github.com/turingchain2020/turingchain@v1.1.21/system/dapp/manage/executor/query.go (about) 1 // Copyright Turing Corp. 2018 All Rights Reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package executor 6 7 import ( 8 "fmt" 9 10 "github.com/turingchain2020/turingchain/types" 11 ) 12 13 // Query_GetConfigItem get config item 14 func (c *Manage) Query_GetConfigItem(in *types.ReqString) (types.Message, error) { 15 // Load config from state db 16 value, err := c.GetStateDB().Get([]byte(types.ManageKey(in.Data))) 17 if err != nil { 18 clog.Info("modifyConfig", "get db key", "not found") 19 value = nil 20 } 21 if value == nil { 22 value, err = c.GetStateDB().Get([]byte(types.ConfigKey(in.Data))) 23 if err != nil { 24 clog.Info("modifyConfig", "get db key", "not found") 25 value = nil 26 } 27 } 28 29 var reply types.ReplyConfig 30 reply.Key = in.Data 31 32 var item types.ConfigItem 33 if value != nil { 34 err = types.Decode(value, &item) 35 if err != nil { 36 clog.Error("modifyConfig", "get db key", in.Data) 37 return nil, err // types.ErrBadConfigValue 38 } 39 reply.Value = fmt.Sprint(item.GetArr().Value) 40 } else { // if config item not exist 41 reply.Value = "" 42 } 43 clog.Info("manage Query", "key ", in.Data) 44 45 return &reply, nil 46 }