Commit 292c0a50 authored by vipwzw's avatar vipwzw Committed by 33cn

update chain33

parent f933d7da
...@@ -255,7 +255,7 @@ func (client *client) CreateGenesisTx() (ret []*types.Transaction) { ...@@ -255,7 +255,7 @@ func (client *client) CreateGenesisTx() (ret []*types.Transaction) {
return return
} }
func (client *client) ProcEvent(msg queue.Message) bool { func (client *client) ProcEvent(msg *queue.Message) bool {
return false return false
} }
......
...@@ -36,7 +36,7 @@ func NewBlockstore(cfg *types.Consensus, replyChan chan *types.ClientReply, requ ...@@ -36,7 +36,7 @@ func NewBlockstore(cfg *types.Consensus, replyChan chan *types.ClientReply, requ
} }
// ProcEvent method // ProcEvent method
func (client *Client) ProcEvent(msg queue.Message) bool { func (client *Client) ProcEvent(msg *queue.Message) bool {
return false return false
} }
......
...@@ -67,7 +67,7 @@ func (client *Client) CreateGenesisTx() (ret []*types.Transaction) { ...@@ -67,7 +67,7 @@ func (client *Client) CreateGenesisTx() (ret []*types.Transaction) {
} }
// ProcEvent method // ProcEvent method
func (client *Client) ProcEvent(msg queue.Message) bool { func (client *Client) ProcEvent(msg *queue.Message) bool {
return false return false
} }
......
...@@ -359,7 +359,7 @@ func (client *Client) CheckBlock(parent *types.Block, current *types.BlockDetail ...@@ -359,7 +359,7 @@ func (client *Client) CheckBlock(parent *types.Block, current *types.BlockDetail
} }
// ProcEvent ... // ProcEvent ...
func (client *Client) ProcEvent(msg queue.Message) bool { func (client *Client) ProcEvent(msg *queue.Message) bool {
return false return false
} }
......
...@@ -160,7 +160,7 @@ func (client *Client) Query_FlushTicket(req *types.ReqNil) (types.Message, error ...@@ -160,7 +160,7 @@ func (client *Client) Query_FlushTicket(req *types.ReqNil) (types.Message, error
} }
// ProcEvent ticket reply not support action err // ProcEvent ticket reply not support action err
func (client *Client) ProcEvent(msg queue.Message) bool { func (client *Client) ProcEvent(msg *queue.Message) bool {
msg.ReplyErr("Client", types.ErrActionNotSupport) msg.ReplyErr("Client", types.ErrActionNotSupport)
return true return true
} }
......
...@@ -140,7 +140,7 @@ func (kvs *KVStore) IterateRangeByStateHash(statehash []byte, start []byte, end ...@@ -140,7 +140,7 @@ func (kvs *KVStore) IterateRangeByStateHash(statehash []byte, start []byte, end
} }
// ProcEvent handles supported events // ProcEvent handles supported events
func (kvs *KVStore) ProcEvent(msg queue.Message) { func (kvs *KVStore) ProcEvent(msg *queue.Message) {
msg.ReplyErr("KVStore", types.ErrActionNotSupport) msg.ReplyErr("KVStore", types.ErrActionNotSupport)
} }
......
...@@ -174,7 +174,7 @@ func (mvccs *KVMVCCStore) IterateRangeByStateHash(statehash []byte, start []byte ...@@ -174,7 +174,7 @@ func (mvccs *KVMVCCStore) IterateRangeByStateHash(statehash []byte, start []byte
} }
// ProcEvent handles supported events // ProcEvent handles supported events
func (mvccs *KVMVCCStore) ProcEvent(msg queue.Message) { func (mvccs *KVMVCCStore) ProcEvent(msg *queue.Message) {
msg.ReplyErr("KVStore", types.ErrActionNotSupport) msg.ReplyErr("KVStore", types.ErrActionNotSupport)
} }
......
...@@ -158,6 +158,6 @@ func (mpts *Store) IterateRangeByStateHash(statehash []byte, start []byte, end [ ...@@ -158,6 +158,6 @@ func (mpts *Store) IterateRangeByStateHash(statehash []byte, start []byte, end [
} }
// ProcEvent not support message // ProcEvent not support message
func (mpts *Store) ProcEvent(msg queue.Message) { func (mpts *Store) ProcEvent(msg *queue.Message) {
msg.ReplyErr("Store", types.ErrActionNotSupport) msg.ReplyErr("Store", types.ErrActionNotSupport)
} }
...@@ -9,7 +9,7 @@ import ( ...@@ -9,7 +9,7 @@ import (
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
) )
func (chain *BlockChain) procLocalDB(msgtype int64, msg queue.Message, reqnum chan struct{}) bool { func (chain *BlockChain) procLocalDB(msgtype int64, msg *queue.Message, reqnum chan struct{}) bool {
switch msgtype { switch msgtype {
case types.EventLocalGet: case types.EventLocalGet:
go chain.processMsg(msg, reqnum, chain.localGet) go chain.processMsg(msg, reqnum, chain.localGet)
...@@ -35,7 +35,7 @@ func (chain *BlockChain) procLocalDB(msgtype int64, msg queue.Message, reqnum ch ...@@ -35,7 +35,7 @@ func (chain *BlockChain) procLocalDB(msgtype int64, msg queue.Message, reqnum ch
return true return true
} }
func (chain *BlockChain) localGet(msg queue.Message) { func (chain *BlockChain) localGet(msg *queue.Message) {
keys := (msg.Data).(*types.LocalDBGet) keys := (msg.Data).(*types.LocalDBGet)
if keys.Txid == 0 { if keys.Txid == 0 {
values := chain.blockStore.Get(keys) values := chain.blockStore.Get(keys)
...@@ -60,7 +60,7 @@ func (chain *BlockChain) localGet(msg queue.Message) { ...@@ -60,7 +60,7 @@ func (chain *BlockChain) localGet(msg queue.Message) {
} }
//只允许设置 通过 transaction 来 set 信息 //只允许设置 通过 transaction 来 set 信息
func (chain *BlockChain) localSet(msg queue.Message) { func (chain *BlockChain) localSet(msg *queue.Message) {
kvs := (msg.Data).(*types.LocalDBSet) kvs := (msg.Data).(*types.LocalDBSet)
if kvs.Txid == 0 { if kvs.Txid == 0 {
msg.Reply(chain.client.NewMessage("", types.EventLocalSet, types.ErrNotSetInTransaction)) msg.Reply(chain.client.NewMessage("", types.EventLocalSet, types.ErrNotSetInTransaction))
...@@ -82,21 +82,21 @@ func (chain *BlockChain) localSet(msg queue.Message) { ...@@ -82,21 +82,21 @@ func (chain *BlockChain) localSet(msg queue.Message) {
} }
//创建 localdb transaction //创建 localdb transaction
func (chain *BlockChain) localNew(msg queue.Message) { func (chain *BlockChain) localNew(msg *queue.Message) {
tx := NewLocalDB(chain.blockStore.db) tx := NewLocalDB(chain.blockStore.db)
id := common.StorePointer(tx) id := common.StorePointer(tx)
msg.Reply(chain.client.NewMessage("", types.EventLocalNew, &types.Int64{Data: id})) msg.Reply(chain.client.NewMessage("", types.EventLocalNew, &types.Int64{Data: id}))
} }
//关闭 localdb transaction //关闭 localdb transaction
func (chain *BlockChain) localClose(msg queue.Message) { func (chain *BlockChain) localClose(msg *queue.Message) {
id := (msg.Data).(*types.Int64).Data id := (msg.Data).(*types.Int64).Data
_, err := common.GetPointer(id) _, err := common.GetPointer(id)
common.RemovePointer(id) common.RemovePointer(id)
msg.Reply(chain.client.NewMessage("", types.EventLocalClose, err)) msg.Reply(chain.client.NewMessage("", types.EventLocalClose, err))
} }
func (chain *BlockChain) localBegin(msg queue.Message) { func (chain *BlockChain) localBegin(msg *queue.Message) {
id := (msg.Data).(*types.Int64).Data id := (msg.Data).(*types.Int64).Data
tx, err := common.GetPointer(id) tx, err := common.GetPointer(id)
if err != nil { if err != nil {
...@@ -107,7 +107,7 @@ func (chain *BlockChain) localBegin(msg queue.Message) { ...@@ -107,7 +107,7 @@ func (chain *BlockChain) localBegin(msg queue.Message) {
msg.Reply(chain.client.NewMessage("", types.EventLocalBegin, nil)) msg.Reply(chain.client.NewMessage("", types.EventLocalBegin, nil))
} }
func (chain *BlockChain) localCommit(msg queue.Message) { func (chain *BlockChain) localCommit(msg *queue.Message) {
id := (msg.Data).(*types.Int64).Data id := (msg.Data).(*types.Int64).Data
tx, err := common.GetPointer(id) tx, err := common.GetPointer(id)
if err != nil { if err != nil {
...@@ -118,7 +118,7 @@ func (chain *BlockChain) localCommit(msg queue.Message) { ...@@ -118,7 +118,7 @@ func (chain *BlockChain) localCommit(msg queue.Message) {
msg.Reply(chain.client.NewMessage("", types.EventLocalCommit, err)) msg.Reply(chain.client.NewMessage("", types.EventLocalCommit, err))
} }
func (chain *BlockChain) localRollback(msg queue.Message) { func (chain *BlockChain) localRollback(msg *queue.Message) {
id := (msg.Data).(*types.Int64).Data id := (msg.Data).(*types.Int64).Data
tx, err := common.GetPointer(id) tx, err := common.GetPointer(id)
if err != nil { if err != nil {
...@@ -129,7 +129,7 @@ func (chain *BlockChain) localRollback(msg queue.Message) { ...@@ -129,7 +129,7 @@ func (chain *BlockChain) localRollback(msg queue.Message) {
msg.Reply(chain.client.NewMessage("", types.EventLocalRollback, nil)) msg.Reply(chain.client.NewMessage("", types.EventLocalRollback, nil))
} }
func (chain *BlockChain) localList(msg queue.Message) { func (chain *BlockChain) localList(msg *queue.Message) {
q := (msg.Data).(*types.LocalDBList) q := (msg.Data).(*types.LocalDBList)
var values [][]byte var values [][]byte
if q.Txid > 0 { if q.Txid > 0 {
...@@ -150,7 +150,7 @@ func (chain *BlockChain) localList(msg queue.Message) { ...@@ -150,7 +150,7 @@ func (chain *BlockChain) localList(msg queue.Message) {
} }
//获取指定前缀key的数量 //获取指定前缀key的数量
func (chain *BlockChain) localPrefixCount(msg queue.Message) { func (chain *BlockChain) localPrefixCount(msg *queue.Message) {
Prefix := (msg.Data).(*types.ReqKey) Prefix := (msg.Data).(*types.ReqKey)
counts := db.NewListHelper(chain.blockStore.db).PrefixCount(Prefix.Key) counts := db.NewListHelper(chain.blockStore.db).PrefixCount(Prefix.Key)
msg.Reply(chain.client.NewMessage("", types.EventLocalReplyValue, &types.Int64{Data: counts})) msg.Reply(chain.client.NewMessage("", types.EventLocalReplyValue, &types.Int64{Data: counts}))
......
...@@ -96,11 +96,11 @@ func (chain *BlockChain) ProcRecvMsg() { ...@@ -96,11 +96,11 @@ func (chain *BlockChain) ProcRecvMsg() {
} }
} }
func (chain *BlockChain) unknowMsg(msg queue.Message) { func (chain *BlockChain) unknowMsg(msg *queue.Message) {
chainlog.Warn("ProcRecvMsg unknow msg", "msgtype", msg.Ty) chainlog.Warn("ProcRecvMsg unknow msg", "msgtype", msg.Ty)
} }
func (chain *BlockChain) addBlockSeqCB(msg queue.Message) { func (chain *BlockChain) addBlockSeqCB(msg *queue.Message) {
reply := &types.Reply{ reply := &types.Reply{
IsOk: true, IsOk: true,
} }
...@@ -116,7 +116,7 @@ func (chain *BlockChain) addBlockSeqCB(msg queue.Message) { ...@@ -116,7 +116,7 @@ func (chain *BlockChain) addBlockSeqCB(msg queue.Message) {
msg.Reply(chain.client.NewMessage("rpc", types.EventAddBlockSeqCB, reply)) msg.Reply(chain.client.NewMessage("rpc", types.EventAddBlockSeqCB, reply))
} }
func (chain *BlockChain) listBlockSeqCB(msg queue.Message) { func (chain *BlockChain) listBlockSeqCB(msg *queue.Message) {
cbs, err := chain.ProcListBlockSeqCB() cbs, err := chain.ProcListBlockSeqCB()
if err != nil { if err != nil {
chainlog.Error("listBlockSeqCB", "err", err.Error()) chainlog.Error("listBlockSeqCB", "err", err.Error())
...@@ -125,7 +125,7 @@ func (chain *BlockChain) listBlockSeqCB(msg queue.Message) { ...@@ -125,7 +125,7 @@ func (chain *BlockChain) listBlockSeqCB(msg queue.Message) {
} }
msg.Reply(chain.client.NewMessage("rpc", types.EventListBlockSeqCB, cbs)) msg.Reply(chain.client.NewMessage("rpc", types.EventListBlockSeqCB, cbs))
} }
func (chain *BlockChain) getSeqCBLastNum(msg queue.Message) { func (chain *BlockChain) getSeqCBLastNum(msg *queue.Message) {
data := (msg.Data).(*types.ReqString) data := (msg.Data).(*types.ReqString)
num := chain.ProcGetSeqCBLastNum(data.Data) num := chain.ProcGetSeqCBLastNum(data.Data)
...@@ -133,7 +133,7 @@ func (chain *BlockChain) getSeqCBLastNum(msg queue.Message) { ...@@ -133,7 +133,7 @@ func (chain *BlockChain) getSeqCBLastNum(msg queue.Message) {
msg.Reply(chain.client.NewMessage("rpc", types.EventGetSeqCBLastNum, lastNum)) msg.Reply(chain.client.NewMessage("rpc", types.EventGetSeqCBLastNum, lastNum))
} }
func (chain *BlockChain) queryTx(msg queue.Message) { func (chain *BlockChain) queryTx(msg *queue.Message) {
txhash := (msg.Data).(*types.ReqHash) txhash := (msg.Data).(*types.ReqHash)
TransactionDetail, err := chain.ProcQueryTxMsg(txhash.Hash) TransactionDetail, err := chain.ProcQueryTxMsg(txhash.Hash)
if err != nil { if err != nil {
...@@ -145,7 +145,7 @@ func (chain *BlockChain) queryTx(msg queue.Message) { ...@@ -145,7 +145,7 @@ func (chain *BlockChain) queryTx(msg queue.Message) {
} }
} }
func (chain *BlockChain) getBlocks(msg queue.Message) { func (chain *BlockChain) getBlocks(msg *queue.Message) {
requestblocks := (msg.Data).(*types.ReqBlocks) requestblocks := (msg.Data).(*types.ReqBlocks)
blocks, err := chain.ProcGetBlockDetailsMsg(requestblocks) blocks, err := chain.ProcGetBlockDetailsMsg(requestblocks)
if err != nil { if err != nil {
...@@ -157,7 +157,7 @@ func (chain *BlockChain) getBlocks(msg queue.Message) { ...@@ -157,7 +157,7 @@ func (chain *BlockChain) getBlocks(msg queue.Message) {
} }
} }
func (chain *BlockChain) addBlock(msg queue.Message) { func (chain *BlockChain) addBlock(msg *queue.Message) {
//var block *types.Block //var block *types.Block
var reply types.Reply var reply types.Reply
reply.IsOk = true reply.IsOk = true
...@@ -174,14 +174,14 @@ func (chain *BlockChain) addBlock(msg queue.Message) { ...@@ -174,14 +174,14 @@ func (chain *BlockChain) addBlock(msg queue.Message) {
msg.Reply(chain.client.NewMessage("p2p", types.EventReply, &reply)) msg.Reply(chain.client.NewMessage("p2p", types.EventReply, &reply))
} }
func (chain *BlockChain) getBlockHeight(msg queue.Message) { func (chain *BlockChain) getBlockHeight(msg *queue.Message) {
var replyBlockHeight types.ReplyBlockHeight var replyBlockHeight types.ReplyBlockHeight
replyBlockHeight.Height = chain.GetBlockHeight() replyBlockHeight.Height = chain.GetBlockHeight()
//chainlog.Debug("EventGetBlockHeight", "success", "ok") //chainlog.Debug("EventGetBlockHeight", "success", "ok")
msg.Reply(chain.client.NewMessage("consensus", types.EventReplyBlockHeight, &replyBlockHeight)) msg.Reply(chain.client.NewMessage("consensus", types.EventReplyBlockHeight, &replyBlockHeight))
} }
func (chain *BlockChain) txHashList(msg queue.Message) { func (chain *BlockChain) txHashList(msg *queue.Message) {
txhashlist := (msg.Data).(*types.TxHashList) txhashlist := (msg.Data).(*types.TxHashList)
duptxhashlist, err := chain.GetDuplicateTxHashList(txhashlist) duptxhashlist, err := chain.GetDuplicateTxHashList(txhashlist)
if err != nil { if err != nil {
...@@ -193,7 +193,7 @@ func (chain *BlockChain) txHashList(msg queue.Message) { ...@@ -193,7 +193,7 @@ func (chain *BlockChain) txHashList(msg queue.Message) {
msg.Reply(chain.client.NewMessage("consensus", types.EventTxHashListReply, duptxhashlist)) msg.Reply(chain.client.NewMessage("consensus", types.EventTxHashListReply, duptxhashlist))
} }
func (chain *BlockChain) getHeaders(msg queue.Message) { func (chain *BlockChain) getHeaders(msg *queue.Message) {
requestblocks := (msg.Data).(*types.ReqBlocks) requestblocks := (msg.Data).(*types.ReqBlocks)
headers, err := chain.ProcGetHeadersMsg(requestblocks) headers, err := chain.ProcGetHeadersMsg(requestblocks)
if err != nil { if err != nil {
...@@ -205,12 +205,12 @@ func (chain *BlockChain) getHeaders(msg queue.Message) { ...@@ -205,12 +205,12 @@ func (chain *BlockChain) getHeaders(msg queue.Message) {
} }
} }
func (chain *BlockChain) isSync(msg queue.Message) { func (chain *BlockChain) isSync(msg *queue.Message) {
ok := chain.IsCaughtUp() ok := chain.IsCaughtUp()
msg.Reply(chain.client.NewMessage("", types.EventReplyIsSync, &types.IsCaughtUp{Iscaughtup: ok})) msg.Reply(chain.client.NewMessage("", types.EventReplyIsSync, &types.IsCaughtUp{Iscaughtup: ok}))
} }
func (chain *BlockChain) getLastHeader(msg queue.Message) { func (chain *BlockChain) getLastHeader(msg *queue.Message) {
header, err := chain.ProcGetLastHeaderMsg() header, err := chain.ProcGetLastHeaderMsg()
if err != nil { if err != nil {
chainlog.Error("ProcGetLastHeaderMsg", "err", err.Error()) chainlog.Error("ProcGetLastHeaderMsg", "err", err.Error())
...@@ -223,7 +223,7 @@ func (chain *BlockChain) getLastHeader(msg queue.Message) { ...@@ -223,7 +223,7 @@ func (chain *BlockChain) getLastHeader(msg queue.Message) {
//共识过来的block是没有被执行的,首先判断此block的parent block是否是当前best链的tip //共识过来的block是没有被执行的,首先判断此block的parent block是否是当前best链的tip
//在blockchain执行时需要做tx的去重处理,所以在执行成功之后需要将最新区块详情返回给共识模块 //在blockchain执行时需要做tx的去重处理,所以在执行成功之后需要将最新区块详情返回给共识模块
func (chain *BlockChain) addBlockDetail(msg queue.Message) { func (chain *BlockChain) addBlockDetail(msg *queue.Message) {
blockDetail := msg.Data.(*types.BlockDetail) blockDetail := msg.Data.(*types.BlockDetail)
Height := blockDetail.Block.Height Height := blockDetail.Block.Height
chainlog.Info("EventAddBlockDetail", "height", blockDetail.Block.Height, "parent", common.ToHex(blockDetail.Block.ParentHash)) chainlog.Info("EventAddBlockDetail", "height", blockDetail.Block.Height, "parent", common.ToHex(blockDetail.Block.ParentHash))
...@@ -243,7 +243,7 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) { ...@@ -243,7 +243,7 @@ func (chain *BlockChain) addBlockDetail(msg queue.Message) {
msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, blockDetail)) msg.Reply(chain.client.NewMessage("consensus", types.EventAddBlockDetail, blockDetail))
} }
func (chain *BlockChain) broadcastAddBlock(msg queue.Message) { func (chain *BlockChain) broadcastAddBlock(msg *queue.Message) {
var reply types.Reply var reply types.Reply
reply.IsOk = true reply.IsOk = true
blockwithpid := msg.Data.(*types.BlockPid) blockwithpid := msg.Data.(*types.BlockPid)
...@@ -268,7 +268,7 @@ func (chain *BlockChain) broadcastAddBlock(msg queue.Message) { ...@@ -268,7 +268,7 @@ func (chain *BlockChain) broadcastAddBlock(msg queue.Message) {
msg.Reply(chain.client.NewMessage("", types.EventReply, &reply)) msg.Reply(chain.client.NewMessage("", types.EventReply, &reply))
} }
func (chain *BlockChain) getTransactionByAddr(msg queue.Message) { func (chain *BlockChain) getTransactionByAddr(msg *queue.Message) {
addr := (msg.Data).(*types.ReqAddr) addr := (msg.Data).(*types.ReqAddr)
//chainlog.Warn("EventGetTransactionByAddr", "req", addr) //chainlog.Warn("EventGetTransactionByAddr", "req", addr)
replyTxInfos, err := chain.ProcGetTransactionByAddr(addr) replyTxInfos, err := chain.ProcGetTransactionByAddr(addr)
...@@ -281,7 +281,7 @@ func (chain *BlockChain) getTransactionByAddr(msg queue.Message) { ...@@ -281,7 +281,7 @@ func (chain *BlockChain) getTransactionByAddr(msg queue.Message) {
} }
} }
func (chain *BlockChain) getTransactionByHashes(msg queue.Message) { func (chain *BlockChain) getTransactionByHashes(msg *queue.Message) {
txhashs := (msg.Data).(*types.ReqHashes) txhashs := (msg.Data).(*types.ReqHashes)
//chainlog.Info("EventGetTransactionByHash", "hash", txhashs) //chainlog.Info("EventGetTransactionByHash", "hash", txhashs)
TransactionDetails, err := chain.ProcGetTransactionByHashes(txhashs.Hashes) TransactionDetails, err := chain.ProcGetTransactionByHashes(txhashs.Hashes)
...@@ -294,7 +294,7 @@ func (chain *BlockChain) getTransactionByHashes(msg queue.Message) { ...@@ -294,7 +294,7 @@ func (chain *BlockChain) getTransactionByHashes(msg queue.Message) {
} }
} }
func (chain *BlockChain) getBlockOverview(msg queue.Message) { func (chain *BlockChain) getBlockOverview(msg *queue.Message) {
ReqHash := (msg.Data).(*types.ReqHash) ReqHash := (msg.Data).(*types.ReqHash)
BlockOverview, err := chain.ProcGetBlockOverview(ReqHash) BlockOverview, err := chain.ProcGetBlockOverview(ReqHash)
if err != nil { if err != nil {
...@@ -306,7 +306,7 @@ func (chain *BlockChain) getBlockOverview(msg queue.Message) { ...@@ -306,7 +306,7 @@ func (chain *BlockChain) getBlockOverview(msg queue.Message) {
} }
} }
func (chain *BlockChain) getAddrOverview(msg queue.Message) { func (chain *BlockChain) getAddrOverview(msg *queue.Message) {
addr := (msg.Data).(*types.ReqAddr) addr := (msg.Data).(*types.ReqAddr)
AddrOverview, err := chain.ProcGetAddrOverview(addr) AddrOverview, err := chain.ProcGetAddrOverview(addr)
if err != nil { if err != nil {
...@@ -318,7 +318,7 @@ func (chain *BlockChain) getAddrOverview(msg queue.Message) { ...@@ -318,7 +318,7 @@ func (chain *BlockChain) getAddrOverview(msg queue.Message) {
} }
} }
func (chain *BlockChain) getBlockHash(msg queue.Message) { func (chain *BlockChain) getBlockHash(msg *queue.Message) {
height := (msg.Data).(*types.ReqInt) height := (msg.Data).(*types.ReqInt)
replyhash, err := chain.ProcGetBlockHash(height) replyhash, err := chain.ProcGetBlockHash(height)
if err != nil { if err != nil {
...@@ -330,7 +330,7 @@ func (chain *BlockChain) getBlockHash(msg queue.Message) { ...@@ -330,7 +330,7 @@ func (chain *BlockChain) getBlockHash(msg queue.Message) {
} }
} }
func (chain *BlockChain) addBlockHeaders(msg queue.Message) { func (chain *BlockChain) addBlockHeaders(msg *queue.Message) {
var reply types.Reply var reply types.Reply
reply.IsOk = true reply.IsOk = true
headerspid := msg.Data.(*types.HeadersPid) headerspid := msg.Data.(*types.HeadersPid)
...@@ -345,7 +345,7 @@ func (chain *BlockChain) addBlockHeaders(msg queue.Message) { ...@@ -345,7 +345,7 @@ func (chain *BlockChain) addBlockHeaders(msg queue.Message) {
msg.Reply(chain.client.NewMessage("p2p", types.EventReply, &reply)) msg.Reply(chain.client.NewMessage("p2p", types.EventReply, &reply))
} }
func (chain *BlockChain) getLastBlock(msg queue.Message) { func (chain *BlockChain) getLastBlock(msg *queue.Message) {
block, err := chain.ProcGetLastBlockMsg() block, err := chain.ProcGetLastBlockMsg()
if err != nil { if err != nil {
chainlog.Error("ProcGetLastBlockMsg", "err", err.Error()) chainlog.Error("ProcGetLastBlockMsg", "err", err.Error())
...@@ -356,14 +356,14 @@ func (chain *BlockChain) getLastBlock(msg queue.Message) { ...@@ -356,14 +356,14 @@ func (chain *BlockChain) getLastBlock(msg queue.Message) {
} }
} }
func (chain *BlockChain) isNtpClockSync(msg queue.Message) { func (chain *BlockChain) isNtpClockSync(msg *queue.Message) {
ok := GetNtpClockSyncStatus() ok := GetNtpClockSyncStatus()
msg.Reply(chain.client.NewMessage("", types.EventReplyIsNtpClockSync, &types.IsNtpClockSync{Isntpclocksync: ok})) msg.Reply(chain.client.NewMessage("", types.EventReplyIsNtpClockSync, &types.IsNtpClockSync{Isntpclocksync: ok}))
} }
type funcProcess func(msg queue.Message) type funcProcess func(msg *queue.Message)
func (chain *BlockChain) processMsg(msg queue.Message, reqnum chan struct{}, cb funcProcess) { func (chain *BlockChain) processMsg(msg *queue.Message, reqnum chan struct{}, cb funcProcess) {
beg := types.Now() beg := types.Now()
defer func() { defer func() {
<-reqnum <-reqnum
...@@ -374,7 +374,7 @@ func (chain *BlockChain) processMsg(msg queue.Message, reqnum chan struct{}, cb ...@@ -374,7 +374,7 @@ func (chain *BlockChain) processMsg(msg queue.Message, reqnum chan struct{}, cb
} }
//获取最新的block执行序列号 //获取最新的block执行序列号
func (chain *BlockChain) getLastBlockSequence(msg queue.Message) { func (chain *BlockChain) getLastBlockSequence(msg *queue.Message) {
var lastSequence types.Int64 var lastSequence types.Int64
var err error var err error
lastSequence.Data, err = chain.blockStore.LoadBlockLastSequence() lastSequence.Data, err = chain.blockStore.LoadBlockLastSequence()
...@@ -385,7 +385,7 @@ func (chain *BlockChain) getLastBlockSequence(msg queue.Message) { ...@@ -385,7 +385,7 @@ func (chain *BlockChain) getLastBlockSequence(msg queue.Message) {
} }
//获取指定区间的block执行序列信息,包含blockhash和操作类型:add/del //获取指定区间的block执行序列信息,包含blockhash和操作类型:add/del
func (chain *BlockChain) getBlockSequences(msg queue.Message) { func (chain *BlockChain) getBlockSequences(msg *queue.Message) {
requestSequences := (msg.Data).(*types.ReqBlocks) requestSequences := (msg.Data).(*types.ReqBlocks)
BlockSequences, err := chain.GetBlockSequences(requestSequences) BlockSequences, err := chain.GetBlockSequences(requestSequences)
if err != nil { if err != nil {
...@@ -396,7 +396,7 @@ func (chain *BlockChain) getBlockSequences(msg queue.Message) { ...@@ -396,7 +396,7 @@ func (chain *BlockChain) getBlockSequences(msg queue.Message) {
} }
} }
func (chain *BlockChain) getBlockByHashes(msg queue.Message) { func (chain *BlockChain) getBlockByHashes(msg *queue.Message) {
blockhashes := (msg.Data).(*types.ReqHashes) blockhashes := (msg.Data).(*types.ReqHashes)
BlockDetails, err := chain.GetBlockByHashes(blockhashes.Hashes) BlockDetails, err := chain.GetBlockByHashes(blockhashes.Hashes)
if err != nil { if err != nil {
...@@ -407,7 +407,7 @@ func (chain *BlockChain) getBlockByHashes(msg queue.Message) { ...@@ -407,7 +407,7 @@ func (chain *BlockChain) getBlockByHashes(msg queue.Message) {
} }
} }
func (chain *BlockChain) getBlockBySeq(msg queue.Message) { func (chain *BlockChain) getBlockBySeq(msg *queue.Message) {
seq := (msg.Data).(*types.Int64) seq := (msg.Data).(*types.Int64)
req := &types.ReqBlocks{Start: seq.Data, End: seq.Data, IsDetail: false, Pid: []string{}} req := &types.ReqBlocks{Start: seq.Data, End: seq.Data, IsDetail: false, Pid: []string{}}
sequences, err := chain.GetBlockSequences(req) sequences, err := chain.GetBlockSequences(req)
...@@ -434,7 +434,7 @@ func (chain *BlockChain) getBlockBySeq(msg queue.Message) { ...@@ -434,7 +434,7 @@ func (chain *BlockChain) getBlockBySeq(msg queue.Message) {
} }
//平行链del block的处理 //平行链del block的处理
func (chain *BlockChain) delParaChainBlockDetail(msg queue.Message) { func (chain *BlockChain) delParaChainBlockDetail(msg *queue.Message) {
var parablockDetail *types.ParaChainBlockDetail var parablockDetail *types.ParaChainBlockDetail
var reply types.Reply var reply types.Reply
reply.IsOk = true reply.IsOk = true
...@@ -454,7 +454,7 @@ func (chain *BlockChain) delParaChainBlockDetail(msg queue.Message) { ...@@ -454,7 +454,7 @@ func (chain *BlockChain) delParaChainBlockDetail(msg queue.Message) {
} }
//平行链add block的处理 //平行链add block的处理
func (chain *BlockChain) addParaChainBlockDetail(msg queue.Message) { func (chain *BlockChain) addParaChainBlockDetail(msg *queue.Message) {
parablockDetail := msg.Data.(*types.ParaChainBlockDetail) parablockDetail := msg.Data.(*types.ParaChainBlockDetail)
chainlog.Debug("EventAddParaChainBlockDetail", "height", parablockDetail.Blockdetail.Block.Height, "hash", common.HashHex(parablockDetail.Blockdetail.Block.Hash())) chainlog.Debug("EventAddParaChainBlockDetail", "height", parablockDetail.Blockdetail.Block.Height, "hash", common.HashHex(parablockDetail.Blockdetail.Block.Hash()))
...@@ -469,7 +469,7 @@ func (chain *BlockChain) addParaChainBlockDetail(msg queue.Message) { ...@@ -469,7 +469,7 @@ func (chain *BlockChain) addParaChainBlockDetail(msg queue.Message) {
} }
//parachian 通过blockhash获取对应的seq,只记录了addblock时的seq //parachian 通过blockhash获取对应的seq,只记录了addblock时的seq
func (chain *BlockChain) getSeqByHash(msg queue.Message) { func (chain *BlockChain) getSeqByHash(msg *queue.Message) {
blockhash := (msg.Data).(*types.ReqHash) blockhash := (msg.Data).(*types.ReqHash)
seq, err := chain.ProcGetSeqByHash(blockhash.Hash) seq, err := chain.ProcGetSeqByHash(blockhash.Hash)
if err != nil { if err != nil {
...@@ -480,7 +480,7 @@ func (chain *BlockChain) getSeqByHash(msg queue.Message) { ...@@ -480,7 +480,7 @@ func (chain *BlockChain) getSeqByHash(msg queue.Message) {
} }
//获取指定地址参与的tx交易计数 //获取指定地址参与的tx交易计数
func (chain *BlockChain) localAddrTxCount(msg queue.Message) { func (chain *BlockChain) localAddrTxCount(msg *queue.Message) {
reqkey := (msg.Data).(*types.ReqKey) reqkey := (msg.Data).(*types.ReqKey)
count := types.Int64{} count := types.Int64{}
......
...@@ -56,26 +56,26 @@ type mockClient struct { ...@@ -56,26 +56,26 @@ type mockClient struct {
c queue.Client c queue.Client
} }
func (mock *mockClient) Send(msg queue.Message, waitReply bool) error { func (mock *mockClient) Send(msg *queue.Message, waitReply bool) error {
if msg.Topic == "error" { if msg.Topic == "error" {
return types.ErrInvalidParam return types.ErrInvalidParam
} }
return mock.c.Send(msg, waitReply) return mock.c.Send(msg, waitReply)
} }
func (mock *mockClient) SendTimeout(msg queue.Message, waitReply bool, timeout time.Duration) error { func (mock *mockClient) SendTimeout(msg *queue.Message, waitReply bool, timeout time.Duration) error {
return mock.c.SendTimeout(msg, waitReply, timeout) return mock.c.SendTimeout(msg, waitReply, timeout)
} }
func (mock *mockClient) Wait(msg queue.Message) (queue.Message, error) { func (mock *mockClient) Wait(msg *queue.Message) (*queue.Message, error) {
return mock.c.Wait(msg) return mock.c.Wait(msg)
} }
func (mock *mockClient) WaitTimeout(msg queue.Message, timeout time.Duration) (queue.Message, error) { func (mock *mockClient) WaitTimeout(msg *queue.Message, timeout time.Duration) (*queue.Message, error) {
return mock.c.WaitTimeout(msg, timeout) return mock.c.WaitTimeout(msg, timeout)
} }
func (mock *mockClient) Recv() chan queue.Message { func (mock *mockClient) Recv() chan *queue.Message {
return mock.c.Recv() return mock.c.Recv()
} }
...@@ -92,7 +92,7 @@ func (mock *mockClient) CloseQueue() (*types.Reply, error) { ...@@ -92,7 +92,7 @@ func (mock *mockClient) CloseQueue() (*types.Reply, error) {
return &types.Reply{IsOk: true, Msg: []byte("Ok")}, nil return &types.Reply{IsOk: true, Msg: []byte("Ok")}, nil
} }
func (mock *mockClient) NewMessage(topic string, ty int64, data interface{}) queue.Message { func (mock *mockClient) NewMessage(topic string, ty int64, data interface{}) *queue.Message {
return mock.c.NewMessage(topic, ty, data) return mock.c.NewMessage(topic, ty, data)
} }
......
...@@ -869,28 +869,32 @@ func (_m *QueueProtocolAPI) NewAccount(param *types.ReqNewAccount) (*types.Walle ...@@ -869,28 +869,32 @@ func (_m *QueueProtocolAPI) NewAccount(param *types.ReqNewAccount) (*types.Walle
} }
// NewMessage provides a mock function with given fields: topic, msgid, data // NewMessage provides a mock function with given fields: topic, msgid, data
func (_m *QueueProtocolAPI) NewMessage(topic string, msgid int64, data interface{}) queue.Message { func (_m *QueueProtocolAPI) NewMessage(topic string, msgid int64, data interface{}) *queue.Message {
ret := _m.Called(topic, msgid, data) ret := _m.Called(topic, msgid, data)
var r0 queue.Message var r0 *queue.Message
if rf, ok := ret.Get(0).(func(string, int64, interface{}) queue.Message); ok { if rf, ok := ret.Get(0).(func(string, int64, interface{}) *queue.Message); ok {
r0 = rf(topic, msgid, data) r0 = rf(topic, msgid, data)
} else { } else {
r0 = ret.Get(0).(queue.Message) if ret.Get(0) != nil {
r0 = ret.Get(0).(*queue.Message)
}
} }
return r0 return r0
} }
// Notify provides a mock function with given fields: topic, ty, data // Notify provides a mock function with given fields: topic, ty, data
func (_m *QueueProtocolAPI) Notify(topic string, ty int64, data interface{}) (queue.Message, error) { func (_m *QueueProtocolAPI) Notify(topic string, ty int64, data interface{}) (*queue.Message, error) {
ret := _m.Called(topic, ty, data) ret := _m.Called(topic, ty, data)
var r0 queue.Message var r0 *queue.Message
if rf, ok := ret.Get(0).(func(string, int64, interface{}) queue.Message); ok { if rf, ok := ret.Get(0).(func(string, int64, interface{}) *queue.Message); ok {
r0 = rf(topic, ty, data) r0 = rf(topic, ty, data)
} else { } else {
r0 = ret.Get(0).(queue.Message) if ret.Get(0) != nil {
r0 = ret.Get(0).(*queue.Message)
}
} }
var r1 error var r1 error
......
...@@ -55,34 +55,34 @@ func New(client queue.Client, option *QueueProtocolOption) (QueueProtocolAPI, er ...@@ -55,34 +55,34 @@ func New(client queue.Client, option *QueueProtocolOption) (QueueProtocolAPI, er
if option != nil { if option != nil {
q.option = *option q.option = *option
} else { } else {
q.option.SendTimeout = 600 * time.Second q.option.SendTimeout = time.Duration(-1)
q.option.WaitTimeout = 600 * time.Second q.option.WaitTimeout = time.Duration(-1)
} }
return q, nil return q, nil
} }
func (q *QueueProtocol) query(topic string, ty int64, data interface{}) (queue.Message, error) { func (q *QueueProtocol) query(topic string, ty int64, data interface{}) (*queue.Message, error) {
client := q.client client := q.client
msg := client.NewMessage(topic, ty, data) msg := client.NewMessage(topic, ty, data)
err := client.SendTimeout(msg, true, q.option.SendTimeout) err := client.SendTimeout(msg, true, q.option.SendTimeout)
if err != nil { if err != nil {
return queue.Message{}, err return &queue.Message{}, err
} }
return client.WaitTimeout(msg, q.option.WaitTimeout) return client.WaitTimeout(msg, q.option.WaitTimeout)
} }
func (q *QueueProtocol) notify(topic string, ty int64, data interface{}) (queue.Message, error) { func (q *QueueProtocol) notify(topic string, ty int64, data interface{}) (*queue.Message, error) {
client := q.client client := q.client
msg := client.NewMessage(topic, ty, data) msg := client.NewMessage(topic, ty, data)
err := client.SendTimeout(msg, false, q.option.SendTimeout) err := client.SendTimeout(msg, false, q.option.SendTimeout)
if err != nil { if err != nil {
return queue.Message{}, err return &queue.Message{}, err
} }
return msg, err return msg, err
} }
// Notify new and send client message // Notify new and send client message
func (q *QueueProtocol) Notify(topic string, ty int64, data interface{}) (queue.Message, error) { func (q *QueueProtocol) Notify(topic string, ty int64, data interface{}) (*queue.Message, error) {
return q.notify(topic, ty, data) return q.notify(topic, ty, data)
} }
...@@ -92,7 +92,7 @@ func (q *QueueProtocol) Close() { ...@@ -92,7 +92,7 @@ func (q *QueueProtocol) Close() {
} }
// NewMessage new message // NewMessage new message
func (q *QueueProtocol) NewMessage(topic string, msgid int64, data interface{}) queue.Message { func (q *QueueProtocol) NewMessage(topic string, msgid int64, data interface{}) *queue.Message {
return q.client.NewMessage(topic, msgid, data) return q.client.NewMessage(topic, msgid, data)
} }
......
...@@ -13,8 +13,8 @@ import ( ...@@ -13,8 +13,8 @@ import (
type QueueProtocolAPI interface { type QueueProtocolAPI interface {
Version() (*types.VersionInfo, error) Version() (*types.VersionInfo, error)
Close() Close()
NewMessage(topic string, msgid int64, data interface{}) queue.Message NewMessage(topic string, msgid int64, data interface{}) *queue.Message
Notify(topic string, ty int64, data interface{}) (queue.Message, error) Notify(topic string, ty int64, data interface{}) (*queue.Message, error)
// +++++++++++++++ mempool interfaces begin // +++++++++++++++ mempool interfaces begin
// 同步发送交易信息到指定模块,获取应答消息 types.EventTx // 同步发送交易信息到指定模块,获取应答消息 types.EventTx
SendTx(param *types.Transaction) (*types.Reply, error) SendTx(param *types.Transaction) (*types.Reply, error)
......
...@@ -129,7 +129,7 @@ func (exec *Executor) SetQueueClient(qcli queue.Client) { ...@@ -129,7 +129,7 @@ func (exec *Executor) SetQueueClient(qcli queue.Client) {
}() }()
} }
func (exec *Executor) procExecQuery(msg queue.Message) { func (exec *Executor) procExecQuery(msg *queue.Message) {
header, err := exec.qclient.GetLastHeader() header, err := exec.qclient.GetLastHeader()
if err != nil { if err != nil {
msg.Reply(exec.client.NewMessage("", types.EventBlockChainQuery, err)) msg.Reply(exec.client.NewMessage("", types.EventBlockChainQuery, err))
...@@ -168,7 +168,7 @@ func (exec *Executor) procExecQuery(msg queue.Message) { ...@@ -168,7 +168,7 @@ func (exec *Executor) procExecQuery(msg queue.Message) {
msg.Reply(exec.client.NewMessage("", types.EventBlockChainQuery, ret)) msg.Reply(exec.client.NewMessage("", types.EventBlockChainQuery, ret))
} }
func (exec *Executor) procExecCheckTx(msg queue.Message) { func (exec *Executor) procExecCheckTx(msg *queue.Message) {
datas := msg.GetData().(*types.ExecTxList) datas := msg.GetData().(*types.ExecTxList)
ctx := &executorCtx{ ctx := &executorCtx{
stateHash: datas.StateHash, stateHash: datas.StateHash,
...@@ -204,7 +204,7 @@ func (exec *Executor) procExecCheckTx(msg queue.Message) { ...@@ -204,7 +204,7 @@ func (exec *Executor) procExecCheckTx(msg queue.Message) {
msg.Reply(exec.client.NewMessage("", types.EventReceiptCheckTx, result)) msg.Reply(exec.client.NewMessage("", types.EventReceiptCheckTx, result))
} }
func (exec *Executor) procExecTxList(msg queue.Message) { func (exec *Executor) procExecTxList(msg *queue.Message) {
datas := msg.GetData().(*types.ExecTxList) datas := msg.GetData().(*types.ExecTxList)
ctx := &executorCtx{ ctx := &executorCtx{
stateHash: datas.StateHash, stateHash: datas.StateHash,
...@@ -278,7 +278,7 @@ func (exec *Executor) procExecTxList(msg queue.Message) { ...@@ -278,7 +278,7 @@ func (exec *Executor) procExecTxList(msg queue.Message) {
&types.Receipts{Receipts: receipts})) &types.Receipts{Receipts: receipts}))
} }
func (exec *Executor) procExecAddBlock(msg queue.Message) { func (exec *Executor) procExecAddBlock(msg *queue.Message) {
datas := msg.GetData().(*types.BlockDetail) datas := msg.GetData().(*types.BlockDetail)
b := datas.Block b := datas.Block
ctx := &executorCtx{ ctx := &executorCtx{
...@@ -340,7 +340,7 @@ func (exec *Executor) procExecAddBlock(msg queue.Message) { ...@@ -340,7 +340,7 @@ func (exec *Executor) procExecAddBlock(msg queue.Message) {
msg.Reply(exec.client.NewMessage("", types.EventAddBlock, &kvset)) msg.Reply(exec.client.NewMessage("", types.EventAddBlock, &kvset))
} }
func (exec *Executor) procExecDelBlock(msg queue.Message) { func (exec *Executor) procExecDelBlock(msg *queue.Message) {
datas := msg.GetData().(*types.BlockDetail) datas := msg.GetData().(*types.BlockDetail)
b := datas.Block b := datas.Block
ctx := &executorCtx{ ctx := &executorCtx{
......
...@@ -23,13 +23,13 @@ import ( ...@@ -23,13 +23,13 @@ import (
// EventInterface p2p subscribe to the event hander interface // EventInterface p2p subscribe to the event hander interface
type EventInterface interface { type EventInterface interface {
BroadCastTx(msg queue.Message, taskindex int64) BroadCastTx(msg *queue.Message, taskindex int64)
GetMemPool(msg queue.Message, taskindex int64) GetMemPool(msg *queue.Message, taskindex int64)
GetPeerInfo(msg queue.Message, taskindex int64) GetPeerInfo(msg *queue.Message, taskindex int64)
GetHeaders(msg queue.Message, taskindex int64) GetHeaders(msg *queue.Message, taskindex int64)
GetBlocks(msg queue.Message, taskindex int64) GetBlocks(msg *queue.Message, taskindex int64)
BlockBroadcast(msg queue.Message, taskindex int64) BlockBroadcast(msg *queue.Message, taskindex int64)
GetNetInfo(msg queue.Message, taskindex int64) GetNetInfo(msg *queue.Message, taskindex int64)
} }
// NormalInterface subscribe to the event hander interface // NormalInterface subscribe to the event hander interface
...@@ -67,7 +67,7 @@ func NewNormalP2PCli() NormalInterface { ...@@ -67,7 +67,7 @@ func NewNormalP2PCli() NormalInterface {
} }
// BroadCastTx broadcast transactions // BroadCastTx broadcast transactions
func (m *Cli) BroadCastTx(msg queue.Message, taskindex int64) { func (m *Cli) BroadCastTx(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
<-m.network.txFactory <-m.network.txFactory
atomic.AddInt32(&m.network.txCapcity, 1) atomic.AddInt32(&m.network.txCapcity, 1)
...@@ -78,7 +78,7 @@ func (m *Cli) BroadCastTx(msg queue.Message, taskindex int64) { ...@@ -78,7 +78,7 @@ func (m *Cli) BroadCastTx(msg queue.Message, taskindex int64) {
} }
// GetMemPool get mempool contents // GetMemPool get mempool contents
func (m *Cli) GetMemPool(msg queue.Message, taskindex int64) { func (m *Cli) GetMemPool(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
<-m.network.otherFactory <-m.network.otherFactory
log.Debug("GetMemPool", "task complete:", taskindex) log.Debug("GetMemPool", "task complete:", taskindex)
...@@ -198,8 +198,7 @@ func (m *Cli) GetAddrList(peer *Peer) (map[string]int64, error) { ...@@ -198,8 +198,7 @@ func (m *Cli) GetAddrList(peer *Peer) (map[string]int64, error) {
log.Error("getLocalPeerInfo blockchain", "Error", err.Error()) log.Error("getLocalPeerInfo blockchain", "Error", err.Error())
return addrlist, err return addrlist, err
} }
var respmsg queue.Message respmsg, err := client.WaitTimeout(msg, time.Second*30)
respmsg, err = client.WaitTimeout(msg, time.Second*30)
if err != nil { if err != nil {
return addrlist, err return addrlist, err
} }
...@@ -318,7 +317,7 @@ func (m *Cli) GetBlockHeight(nodeinfo *NodeInfo) (int64, error) { ...@@ -318,7 +317,7 @@ func (m *Cli) GetBlockHeight(nodeinfo *NodeInfo) (int64, error) {
} }
// GetPeerInfo return peer information // GetPeerInfo return peer information
func (m *Cli) GetPeerInfo(msg queue.Message, taskindex int64) { func (m *Cli) GetPeerInfo(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
log.Debug("GetPeerInfo", "task complete:", taskindex) log.Debug("GetPeerInfo", "task complete:", taskindex)
}() }()
...@@ -343,7 +342,7 @@ func (m *Cli) GetPeerInfo(msg queue.Message, taskindex int64) { ...@@ -343,7 +342,7 @@ func (m *Cli) GetPeerInfo(msg queue.Message, taskindex int64) {
} }
// GetHeaders get headers information // GetHeaders get headers information
func (m *Cli) GetHeaders(msg queue.Message, taskindex int64) { func (m *Cli) GetHeaders(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
<-m.network.otherFactory <-m.network.otherFactory
log.Debug("GetHeaders", "task complete:", taskindex) log.Debug("GetHeaders", "task complete:", taskindex)
...@@ -388,7 +387,7 @@ func (m *Cli) GetHeaders(msg queue.Message, taskindex int64) { ...@@ -388,7 +387,7 @@ func (m *Cli) GetHeaders(msg queue.Message, taskindex int64) {
} }
// GetBlocks get blocks information // GetBlocks get blocks information
func (m *Cli) GetBlocks(msg queue.Message, taskindex int64) { func (m *Cli) GetBlocks(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
<-m.network.otherFactory <-m.network.otherFactory
log.Debug("GetBlocks", "task complete:", taskindex) log.Debug("GetBlocks", "task complete:", taskindex)
...@@ -546,7 +545,7 @@ func (m *Cli) GetBlocks(msg queue.Message, taskindex int64) { ...@@ -546,7 +545,7 @@ func (m *Cli) GetBlocks(msg queue.Message, taskindex int64) {
} }
// BlockBroadcast block broadcast // BlockBroadcast block broadcast
func (m *Cli) BlockBroadcast(msg queue.Message, taskindex int64) { func (m *Cli) BlockBroadcast(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
<-m.network.otherFactory <-m.network.otherFactory
log.Debug("BlockBroadcast", "task complete:", taskindex) log.Debug("BlockBroadcast", "task complete:", taskindex)
...@@ -555,7 +554,7 @@ func (m *Cli) BlockBroadcast(msg queue.Message, taskindex int64) { ...@@ -555,7 +554,7 @@ func (m *Cli) BlockBroadcast(msg queue.Message, taskindex int64) {
} }
// GetNetInfo get network information // GetNetInfo get network information
func (m *Cli) GetNetInfo(msg queue.Message, taskindex int64) { func (m *Cli) GetNetInfo(msg *queue.Message, taskindex int64) {
defer func() { defer func() {
<-m.network.otherFactory <-m.network.otherFactory
log.Debug("GetNetInfo", "task complete:", taskindex) log.Debug("GetNetInfo", "task complete:", taskindex)
......
...@@ -29,15 +29,15 @@ var gid int64 ...@@ -29,15 +29,15 @@ var gid int64
// Client 消息队列的接口,每个模块都需要一个发送接受client // Client 消息队列的接口,每个模块都需要一个发送接受client
type Client interface { type Client interface {
Send(msg Message, waitReply bool) (err error) //同步发送消息 Send(msg *Message, waitReply bool) (err error) //同步发送消息
SendTimeout(msg Message, waitReply bool, timeout time.Duration) (err error) SendTimeout(msg *Message, waitReply bool, timeout time.Duration) (err error)
Wait(msg Message) (Message, error) //等待消息处理完成 Wait(msg *Message) (*Message, error) //等待消息处理完成
WaitTimeout(msg Message, timeout time.Duration) (Message, error) //等待消息处理完成 WaitTimeout(msg *Message, timeout time.Duration) (*Message, error) //等待消息处理完成
Recv() chan Message Recv() chan *Message
Sub(topic string) //订阅消息 Sub(topic string) //订阅消息
Close() Close()
CloseQueue() (*types.Reply, error) CloseQueue() (*types.Reply, error)
NewMessage(topic string, ty int64, data interface{}) (msg Message) NewMessage(topic string, ty int64, data interface{}) (msg *Message)
} }
// Module be used for module interface // Module be used for module interface
...@@ -50,7 +50,7 @@ type Module interface { ...@@ -50,7 +50,7 @@ type Module interface {
type client struct { type client struct {
q *queue q *queue
recv chan Message recv chan *Message
done chan struct{} done chan struct{}
wg *sync.WaitGroup wg *sync.WaitGroup
topic unsafe.Pointer topic unsafe.Pointer
...@@ -61,7 +61,7 @@ type client struct { ...@@ -61,7 +61,7 @@ type client struct {
func newClient(q *queue) Client { func newClient(q *queue) Client {
client := &client{} client := &client{}
client.q = q client.q = q
client.recv = make(chan Message, 5) client.recv = make(chan *Message, 5)
client.done = make(chan struct{}, 1) client.done = make(chan struct{}, 1)
client.wg = &sync.WaitGroup{} client.wg = &sync.WaitGroup{}
return client return client
...@@ -70,11 +70,8 @@ func newClient(q *queue) Client { ...@@ -70,11 +70,8 @@ func newClient(q *queue) Client {
// Send 发送消息,msg 消息 ,waitReply 是否等待回应 // Send 发送消息,msg 消息 ,waitReply 是否等待回应
//1. 系统保证send出去的消息就是成功了,除非系统崩溃 //1. 系统保证send出去的消息就是成功了,除非系统崩溃
//2. 系统保证每个消息都有对应的 response 消息 //2. 系统保证每个消息都有对应的 response 消息
func (client *client) Send(msg Message, waitReply bool) (err error) { func (client *client) Send(msg *Message, waitReply bool) (err error) {
timeout := 10 * time.Minute timeout := time.Duration(-1)
if types.IsTestNet() {
timeout = time.Minute
}
err = client.SendTimeout(msg, waitReply, timeout) err = client.SendTimeout(msg, waitReply, timeout)
if err == ErrQueueTimeout { if err == ErrQueueTimeout {
panic(err) panic(err)
...@@ -83,7 +80,7 @@ func (client *client) Send(msg Message, waitReply bool) (err error) { ...@@ -83,7 +80,7 @@ func (client *client) Send(msg Message, waitReply bool) (err error) {
} }
// SendTimeout 超时发送, msg 消息 ,waitReply 是否等待回应, timeout 超时时间 // SendTimeout 超时发送, msg 消息 ,waitReply 是否等待回应, timeout 超时时间
func (client *client) SendTimeout(msg Message, waitReply bool, timeout time.Duration) (err error) { func (client *client) SendTimeout(msg *Message, waitReply bool, timeout time.Duration) (err error) {
if client.isClose() { if client.isClose() {
return ErrIsQueueClosed return ErrIsQueueClosed
} }
...@@ -99,15 +96,19 @@ func (client *client) SendTimeout(msg Message, waitReply bool, timeout time.Dura ...@@ -99,15 +96,19 @@ func (client *client) SendTimeout(msg Message, waitReply bool, timeout time.Dura
//2. Send 高优先级别的发送消息 //2. Send 高优先级别的发送消息
// NewMessage 新建消息 topic模块名称 ty消息类型 data 数据 // NewMessage 新建消息 topic模块名称 ty消息类型 data 数据
func (client *client) NewMessage(topic string, ty int64, data interface{}) (msg Message) { func (client *client) NewMessage(topic string, ty int64, data interface{}) (msg *Message) {
id := atomic.AddInt64(&gid, 1) id := atomic.AddInt64(&gid, 1)
return NewMessage(id, topic, ty, data) return NewMessage(id, topic, ty, data)
} }
// WaitTimeout 等待时间 msg 消息 timeout 超时时间 // WaitTimeout 等待时间 msg 消息 timeout 超时时间
func (client *client) WaitTimeout(msg Message, timeout time.Duration) (Message, error) { func (client *client) WaitTimeout(msg *Message, timeout time.Duration) (*Message, error) {
if msg.chReply == nil { if msg.chReply == nil {
return Message{}, errors.New("empty wait channel") return &Message{}, errors.New("empty wait channel")
}
if timeout == -1 {
msg = <-msg.chReply
return msg, msg.Err()
} }
t := time.NewTimer(timeout) t := time.NewTimer(timeout)
defer t.Stop() defer t.Stop()
...@@ -115,18 +116,15 @@ func (client *client) WaitTimeout(msg Message, timeout time.Duration) (Message, ...@@ -115,18 +116,15 @@ func (client *client) WaitTimeout(msg Message, timeout time.Duration) (Message,
case msg = <-msg.chReply: case msg = <-msg.chReply:
return msg, msg.Err() return msg, msg.Err()
case <-client.done: case <-client.done:
return Message{}, ErrIsQueueClosed return &Message{}, ErrIsQueueClosed
case <-t.C: case <-t.C:
return Message{}, ErrQueueTimeout return &Message{}, ErrQueueTimeout
} }
} }
// Wait 等待时间 // Wait 等待时间
func (client *client) Wait(msg Message) (Message, error) { func (client *client) Wait(msg *Message) (*Message, error) {
timeout := 10 * time.Minute timeout := time.Duration(-1)
if types.IsTestNet() {
timeout = 5 * time.Minute
}
msg, err := client.WaitTimeout(msg, timeout) msg, err := client.WaitTimeout(msg, timeout)
if err == ErrQueueTimeout { if err == ErrQueueTimeout {
panic(err) panic(err)
...@@ -135,7 +133,7 @@ func (client *client) Wait(msg Message) (Message, error) { ...@@ -135,7 +133,7 @@ func (client *client) Wait(msg Message) (Message, error) {
} }
// Recv 获取接受消息通道 // Recv 获取接受消息通道
func (client *client) Recv() chan Message { func (client *client) Recv() chan *Message {
return client.recv return client.recv
} }
...@@ -181,7 +179,7 @@ func (client *client) CloseQueue() (*types.Reply, error) { ...@@ -181,7 +179,7 @@ func (client *client) CloseQueue() (*types.Reply, error) {
return &types.Reply{IsOk: true}, nil return &types.Reply{IsOk: true}, nil
} }
func (client *client) isEnd(data Message, ok bool) bool { func (client *client) isEnd(data *Message, ok bool) bool {
if !ok { if !ok {
return true return true
} }
......
...@@ -16,5 +16,4 @@ func TestSetTopic(t *testing.T) { ...@@ -16,5 +16,4 @@ func TestSetTopic(t *testing.T) {
client.setTopic(hi) client.setTopic(hi)
ret := client.getTopic() ret := client.getTopic()
assert.Equal(t, hi, ret) assert.Equal(t, hi, ret)
} }
...@@ -41,29 +41,31 @@ func (_m *Client) CloseQueue() (*types.Reply, error) { ...@@ -41,29 +41,31 @@ func (_m *Client) CloseQueue() (*types.Reply, error) {
} }
// NewMessage provides a mock function with given fields: topic, ty, data // NewMessage provides a mock function with given fields: topic, ty, data
func (_m *Client) NewMessage(topic string, ty int64, data interface{}) queue.Message { func (_m *Client) NewMessage(topic string, ty int64, data interface{}) *queue.Message {
ret := _m.Called(topic, ty, data) ret := _m.Called(topic, ty, data)
var r0 queue.Message var r0 *queue.Message
if rf, ok := ret.Get(0).(func(string, int64, interface{}) queue.Message); ok { if rf, ok := ret.Get(0).(func(string, int64, interface{}) *queue.Message); ok {
r0 = rf(topic, ty, data) r0 = rf(topic, ty, data)
} else { } else {
r0 = ret.Get(0).(queue.Message) if ret.Get(0) != nil {
r0 = ret.Get(0).(*queue.Message)
}
} }
return r0 return r0
} }
// Recv provides a mock function with given fields: // Recv provides a mock function with given fields:
func (_m *Client) Recv() chan queue.Message { func (_m *Client) Recv() chan *queue.Message {
ret := _m.Called() ret := _m.Called()
var r0 chan queue.Message var r0 chan *queue.Message
if rf, ok := ret.Get(0).(func() chan queue.Message); ok { if rf, ok := ret.Get(0).(func() chan *queue.Message); ok {
r0 = rf() r0 = rf()
} else { } else {
if ret.Get(0) != nil { if ret.Get(0) != nil {
r0 = ret.Get(0).(chan queue.Message) r0 = ret.Get(0).(chan *queue.Message)
} }
} }
...@@ -71,11 +73,11 @@ func (_m *Client) Recv() chan queue.Message { ...@@ -71,11 +73,11 @@ func (_m *Client) Recv() chan queue.Message {
} }
// Send provides a mock function with given fields: msg, waitReply // Send provides a mock function with given fields: msg, waitReply
func (_m *Client) Send(msg queue.Message, waitReply bool) error { func (_m *Client) Send(msg *queue.Message, waitReply bool) error {
ret := _m.Called(msg, waitReply) ret := _m.Called(msg, waitReply)
var r0 error var r0 error
if rf, ok := ret.Get(0).(func(queue.Message, bool) error); ok { if rf, ok := ret.Get(0).(func(*queue.Message, bool) error); ok {
r0 = rf(msg, waitReply) r0 = rf(msg, waitReply)
} else { } else {
r0 = ret.Error(0) r0 = ret.Error(0)
...@@ -85,11 +87,11 @@ func (_m *Client) Send(msg queue.Message, waitReply bool) error { ...@@ -85,11 +87,11 @@ func (_m *Client) Send(msg queue.Message, waitReply bool) error {
} }
// SendTimeout provides a mock function with given fields: msg, waitReply, timeout // SendTimeout provides a mock function with given fields: msg, waitReply, timeout
func (_m *Client) SendTimeout(msg queue.Message, waitReply bool, timeout time.Duration) error { func (_m *Client) SendTimeout(msg *queue.Message, waitReply bool, timeout time.Duration) error {
ret := _m.Called(msg, waitReply, timeout) ret := _m.Called(msg, waitReply, timeout)
var r0 error var r0 error
if rf, ok := ret.Get(0).(func(queue.Message, bool, time.Duration) error); ok { if rf, ok := ret.Get(0).(func(*queue.Message, bool, time.Duration) error); ok {
r0 = rf(msg, waitReply, timeout) r0 = rf(msg, waitReply, timeout)
} else { } else {
r0 = ret.Error(0) r0 = ret.Error(0)
...@@ -104,18 +106,20 @@ func (_m *Client) Sub(topic string) { ...@@ -104,18 +106,20 @@ func (_m *Client) Sub(topic string) {
} }
// Wait provides a mock function with given fields: msg // Wait provides a mock function with given fields: msg
func (_m *Client) Wait(msg queue.Message) (queue.Message, error) { func (_m *Client) Wait(msg *queue.Message) (*queue.Message, error) {
ret := _m.Called(msg) ret := _m.Called(msg)
var r0 queue.Message var r0 *queue.Message
if rf, ok := ret.Get(0).(func(queue.Message) queue.Message); ok { if rf, ok := ret.Get(0).(func(*queue.Message) *queue.Message); ok {
r0 = rf(msg) r0 = rf(msg)
} else { } else {
r0 = ret.Get(0).(queue.Message) if ret.Get(0) != nil {
r0 = ret.Get(0).(*queue.Message)
}
} }
var r1 error var r1 error
if rf, ok := ret.Get(1).(func(queue.Message) error); ok { if rf, ok := ret.Get(1).(func(*queue.Message) error); ok {
r1 = rf(msg) r1 = rf(msg)
} else { } else {
r1 = ret.Error(1) r1 = ret.Error(1)
...@@ -125,18 +129,20 @@ func (_m *Client) Wait(msg queue.Message) (queue.Message, error) { ...@@ -125,18 +129,20 @@ func (_m *Client) Wait(msg queue.Message) (queue.Message, error) {
} }
// WaitTimeout provides a mock function with given fields: msg, timeout // WaitTimeout provides a mock function with given fields: msg, timeout
func (_m *Client) WaitTimeout(msg queue.Message, timeout time.Duration) (queue.Message, error) { func (_m *Client) WaitTimeout(msg *queue.Message, timeout time.Duration) (*queue.Message, error) {
ret := _m.Called(msg, timeout) ret := _m.Called(msg, timeout)
var r0 queue.Message var r0 *queue.Message
if rf, ok := ret.Get(0).(func(queue.Message, time.Duration) queue.Message); ok { if rf, ok := ret.Get(0).(func(*queue.Message, time.Duration) *queue.Message); ok {
r0 = rf(msg, timeout) r0 = rf(msg, timeout)
} else { } else {
r0 = ret.Get(0).(queue.Message) if ret.Get(0) != nil {
r0 = ret.Get(0).(*queue.Message)
}
} }
var r1 error var r1 error
if rf, ok := ret.Get(1).(func(queue.Message, time.Duration) error); ok { if rf, ok := ret.Get(1).(func(*queue.Message, time.Duration) error); ok {
r1 = rf(msg, timeout) r1 = rf(msg, timeout)
} else { } else {
r1 = ret.Error(1) r1 = ret.Error(1)
......
...@@ -46,8 +46,8 @@ func DisableLog() { ...@@ -46,8 +46,8 @@ func DisableLog() {
} }
type chanSub struct { type chanSub struct {
high chan Message high chan *Message
low chan Message low chan *Message
isClose int32 isClose int32
} }
...@@ -113,8 +113,8 @@ func (q *queue) Close() { ...@@ -113,8 +113,8 @@ func (q *queue) Close() {
q.mu.Lock() q.mu.Lock()
for topic, ch := range q.chanSubs { for topic, ch := range q.chanSubs {
if ch.isClose == 0 { if ch.isClose == 0 {
ch.high <- Message{} ch.high <- &Message{}
ch.low <- Message{} ch.low <- &Message{}
q.chanSubs[topic] = &chanSub{isClose: 1} q.chanSubs[topic] = &chanSub{isClose: 1}
} }
} }
...@@ -130,7 +130,7 @@ func (q *queue) chanSub(topic string) *chanSub { ...@@ -130,7 +130,7 @@ func (q *queue) chanSub(topic string) *chanSub {
defer q.mu.Unlock() defer q.mu.Unlock()
_, ok := q.chanSubs[topic] _, ok := q.chanSubs[topic]
if !ok { if !ok {
q.chanSubs[topic] = &chanSub{make(chan Message, defaultChanBuffer), make(chan Message, defaultLowChanBuffer), 0} q.chanSubs[topic] = &chanSub{make(chan *Message, defaultChanBuffer), make(chan *Message, defaultLowChanBuffer), 0}
} }
return q.chanSubs[topic] return q.chanSubs[topic]
} }
...@@ -143,13 +143,13 @@ func (q *queue) closeTopic(topic string) { ...@@ -143,13 +143,13 @@ func (q *queue) closeTopic(topic string) {
return return
} }
if sub.isClose == 0 { if sub.isClose == 0 {
sub.high <- Message{} sub.high <- &Message{}
sub.low <- Message{} sub.low <- &Message{}
} }
q.chanSubs[topic] = &chanSub{isClose: 1} q.chanSubs[topic] = &chanSub{isClose: 1}
} }
func (q *queue) send(msg Message, timeout time.Duration) (err error) { func (q *queue) send(msg *Message, timeout time.Duration) (err error) {
if q.isClosed() { if q.isClosed() {
return types.ErrChannelClosed return types.ErrChannelClosed
} }
...@@ -166,28 +166,28 @@ func (q *queue) send(msg Message, timeout time.Duration) (err error) { ...@@ -166,28 +166,28 @@ func (q *queue) send(msg Message, timeout time.Duration) (err error) {
if timeout == 0 { if timeout == 0 {
select { select {
case sub.high <- msg: case sub.high <- msg:
qlog.Debug("send ok", "msg", msg, "topic", msg.Topic, "sub", sub)
return nil return nil
default: default:
qlog.Debug("send chainfull", "msg", msg, "topic", msg.Topic, "sub", sub) qlog.Error("send chainfull", "msg", msg, "topic", msg.Topic, "sub", sub)
return ErrQueueChannelFull return ErrQueueChannelFull
} }
} }
if timeout == -1 {
sub.high <- msg
return nil
}
t := time.NewTimer(timeout) t := time.NewTimer(timeout)
defer t.Stop() defer t.Stop()
select { select {
case sub.high <- msg: case sub.high <- msg:
case <-t.C: case <-t.C:
qlog.Debug("send timeout", "msg", msg, "topic", msg.Topic, "sub", sub) qlog.Error("send timeout", "msg", msg, "topic", msg.Topic, "sub", sub)
return ErrQueueTimeout return ErrQueueTimeout
} }
if msg.Topic != "store" {
qlog.Debug("send ok", "msg", msg, "topic", msg.Topic, "sub", sub)
}
return nil return nil
} }
func (q *queue) sendAsyn(msg Message) error { func (q *queue) sendAsyn(msg *Message) error {
if q.isClosed() { if q.isClosed() {
return types.ErrChannelClosed return types.ErrChannelClosed
} }
...@@ -197,7 +197,6 @@ func (q *queue) sendAsyn(msg Message) error { ...@@ -197,7 +197,6 @@ func (q *queue) sendAsyn(msg Message) error {
} }
select { select {
case sub.low <- msg: case sub.low <- msg:
qlog.Debug("send asyn ok", "msg", msg)
return nil return nil
default: default:
qlog.Error("send asyn err", "msg", msg, "err", ErrQueueChannelFull) qlog.Error("send asyn err", "msg", msg, "err", ErrQueueChannelFull)
...@@ -205,7 +204,7 @@ func (q *queue) sendAsyn(msg Message) error { ...@@ -205,7 +204,7 @@ func (q *queue) sendAsyn(msg Message) error {
} }
} }
func (q *queue) sendLowTimeout(msg Message, timeout time.Duration) error { func (q *queue) sendLowTimeout(msg *Message, timeout time.Duration) error {
if q.isClosed() { if q.isClosed() {
return types.ErrChannelClosed return types.ErrChannelClosed
} }
...@@ -216,11 +215,14 @@ func (q *queue) sendLowTimeout(msg Message, timeout time.Duration) error { ...@@ -216,11 +215,14 @@ func (q *queue) sendLowTimeout(msg Message, timeout time.Duration) error {
if timeout == 0 { if timeout == 0 {
return q.sendAsyn(msg) return q.sendAsyn(msg)
} }
if timeout == -1 {
sub.low <- msg
return nil
}
t := time.NewTimer(timeout) t := time.NewTimer(timeout)
defer t.Stop() defer t.Stop()
select { select {
case sub.low <- msg: case sub.low <- msg:
qlog.Debug("send asyn ok", "msg", msg)
return nil return nil
case <-t.C: case <-t.C:
qlog.Error("send asyn timeout", "msg", msg) qlog.Error("send asyn timeout", "msg", msg)
...@@ -239,21 +241,22 @@ type Message struct { ...@@ -239,21 +241,22 @@ type Message struct {
Ty int64 Ty int64
ID int64 ID int64
Data interface{} Data interface{}
chReply chan Message chReply chan *Message
} }
// NewMessage new message // NewMessage new message
func NewMessage(id int64, topic string, ty int64, data interface{}) (msg Message) { func NewMessage(id int64, topic string, ty int64, data interface{}) (msg *Message) {
msg = &Message{}
msg.ID = id msg.ID = id
msg.Ty = ty msg.Ty = ty
msg.Data = data msg.Data = data
msg.Topic = topic msg.Topic = topic
msg.chReply = make(chan Message, 1) msg.chReply = make(chan *Message, 1)
return msg return msg
} }
// GetData get message data // GetData get message data
func (msg Message) GetData() interface{} { func (msg *Message) GetData() interface{} {
if _, ok := msg.Data.(error); ok { if _, ok := msg.Data.(error); ok {
return nil return nil
} }
...@@ -261,7 +264,7 @@ func (msg Message) GetData() interface{} { ...@@ -261,7 +264,7 @@ func (msg Message) GetData() interface{} {
} }
// Err if err return error msg, or return nil // Err if err return error msg, or return nil
func (msg Message) Err() error { func (msg *Message) Err() error {
if err, ok := msg.Data.(error); ok { if err, ok := msg.Data.(error); ok {
return err return err
} }
...@@ -269,7 +272,7 @@ func (msg Message) Err() error { ...@@ -269,7 +272,7 @@ func (msg Message) Err() error {
} }
// Reply reply message to reply chan // Reply reply message to reply chan
func (msg Message) Reply(replyMsg Message) { func (msg *Message) Reply(replyMsg *Message) {
if msg.chReply == nil { if msg.chReply == nil {
qlog.Debug("reply a empty chreply", "msg", msg) qlog.Debug("reply a empty chreply", "msg", msg)
return return
...@@ -281,13 +284,13 @@ func (msg Message) Reply(replyMsg Message) { ...@@ -281,13 +284,13 @@ func (msg Message) Reply(replyMsg Message) {
} }
// String print the message information // String print the message information
func (msg Message) String() string { func (msg *Message) String() string {
return fmt.Sprintf("{topic:%s, Ty:%s, Id:%d, Err:%v, Ch:%v}", msg.Topic, return fmt.Sprintf("{topic:%s, Ty:%s, Id:%d, Err:%v, Ch:%v}", msg.Topic,
types.GetEventName(int(msg.Ty)), msg.ID, msg.Err(), msg.chReply != nil) types.GetEventName(int(msg.Ty)), msg.ID, msg.Err(), msg.chReply != nil)
} }
// ReplyErr reply error // ReplyErr reply error
func (msg Message) ReplyErr(title string, err error) { func (msg *Message) ReplyErr(title string, err error) {
var reply types.Reply var reply types.Reply
if err != nil { if err != nil {
qlog.Error(title, "reply.err", err.Error()) qlog.Error(title, "reply.err", err.Error())
......
...@@ -210,3 +210,70 @@ func TestPrintMessage(t *testing.T) { ...@@ -210,3 +210,70 @@ func TestPrintMessage(t *testing.T) {
msg := client.NewMessage("mempool", types.EventReply, types.Reply{IsOk: true, Msg: []byte("word")}) msg := client.NewMessage("mempool", types.EventReply, types.Reply{IsOk: true, Msg: []byte("word")})
t.Log(msg) t.Log(msg)
} }
func BenchmarkSendMessage(b *testing.B) {
q := New("channel")
//mempool
go func() {
client := q.Client()
client.Sub("mempool")
defer client.Close()
for msg := range client.Recv() {
if msg.Ty == types.EventTx {
msg.Reply(client.NewMessage("mempool", types.EventReply, types.Reply{IsOk: true, Msg: []byte("word")}))
}
}
}()
go q.Start()
client := q.Client()
//high 优先级
for i := 0; i < b.N; i++ {
msg := client.NewMessage("mempool", types.EventTx, "hello")
err := client.Send(msg, true)
if err != nil {
b.Error(err)
return
}
_, err = client.Wait(msg)
if err != nil {
b.Error(err)
return
}
}
}
func BenchmarkStructChan(b *testing.B) {
ch := make(chan struct{})
go func() {
for {
<-ch
}
}()
for i := 0; i < b.N; i++ {
ch <- struct{}{}
}
}
func BenchmarkBoolChan(b *testing.B) {
ch := make(chan bool)
go func() {
for {
<-ch
}
}()
for i := 0; i < b.N; i++ {
ch <- true
}
}
func BenchmarkIntChan(b *testing.B) {
ch := make(chan int)
go func() {
for {
<-ch
}
}()
for i := 0; i < b.N; i++ {
ch <- 1
}
}
...@@ -37,7 +37,7 @@ type Miner interface { ...@@ -37,7 +37,7 @@ type Miner interface {
GetGenesisBlockTime() int64 GetGenesisBlockTime() int64
CreateBlock() CreateBlock()
CheckBlock(parent *types.Block, current *types.BlockDetail) error CheckBlock(parent *types.Block, current *types.BlockDetail) error
ProcEvent(msg queue.Message) bool ProcEvent(msg *queue.Message) bool
} }
//BaseClient ... //BaseClient ...
......
...@@ -83,7 +83,7 @@ func (client *Client) CreateGenesisTx() (ret []*types.Transaction) { ...@@ -83,7 +83,7 @@ func (client *Client) CreateGenesisTx() (ret []*types.Transaction) {
} }
//ProcEvent false //ProcEvent false
func (client *Client) ProcEvent(msg queue.Message) bool { func (client *Client) ProcEvent(msg *queue.Message) bool {
return false return false
} }
......
...@@ -20,8 +20,8 @@ var mlog = log.New("module", "mempool.base") ...@@ -20,8 +20,8 @@ var mlog = log.New("module", "mempool.base")
//Mempool mempool 基础类 //Mempool mempool 基础类
type Mempool struct { type Mempool struct {
proxyMtx sync.Mutex proxyMtx sync.Mutex
in chan queue.Message in chan *queue.Message
out <-chan queue.Message out <-chan *queue.Message
client queue.Client client queue.Client
header *types.Header header *types.Header
sync bool sync bool
...@@ -53,8 +53,8 @@ func NewMempool(cfg *types.Mempool) *Mempool { ...@@ -53,8 +53,8 @@ func NewMempool(cfg *types.Mempool) *Mempool {
if cfg.PoolCacheSize == 0 { if cfg.PoolCacheSize == 0 {
cfg.PoolCacheSize = poolCacheSize cfg.PoolCacheSize = poolCacheSize
} }
pool.in = make(chan queue.Message) pool.in = make(chan *queue.Message)
pool.out = make(<-chan queue.Message) pool.out = make(<-chan *queue.Message)
pool.done = make(chan struct{}) pool.done = make(chan struct{})
pool.cfg = cfg pool.cfg = cfg
pool.poolHeader = make(chan struct{}, 2) pool.poolHeader = make(chan struct{}, 2)
...@@ -235,7 +235,7 @@ func (mem *Mempool) pollLastHeader() { ...@@ -235,7 +235,7 @@ func (mem *Mempool) pollLastHeader() {
time.Sleep(time.Second) time.Sleep(time.Second)
continue continue
} }
h := lastHeader.(queue.Message).Data.(*types.Header) h := lastHeader.(*queue.Message).Data.(*types.Header)
mem.setHeader(h) mem.setHeader(h)
return return
} }
......
...@@ -11,7 +11,7 @@ import ( ...@@ -11,7 +11,7 @@ import (
) )
// CheckExpireValid 检查交易过期有效性,过期返回false,未过期返回true // CheckExpireValid 检查交易过期有效性,过期返回false,未过期返回true
func (mem *Mempool) CheckExpireValid(msg queue.Message) (bool, error) { func (mem *Mempool) CheckExpireValid(msg *queue.Message) (bool, error) {
mem.proxyMtx.Lock() mem.proxyMtx.Lock()
defer mem.proxyMtx.Unlock() defer mem.proxyMtx.Unlock()
if mem.header == nil { if mem.header == nil {
...@@ -54,7 +54,7 @@ func (mem *Mempool) checkExpireValid(tx *types.Transaction) bool { ...@@ -54,7 +54,7 @@ func (mem *Mempool) checkExpireValid(tx *types.Transaction) bool {
} }
// CheckTx 初步检查并筛选交易消息 // CheckTx 初步检查并筛选交易消息
func (mem *Mempool) checkTx(msg queue.Message) queue.Message { func (mem *Mempool) checkTx(msg *queue.Message) *queue.Message {
tx := msg.GetData().(types.TxGroup).Tx() tx := msg.GetData().(types.TxGroup).Tx()
// 检查接收地址是否合法 // 检查接收地址是否合法
if err := address.CheckAddress(tx.To); err != nil { if err := address.CheckAddress(tx.To); err != nil {
...@@ -77,7 +77,7 @@ func (mem *Mempool) checkTx(msg queue.Message) queue.Message { ...@@ -77,7 +77,7 @@ func (mem *Mempool) checkTx(msg queue.Message) queue.Message {
} }
// CheckTxs 初步检查并筛选交易消息 // CheckTxs 初步检查并筛选交易消息
func (mem *Mempool) checkTxs(msg queue.Message) queue.Message { func (mem *Mempool) checkTxs(msg *queue.Message) *queue.Message {
// 判断消息是否含有nil交易 // 判断消息是否含有nil交易
if msg.GetData() == nil { if msg.GetData() == nil {
msg.Data = types.ErrEmptyTx msg.Data = types.ErrEmptyTx
...@@ -105,7 +105,7 @@ func (mem *Mempool) checkTxs(msg queue.Message) queue.Message { ...@@ -105,7 +105,7 @@ func (mem *Mempool) checkTxs(msg queue.Message) queue.Message {
} }
//txgroup 的交易 //txgroup 的交易
for i := 0; i < len(txs.Txs); i++ { for i := 0; i < len(txs.Txs); i++ {
msgitem := mem.checkTx(queue.Message{Data: txs.Txs[i]}) msgitem := mem.checkTx(&queue.Message{Data: txs.Txs[i]})
if msgitem.Err() != nil { if msgitem.Err() != nil {
msg.Data = msgitem.Err() msg.Data = msgitem.Err()
return msg return msg
...@@ -115,7 +115,7 @@ func (mem *Mempool) checkTxs(msg queue.Message) queue.Message { ...@@ -115,7 +115,7 @@ func (mem *Mempool) checkTxs(msg queue.Message) queue.Message {
} }
//checkTxList 检查账户余额是否足够,并加入到Mempool,成功则传入goodChan,若加入Mempool失败则传入badChan //checkTxList 检查账户余额是否足够,并加入到Mempool,成功则传入goodChan,若加入Mempool失败则传入badChan
func (mem *Mempool) checkTxRemote(msg queue.Message) queue.Message { func (mem *Mempool) checkTxRemote(msg *queue.Message) *queue.Message {
tx := msg.GetData().(types.TxGroup) tx := msg.GetData().(types.TxGroup)
txlist := &types.ExecTxList{} txlist := &types.ExecTxList{}
txlist.Txs = append(txlist.Txs, tx.Tx()) txlist.Txs = append(txlist.Txs, tx.Tx())
......
...@@ -19,28 +19,28 @@ func (mem *Mempool) reply() { ...@@ -19,28 +19,28 @@ func (mem *Mempool) reply() {
} }
} }
func (mem *Mempool) pipeLine() <-chan queue.Message { func (mem *Mempool) pipeLine() <-chan *queue.Message {
//check sign //check sign
step1 := func(data queue.Message) queue.Message { step1 := func(data *queue.Message) *queue.Message {
if data.Err() != nil { if data.Err() != nil {
return data return data
} }
return mem.checkSign(data) return mem.checkSign(data)
} }
chs := make([]<-chan queue.Message, processNum) chs := make([]<-chan *queue.Message, processNum)
for i := 0; i < processNum; i++ { for i := 0; i < processNum; i++ {
chs[i] = step(mem.done, mem.in, step1) chs[i] = step(mem.done, mem.in, step1)
} }
out1 := merge(mem.done, chs) out1 := merge(mem.done, chs)
//checktx remote //checktx remote
step2 := func(data queue.Message) queue.Message { step2 := func(data *queue.Message) *queue.Message {
if data.Err() != nil { if data.Err() != nil {
return data return data
} }
return mem.checkTxRemote(data) return mem.checkTxRemote(data)
} }
chs2 := make([]<-chan queue.Message, processNum) chs2 := make([]<-chan *queue.Message, processNum)
for i := 0; i < processNum; i++ { for i := 0; i < processNum; i++ {
chs2[i] = step(mem.done, out1, step2) chs2[i] = step(mem.done, out1, step2)
} }
...@@ -94,7 +94,7 @@ func (mem *Mempool) eventProcess() { ...@@ -94,7 +94,7 @@ func (mem *Mempool) eventProcess() {
} }
//EventTx 初步筛选后存入mempool //EventTx 初步筛选后存入mempool
func (mem *Mempool) eventTx(msg queue.Message) { func (mem *Mempool) eventTx(msg *queue.Message) {
if !mem.getSync() { if !mem.getSync() {
msg.Reply(mem.client.NewMessage("", types.EventReply, &types.Reply{Msg: []byte(types.ErrNotSync.Error())})) msg.Reply(mem.client.NewMessage("", types.EventReply, &types.Reply{Msg: []byte(types.ErrNotSync.Error())}))
mlog.Debug("wrong tx", "err", types.ErrNotSync.Error()) mlog.Debug("wrong tx", "err", types.ErrNotSync.Error())
...@@ -108,13 +108,13 @@ func (mem *Mempool) eventTx(msg queue.Message) { ...@@ -108,13 +108,13 @@ func (mem *Mempool) eventTx(msg queue.Message) {
} }
// EventGetMempool 获取Mempool内所有交易 // EventGetMempool 获取Mempool内所有交易
func (mem *Mempool) eventGetMempool(msg queue.Message) { func (mem *Mempool) eventGetMempool(msg *queue.Message) {
msg.Reply(mem.client.NewMessage("rpc", types.EventReplyTxList, msg.Reply(mem.client.NewMessage("rpc", types.EventReplyTxList,
&types.ReplyTxList{Txs: mem.filterTxList(0, nil)})) &types.ReplyTxList{Txs: mem.filterTxList(0, nil)}))
} }
// EventDelTxList 获取Mempool中一定数量交易,并把这些交易从Mempool中删除 // EventDelTxList 获取Mempool中一定数量交易,并把这些交易从Mempool中删除
func (mem *Mempool) eventDelTxList(msg queue.Message) { func (mem *Mempool) eventDelTxList(msg *queue.Message) {
hashList := msg.GetData().(*types.TxHashList) hashList := msg.GetData().(*types.TxHashList)
if len(hashList.GetHashes()) == 0 { if len(hashList.GetHashes()) == 0 {
msg.ReplyErr("EventDelTxList", types.ErrSize) msg.ReplyErr("EventDelTxList", types.ErrSize)
...@@ -125,7 +125,7 @@ func (mem *Mempool) eventDelTxList(msg queue.Message) { ...@@ -125,7 +125,7 @@ func (mem *Mempool) eventDelTxList(msg queue.Message) {
} }
// EventTxList 获取mempool中一定数量交易 // EventTxList 获取mempool中一定数量交易
func (mem *Mempool) eventTxList(msg queue.Message) { func (mem *Mempool) eventTxList(msg *queue.Message) {
hashList := msg.GetData().(*types.TxHashList) hashList := msg.GetData().(*types.TxHashList)
if hashList.Count <= 0 { if hashList.Count <= 0 {
msg.Reply(mem.client.NewMessage("", types.EventReplyTxList, types.ErrSize)) msg.Reply(mem.client.NewMessage("", types.EventReplyTxList, types.ErrSize))
...@@ -137,7 +137,7 @@ func (mem *Mempool) eventTxList(msg queue.Message) { ...@@ -137,7 +137,7 @@ func (mem *Mempool) eventTxList(msg queue.Message) {
} }
// EventAddBlock 将添加到区块内的交易从mempool中删除 // EventAddBlock 将添加到区块内的交易从mempool中删除
func (mem *Mempool) eventAddBlock(msg queue.Message) { func (mem *Mempool) eventAddBlock(msg *queue.Message) {
block := msg.GetData().(*types.BlockDetail).Block block := msg.GetData().(*types.BlockDetail).Block
if block.Height > mem.Height() || (block.Height == 0 && mem.Height() == 0) { if block.Height > mem.Height() || (block.Height == 0 && mem.Height() == 0) {
header := &types.Header{} header := &types.Header{}
...@@ -150,21 +150,21 @@ func (mem *Mempool) eventAddBlock(msg queue.Message) { ...@@ -150,21 +150,21 @@ func (mem *Mempool) eventAddBlock(msg queue.Message) {
} }
// EventGetMempoolSize 获取mempool大小 // EventGetMempoolSize 获取mempool大小
func (mem *Mempool) eventGetMempoolSize(msg queue.Message) { func (mem *Mempool) eventGetMempoolSize(msg *queue.Message) {
memSize := int64(mem.Size()) memSize := int64(mem.Size())
msg.Reply(mem.client.NewMessage("rpc", types.EventMempoolSize, msg.Reply(mem.client.NewMessage("rpc", types.EventMempoolSize,
&types.MempoolSize{Size: memSize})) &types.MempoolSize{Size: memSize}))
} }
// EventGetLastMempool 获取最新十条加入到mempool的交易 // EventGetLastMempool 获取最新十条加入到mempool的交易
func (mem *Mempool) eventGetLastMempool(msg queue.Message) { func (mem *Mempool) eventGetLastMempool(msg *queue.Message) {
txList := mem.GetLatestTx() txList := mem.GetLatestTx()
msg.Reply(mem.client.NewMessage("rpc", types.EventReplyTxList, msg.Reply(mem.client.NewMessage("rpc", types.EventReplyTxList,
&types.ReplyTxList{Txs: txList})) &types.ReplyTxList{Txs: txList}))
} }
// EventDelBlock 回滚区块,把该区块内交易重新加回mempool // EventDelBlock 回滚区块,把该区块内交易重新加回mempool
func (mem *Mempool) eventDelBlock(msg queue.Message) { func (mem *Mempool) eventDelBlock(msg *queue.Message) {
block := msg.GetData().(*types.BlockDetail).Block block := msg.GetData().(*types.BlockDetail).Block
if block.Height != mem.GetHeader().GetHeight() { if block.Height != mem.GetHeader().GetHeight() {
return return
...@@ -174,19 +174,19 @@ func (mem *Mempool) eventDelBlock(msg queue.Message) { ...@@ -174,19 +174,19 @@ func (mem *Mempool) eventDelBlock(msg queue.Message) {
mlog.Error(err.Error()) mlog.Error(err.Error())
return return
} }
h := lastHeader.(queue.Message).Data.(*types.Header) h := lastHeader.(*queue.Message).Data.(*types.Header)
mem.setHeader(h) mem.setHeader(h)
mem.delBlock(block) mem.delBlock(block)
} }
// eventGetAddrTxs 获取mempool中对应账户(组)所有交易 // eventGetAddrTxs 获取mempool中对应账户(组)所有交易
func (mem *Mempool) eventGetAddrTxs(msg queue.Message) { func (mem *Mempool) eventGetAddrTxs(msg *queue.Message) {
addrs := msg.GetData().(*types.ReqAddrs) addrs := msg.GetData().(*types.ReqAddrs)
txlist := mem.GetAccTxs(addrs) txlist := mem.GetAccTxs(addrs)
msg.Reply(mem.client.NewMessage("", types.EventReplyAddrTxs, txlist)) msg.Reply(mem.client.NewMessage("", types.EventReplyAddrTxs, txlist))
} }
func (mem *Mempool) checkSign(data queue.Message) queue.Message { func (mem *Mempool) checkSign(data *queue.Message) *queue.Message {
tx, ok := data.GetData().(types.TxGroup) tx, ok := data.GetData().(types.TxGroup)
if ok && tx.CheckSign() { if ok && tx.CheckSign() {
return data return data
......
...@@ -12,8 +12,8 @@ import ( ...@@ -12,8 +12,8 @@ import (
//pipeline 适用于 一个问题,分成很多步完成,每步的输出作为下一步的输入 //pipeline 适用于 一个问题,分成很多步完成,每步的输出作为下一步的输入
func step(done <-chan struct{}, in <-chan queue.Message, cb func(queue.Message) queue.Message) <-chan queue.Message { func step(done <-chan struct{}, in <-chan *queue.Message, cb func(*queue.Message) *queue.Message) <-chan *queue.Message {
out := make(chan queue.Message) out := make(chan *queue.Message)
go func() { go func() {
defer close(out) defer close(out)
for n := range in { for n := range in {
...@@ -27,10 +27,10 @@ func step(done <-chan struct{}, in <-chan queue.Message, cb func(queue.Message) ...@@ -27,10 +27,10 @@ func step(done <-chan struct{}, in <-chan queue.Message, cb func(queue.Message)
return out return out
} }
func merge(done <-chan struct{}, cs []<-chan queue.Message) <-chan queue.Message { func merge(done <-chan struct{}, cs []<-chan *queue.Message) <-chan *queue.Message {
var wg sync.WaitGroup var wg sync.WaitGroup
out := make(chan queue.Message) out := make(chan *queue.Message)
output := func(c <-chan queue.Message) { output := func(c <-chan *queue.Message) {
defer wg.Done() defer wg.Done()
for n := range c { for n := range c {
select { select {
......
...@@ -15,9 +15,9 @@ import ( ...@@ -15,9 +15,9 @@ import (
func TestStep(t *testing.T) { func TestStep(t *testing.T) {
done := make(chan struct{}) done := make(chan struct{})
in := make(chan queue.Message) in := make(chan *queue.Message)
msg := queue.Message{ID: 0} msg := &queue.Message{ID: 0}
cb := func(in queue.Message) queue.Message { cb := func(in *queue.Message) *queue.Message {
in.ID++ in.ID++
time.Sleep(time.Microsecond) time.Sleep(time.Microsecond)
return in return in
...@@ -31,15 +31,15 @@ func TestStep(t *testing.T) { ...@@ -31,15 +31,15 @@ func TestStep(t *testing.T) {
func TestMutiStep(t *testing.T) { func TestMutiStep(t *testing.T) {
done := make(chan struct{}) done := make(chan struct{})
in := make(chan queue.Message) in := make(chan *queue.Message)
msg := queue.Message{ID: 0} msg := &queue.Message{ID: 0}
step1 := func(in queue.Message) queue.Message { step1 := func(in *queue.Message) *queue.Message {
in.ID++ in.ID++
time.Sleep(time.Microsecond) time.Sleep(time.Microsecond)
return in return in
} }
out1 := step(done, in, step1) out1 := step(done, in, step1)
step2 := func(in queue.Message) queue.Message { step2 := func(in *queue.Message) *queue.Message {
in.ID++ in.ID++
time.Sleep(time.Microsecond) time.Sleep(time.Microsecond)
return in return in
...@@ -56,9 +56,9 @@ func TestMutiStep(t *testing.T) { ...@@ -56,9 +56,9 @@ func TestMutiStep(t *testing.T) {
func BenchmarkStep(b *testing.B) { func BenchmarkStep(b *testing.B) {
done := make(chan struct{}) done := make(chan struct{})
in := make(chan queue.Message) in := make(chan *queue.Message)
msg := queue.Message{ID: 0} msg := &queue.Message{ID: 0}
cb := func(in queue.Message) queue.Message { cb := func(in *queue.Message) *queue.Message {
in.ID++ in.ID++
time.Sleep(100 * time.Microsecond) time.Sleep(100 * time.Microsecond)
return in return in
...@@ -78,14 +78,14 @@ func BenchmarkStep(b *testing.B) { ...@@ -78,14 +78,14 @@ func BenchmarkStep(b *testing.B) {
func BenchmarkStepMerge(b *testing.B) { func BenchmarkStepMerge(b *testing.B) {
done := make(chan struct{}) done := make(chan struct{})
in := make(chan queue.Message) in := make(chan *queue.Message)
msg := queue.Message{ID: 0} msg := &queue.Message{ID: 0}
cb := func(in queue.Message) queue.Message { cb := func(in *queue.Message) *queue.Message {
in.ID++ in.ID++
time.Sleep(100 * time.Microsecond) time.Sleep(100 * time.Microsecond)
return in return in
} }
chs := make([]<-chan queue.Message, runtime.NumCPU()) chs := make([]<-chan *queue.Message, runtime.NumCPU())
for i := 0; i < runtime.NumCPU(); i++ { for i := 0; i < runtime.NumCPU(); i++ {
chs[i] = step(done, in, cb) chs[i] = step(done, in, cb)
} }
...@@ -102,6 +102,6 @@ func BenchmarkStepMerge(b *testing.B) { ...@@ -102,6 +102,6 @@ func BenchmarkStepMerge(b *testing.B) {
close(done) close(done)
} }
func mergeList(done <-chan struct{}, cs ...<-chan queue.Message) <-chan queue.Message { func mergeList(done <-chan struct{}, cs ...<-chan *queue.Message) <-chan *queue.Message {
return merge(done, cs) return merge(done, cs)
} }
...@@ -48,7 +48,7 @@ type SubStore interface { ...@@ -48,7 +48,7 @@ type SubStore interface {
Rollback(req *types.ReqHash) ([]byte, error) Rollback(req *types.ReqHash) ([]byte, error)
Del(req *types.StoreDel) ([]byte, error) Del(req *types.StoreDel) ([]byte, error)
IterateRangeByStateHash(statehash []byte, start []byte, end []byte, ascending bool, fn func(key, value []byte) bool) IterateRangeByStateHash(statehash []byte, start []byte, end []byte, ascending bool, fn func(key, value []byte) bool)
ProcEvent(msg queue.Message) ProcEvent(msg *queue.Message)
} }
// BaseStore 基础的store结构体 // BaseStore 基础的store结构体
...@@ -87,7 +87,7 @@ func (store *BaseStore) SetQueueClient(c queue.Client) { ...@@ -87,7 +87,7 @@ func (store *BaseStore) SetQueueClient(c queue.Client) {
//Wait wait for basestore ready //Wait wait for basestore ready
func (store *BaseStore) Wait() {} func (store *BaseStore) Wait() {}
func (store *BaseStore) processMessage(msg queue.Message) { func (store *BaseStore) processMessage(msg *queue.Message) {
client := store.qclient client := store.qclient
if msg.Ty == types.EventStoreSet { if msg.Ty == types.EventStoreSet {
go func() { go func() {
......
...@@ -49,7 +49,7 @@ func (s *storeChild) IterateRangeByStateHash(statehash []byte, start []byte, end ...@@ -49,7 +49,7 @@ func (s *storeChild) IterateRangeByStateHash(statehash []byte, start []byte, end
} }
func (s *storeChild) ProcEvent(msg queue.Message) {} func (s *storeChild) ProcEvent(msg *queue.Message) {}
func init() { func init() {
log.SetLogLevel("error") log.SetLogLevel("error")
......
...@@ -88,7 +88,7 @@ func (mavls *Store) Get(datas *types.StoreGet) [][]byte { ...@@ -88,7 +88,7 @@ func (mavls *Store) Get(datas *types.StoreGet) [][]byte {
var err error var err error
values := make([][]byte, len(datas.Keys)) values := make([][]byte, len(datas.Keys))
search := string(datas.StateHash) search := string(datas.StateHash)
if data, ok := mavls.trees.Load(search); ok { if data, ok := mavls.trees.Load(search); ok && data != nil {
tree = data.(*mavl.Tree) tree = data.(*mavl.Tree)
} else { } else {
tree = mavl.NewTree(mavls.GetDB(), true) tree = mavl.NewTree(mavls.GetDB(), true)
...@@ -179,7 +179,7 @@ func (mavls *Store) IterateRangeByStateHash(statehash []byte, start []byte, end ...@@ -179,7 +179,7 @@ func (mavls *Store) IterateRangeByStateHash(statehash []byte, start []byte, end
} }
// ProcEvent not support message // ProcEvent not support message
func (mavls *Store) ProcEvent(msg queue.Message) { func (mavls *Store) ProcEvent(msg *queue.Message) {
msg.ReplyErr("Store", types.ErrActionNotSupport) msg.ReplyErr("Store", types.ErrActionNotSupport)
} }
......
...@@ -16,7 +16,7 @@ func (wallet *Wallet) ProcRecvMsg() { ...@@ -16,7 +16,7 @@ func (wallet *Wallet) ProcRecvMsg() {
for msg := range wallet.client.Recv() { for msg := range wallet.client.Recv() {
walletlog.Debug("wallet recv", "msg", types.GetEventName(int(msg.Ty)), "Id", msg.ID) walletlog.Debug("wallet recv", "msg", types.GetEventName(int(msg.Ty)), "Id", msg.ID)
beg := types.Now() beg := types.Now()
reply, err := wallet.ExecWallet(&msg) reply, err := wallet.ExecWallet(msg)
if err != nil { if err != nil {
//only for test ,del when test end //only for test ,del when test end
msg.Reply(wallet.api.NewMessage("", 0, err)) msg.Reply(wallet.api.NewMessage("", 0, err))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment