github.com/turingchain2020/turingchain@v1.1.21/system/dapp/coins/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 "github.com/turingchain2020/turingchain/types" 9 ) 10 11 // Query_GetAddrReciver query of get address reciver 12 func (c *Coins) Query_GetAddrReciver(in *types.ReqAddr) (types.Message, error) { 13 return c.GetAddrReciver(in) 14 } 15 16 // Query_GetTxsByAddr query get txs by address 17 func (c *Coins) Query_GetTxsByAddr(in *types.ReqAddr) (types.Message, error) { 18 return c.GetTxsByAddr(in) 19 } 20 21 // Query_GetPrefixCount query key counts in the prefix 22 func (c *Coins) Query_GetPrefixCount(in *types.ReqKey) (types.Message, error) { 23 return c.GetPrefixCount(in) 24 } 25 26 // Query_GetAddrTxsCount query count of txs in the address 27 func (c *Coins) Query_GetAddrTxsCount(in *types.ReqKey) (types.Message, error) { 28 return c.GetAddrTxsCount(in) 29 } 30 31 // GetAddrReciver get address reciver by address 32 func (c *Coins) GetAddrReciver(addr *types.ReqAddr) (types.Message, error) { 33 reciver := types.Int64{} 34 db := c.GetLocalDB() 35 addrReciver, err := db.Get(calcAddrKey(addr.Addr)) 36 if addrReciver == nil || err != nil { 37 return &reciver, types.ErrEmpty 38 } 39 err = types.Decode(addrReciver, &reciver) 40 if err != nil { 41 return &reciver, err 42 } 43 return &reciver, nil 44 }