Commit ae154542 authored by lilinleeli1234's avatar lilinleeli1234 Committed by vipwzw

update retry

parent 83035811
...@@ -3,16 +3,16 @@ package para ...@@ -3,16 +3,16 @@ package para
import ( import (
"bytes" "bytes"
"context" "context"
"fmt"
log "github.com/33cn/chain33/common/log/log15" log "github.com/33cn/chain33/common/log/log15"
"github.com/33cn/chain33/queue" "github.com/33cn/chain33/queue"
"github.com/33cn/chain33/rpc/grpcclient" "github.com/33cn/chain33/rpc/grpcclient"
"github.com/33cn/chain33/types" "github.com/33cn/chain33/types"
"fmt"
) )
var mlog = log.New("module", "mempool.para") var mlog = log.New("module", "mempool.para")
var topic = "mempool" var topic = "mempool"
var RETRY_TIMES = 3
//Mempool mempool 基础类 //Mempool mempool 基础类
type Mempool struct { type Mempool struct {
...@@ -49,21 +49,21 @@ func (mem *Mempool) SetQueueClient(client queue.Client) { ...@@ -49,21 +49,21 @@ func (mem *Mempool) SetQueueClient(client queue.Client) {
reply, err := mem.mainGrpcCli.SendTransaction(context.Background(), tx) reply, err := mem.mainGrpcCli.SendTransaction(context.Background(), tx)
if err != nil { if err != nil {
//进行重试 //进行重试
for i := 0; i < 3; i++ { for i := 0; i < RETRY_TIMES; i++ {
reply, err = mem.mainGrpcCli.SendTransaction(context.Background(), tx) reply, err = mem.mainGrpcCli.SendTransaction(context.Background(), tx)
if err != nil { if err != nil {
continue continue
} else {
break
} }
} }
} if err != nil {
if err == nil {
msg.Reply(client.NewMessage(topic, types.EventReply, &types.Reply{IsOk: true,
Msg: []byte(reply.GetMsg())}))
} else {
msg.Reply(client.NewMessage(topic, types.EventReply, &types.Reply{IsOk: false, msg.Reply(client.NewMessage(topic, 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
}
} }
msg.Reply(client.NewMessage(topic, types.EventReply, &types.Reply{IsOk: true, Msg: []byte(reply.GetMsg())}))
} }
default: default:
} }
......
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