pull/1616/head
Rongjian Lan 5 years ago
parent 266a4e42d8
commit 9fb879f565
  1. 5
      consensus/consensus_v2.go
  2. 1
      node/node_handler.go

@ -107,6 +107,7 @@ func (consensus *Consensus) announce(block *types.Block) {
// save announce message to PbftLog
msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend)
// TODO(chao): don't unmarshall the message here and direclty pass the original object.
msg := &msg_pb.Message{}
_ = protobuf.Unmarshal(msgPayload, msg)
pbftMsg, err := ParsePbftMessage(msg)
@ -115,6 +116,7 @@ func (consensus *Consensus) announce(block *types.Block) {
return
}
// TODO(chao): review pbft log data structure
consensus.PbftLog.AddMessage(pbftMsg)
utils.Logger().Debug().
Str("MsgBlockHash", pbftMsg.BlockHash.Hex()).
@ -183,6 +185,7 @@ func (consensus *Consensus) onAnnounce(msg *msg_pb.Message) {
}
// verify validity of block header object
// TODO: think about just sending the block hash instead of the header.
encodedHeader := recvMsg.Payload
header := new(block.Header)
err = rlp.DecodeBytes(encodedHeader, header)
@ -384,6 +387,7 @@ func (consensus *Consensus) onPrepare(msg *msg_pb.Message) {
consensus.aggregatedPrepareSig = aggSig
//leader adds prepared message to log
// TODO(chao): don't unmarshall the payload again
msgPayload, _ := proto.GetConsensusMessagePayload(msgToSend)
msg := &msg_pb.Message{}
_ = protobuf.Unmarshal(msgPayload, msg)
@ -678,6 +682,7 @@ func (consensus *Consensus) onCommit(msg *msg_pb.Message) {
return
}
// has to be called before verifying signature
quorumWasMet := len(commitSigs) >= consensus.Quorum()
// Verify the signature on commitPayload is correct

@ -366,6 +366,7 @@ func (node *Node) PostConsensusProcessing(newBlock *types.Block, commitSigAndBit
// Update last consensus time for metrics
// TODO: randomly selected a few validators to broadcast messages instead of only leader broadcast
// TODO: refactor the asynchronous calls to separate go routine.
node.lastConsensusTime = time.Now().Unix()
if node.Consensus.PubKey.IsEqual(node.Consensus.LeaderPubKey) {
if node.NodeConfig.ShardID == 0 {

Loading…
Cancel
Save