Commit f1a335fe authored by mdj33's avatar mdj33 Committed by vipwzw

error modify

parent a2923c19
......@@ -177,6 +177,12 @@ func (client *client) SetQueueClient(c queue.Client) {
}
func (client *client) InitBlock() {
var err error
mainBlockHashForkHeight, err = client.GetBlockHashForkHeightOnMainChain()
if err != nil {
panic(err)
}
block, err := client.RequestLastBlock()
if err != nil {
panic(err)
......@@ -205,13 +211,6 @@ func (client *client) GetStartSeq(height int64) int64 {
return 0
}
ret, err := client.grpcClient.GetFork(context.Background(), &types.ReqKey{Key: []byte("ForkBlockHash")})
if err != nil {
plog.Error("para get rpc ForkBlockHash fail", "err", err.Error())
panic(err)
}
mainBlockHashForkHeight = ret.Data
lastHeight, err := client.GetLastHeightOnMainChain()
if err != nil {
panic(err)
......@@ -377,6 +376,16 @@ func (client *client) getLastBlockInfo() (int64, *types.Block, []byte, int64, er
}
func (client *client) GetBlockHashForkHeightOnMainChain() (int64, error) {
ret, err := client.grpcClient.GetFork(context.Background(), &types.ReqKey{Key: []byte("ForkBlockHash")})
if err != nil {
plog.Error("para get rpc ForkBlockHash fail", "err", err.Error())
return -1, err
}
return ret.Data, nil
}
func (client *client) GetLastHeightOnMainChain() (int64, error) {
header, err := client.grpcClient.GetLastHeader(context.Background(), &types.ReqNil{})
if err != nil {
......
......@@ -75,7 +75,7 @@ func (s *suiteParaCommitMsg) initEnv(cfg *types.Config, sub *types.ConfigSubModu
s.para = New(cfg.Consensus, sub.Consensus["para"]).(*client)
s.grpcCli = &typesmocks.Chain33Client{}
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil)
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
// GetBlockBySeq return error to stop create's for cycle to request tx
s.grpcCli.On("GetBlockBySeq", mock.Anything, mock.Anything).Return(nil, errors.New("quit create"))
//data := &types.Int64{1}
......
......@@ -66,7 +66,7 @@ func (s *suiteParaClient) initEnv(cfg *types.Config, sub *types.ConfigSubModule)
s.para = New(cfg.Consensus, sub.Consensus["para"]).(*client)
s.grpcCli = &typesmocks.Chain33Client{}
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil)
s.grpcCli.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, nil).Once()
s.createBlockMock()
reply := &types.Reply{IsOk: true}
......
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