avoid unnecessary header sig checking

pull/3579/head
Rongjian Lan 4 years ago
parent def04c8ef3
commit a6f356b386
  1. 5
      consensus/consensus_v2.go
  2. 1
      consensus/leader.go
  3. 2
      node/node_explorer.go

@ -588,7 +588,7 @@ func (consensus *Consensus) preCommitAndPropose(blk *types.Block) error {
go func() {
blk.SetCurrentCommitSig(bareMinimumCommit)
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, true); err != nil {
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, !consensus.FBFTLog.IsBlockVerified(blk)); err != nil {
consensus.getLogger().Error().Err(err).Msg("[preCommitAndPropose] Failed to add block to chain")
return
}
@ -690,7 +690,8 @@ func (consensus *Consensus) tryCatchup() error {
func (consensus *Consensus) commitBlock(blk *types.Block, committedMsg *FBFTMessage) error {
if consensus.Blockchain.CurrentBlock().NumberU64() < blk.NumberU64() {
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, true); err != nil {
consensus.FBFTLog.IsBlockVerified(blk)
if _, err := consensus.Blockchain.InsertChain([]*types.Block{blk}, !consensus.FBFTLog.IsBlockVerified(blk)); err != nil {
consensus.getLogger().Error().Err(err).Msg("[commitBlock] Failed to add block to chain")
return err
}

@ -296,6 +296,7 @@ func (consensus *Consensus) onCommit(recvMsg *FBFTMessage) {
if !quorumWasMet && quorumIsMet {
logger.Info().Msg("[OnCommit] 2/3 Enough commits received")
consensus.FBFTLog.MarkBlockVerified(blockObj)
if !blockObj.IsLastBlockInEpoch() {
// only do early commit if it's not epoch block to avoid problems

@ -122,7 +122,7 @@ func (node *Node) explorerMessageHandler(ctx context.Context, msg *msg_pb.Messag
// AddNewBlockForExplorer add new block for explorer.
func (node *Node) AddNewBlockForExplorer(block *types.Block) {
utils.Logger().Info().Uint64("blockHeight", block.NumberU64()).Msg("[Explorer] Adding new block for explorer node")
if _, err := node.Blockchain().InsertChain([]*types.Block{block}, true); err == nil {
if _, err := node.Blockchain().InsertChain([]*types.Block{block}, false); err == nil {
if block.IsLastBlockInEpoch() {
node.Consensus.UpdateConsensusInformation()
}

Loading…
Cancel
Save