[viewchange] filter out viewchange message in p2p validation

filter out viewchange/newview message when the validator is not in viewchanging mode.

Signed-off-by: Leo Chen <leo@harmony.one>
pull/3388/head
Leo Chen 4 years ago
parent 793529ee24
commit 67a167eb3a
  1. 7
      consensus/consensus_v2.go
  2. 4
      node/node.go

@ -43,13 +43,6 @@ func (consensus *Consensus) HandleMessageUpdate(ctx context.Context, msg *msg_pb
return nil
}
// when node is not in ViewChanging mode, ignore viewchange / newview messages
if !consensus.IsViewChangingMode() &&
(msg.Type == msg_pb.MessageType_VIEWCHANGE ||
msg.Type == msg_pb.MessageType_NEWVIEW) {
return nil
}
intendedForValidator, intendedForLeader :=
!consensus.IsLeader(),
consensus.IsLeader()

@ -461,9 +461,9 @@ func (node *Node) validateShardBoundMessage(
return nil, nil, true, nil
}
} else {
// ignore newview message if the node is not in viewchanging mode
// ignore viewchange/newview message if the node is not in viewchanging mode
switch m.Type {
case msg_pb.MessageType_NEWVIEW:
case msg_pb.MessageType_NEWVIEW, msg_pb.MessageType_VIEWCHANGE:
return nil, nil, true, nil
}
}

Loading…
Cancel
Save