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

commit msg get local consens height

parent c6fa4e0b
......@@ -162,7 +162,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
quitCreate: make(chan struct{}),
}
waitBlocks := int32(2) //最小是2
waitBlocks := int32(3) //最小是2
if subcfg.WaitBlocks4CommitMsg > 0 {
if subcfg.WaitBlocks4CommitMsg < waitBlocks {
panic("config WaitBlocks4CommitMsg should not less 2")
......@@ -181,7 +181,7 @@ func New(cfg *types.Consensus, sub []byte) queue.Module {
waitConsensStopTimes: waitConsensTimes,
commitCh: make(chan int64, 1),
resetCh: make(chan int64, 1),
verifyCh: make(chan []byte, 1),
verifyCh: make(chan bool, 1),
consensHeight: -2,
sendingHeight: -1,
quit: make(chan struct{}),
......
This diff is collapsed.
......@@ -59,11 +59,8 @@ func (client *client) checkCommitTxSuccess(txs []*pt.TxDetail) {
}
}
if txMap[string(curTx.Hash())] {
client.commitMsgClient.verifyNotify(curTx.Hash())
} else {
client.commitMsgClient.verifyNotify(nil)
}
client.commitMsgClient.verifyNotify(txMap[string(curTx.Hash())])
}
func (client *client) createLocalBlock(lastBlock *pt.ParaLocalDbBlock, txs []*types.Transaction, mainBlock *pt.ParaTxDetail) error {
......
......@@ -69,32 +69,32 @@ func TestCalcCommitMsgTxs(t *testing.T) {
}
func TestGetConsensusStatus(t *testing.T) {
para := new(client)
grpcClient := &typesmocks.Chain33Client{}
//grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
para.grpcClient = grpcClient
commitCli := new(commitMsgClient)
commitCli.paraClient = para
block := &types.Block{
Height: 1,
MainHeight: 10,
}
status := &pt.ParacrossStatus{
Height: 1,
}
reply := &types.Reply{
IsOk: true,
Msg: types.Encode(status),
}
grpcClient.On("QueryChain", mock.Anything, mock.Anything).Return(reply, nil).Once()
ret, err := commitCli.getConsensusStatus(block)
assert.Nil(t, err)
assert.Equal(t, int64(1), ret.Height)
}
//func TestGetConsensusStatus(t *testing.T) {
// para := new(client)
// grpcClient := &typesmocks.Chain33Client{}
// //grpcClient.On("GetFork", mock.Anything, &types.ReqKey{Key: []byte("ForkBlockHash")}).Return(&types.Int64{Data: 1}, errors.New("err")).Once()
// para.grpcClient = grpcClient
// commitCli := new(commitMsgClient)
// commitCli.paraClient = para
//
// block := &types.Block{
// Height: 1,
// MainHeight: 10,
// }
//
// status := &pt.ParacrossStatus{
// Height: 1,
// }
// reply := &types.Reply{
// IsOk: true,
// Msg: types.Encode(status),
// }
// grpcClient.On("QueryChain", mock.Anything, mock.Anything).Return(reply, nil).Once()
// ret, err := commitCli.getSelfConsensusStatus()
//
// assert.Nil(t, err)
// assert.Equal(t, int64(1), ret.Height)
//}
func TestSendCommitMsg(t *testing.T) {
para := new(client)
......
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