Commit 7b6cf303 authored by lilinleeli1234's avatar lilinleeli1234 Committed by vipwzw

add unsupported msg reply

parent 046c247e
...@@ -17,14 +17,14 @@ var RETRY_TIMES = 3 ...@@ -17,14 +17,14 @@ var RETRY_TIMES = 3
//Mempool mempool 基础类 //Mempool mempool 基础类
type Mempool struct { type Mempool struct {
Key string key string
mainGrpcCli types.Chain33Client mainGrpcCli types.Chain33Client
} }
//NewMempool 新建mempool 实例 //NewMempool 新建mempool 实例
func NewMempool(cfg *types.Mempool) *Mempool { func NewMempool(cfg *types.Mempool) *Mempool {
pool := &Mempool{} pool := &Mempool{}
pool.Key = topic pool.key = topic
if types.IsPara() { if types.IsPara() {
grpcCli, err := grpcclient.NewMainChainClient("") grpcCli, err := grpcclient.NewMainChainClient("")
if err != nil { if err != nil {
...@@ -39,7 +39,7 @@ func NewMempool(cfg *types.Mempool) *Mempool { ...@@ -39,7 +39,7 @@ func NewMempool(cfg *types.Mempool) *Mempool {
//SetQueueClient 初始化mempool模块 //SetQueueClient 初始化mempool模块
func (mem *Mempool) SetQueueClient(client queue.Client) { func (mem *Mempool) SetQueueClient(client queue.Client) {
go func() { go func() {
client.Sub(mem.Key) client.Sub(mem.key)
for msg := range client.Recv() { for msg := range client.Recv() {
switch msg.Ty { switch msg.Ty {
case types.EventTx: case types.EventTx:
...@@ -59,14 +59,16 @@ func (mem *Mempool) SetQueueClient(client queue.Client) { ...@@ -59,14 +59,16 @@ func (mem *Mempool) SetQueueClient(client queue.Client) {
} }
} }
if err != nil { if err != nil {
msg.Reply(client.NewMessage(topic, types.EventReply, &types.Reply{IsOk: false, msg.Reply(client.NewMessage(mem.key, types.EventReply, &types.Reply{IsOk: false,
Msg: []byte(fmt.Sprintf("Send transaction to main chain failed, %v", err))})) Msg: []byte(fmt.Sprintf("Send transaction to main chain failed, %v", err))}))
break break
} }
} }
msg.Reply(client.NewMessage(topic, types.EventReply, &types.Reply{IsOk: true, Msg: []byte(reply.GetMsg())})) msg.Reply(client.NewMessage(mem.key, types.EventReply, &types.Reply{IsOk: true, Msg: []byte(reply.GetMsg())}))
} }
default: default:
msg.Reply(client.NewMessage(mem.key, types.EventReply, &types.Reply{IsOk: false,
Msg: []byte(fmt.Sprintf("para %v doesn't handle message %v", mem.key, msg.Ty))}))
} }
} }
}() }()
......
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