|
|
@ -132,10 +132,10 @@ func (node *Node) messageHandler(content []byte, sender string) { |
|
|
|
case proto.Consensus: |
|
|
|
case proto.Consensus: |
|
|
|
msgPayload, _ := proto.GetConsensusMessagePayload(content) |
|
|
|
msgPayload, _ := proto.GetConsensusMessagePayload(content) |
|
|
|
if consensusObj.IsLeader { |
|
|
|
if consensusObj.IsLeader { |
|
|
|
utils.GetLogInstance().Info("NET: Leader received consensus message") |
|
|
|
// utils.GetLogInstance().Info("NET: Leader received consensus message")
|
|
|
|
consensusObj.ProcessMessageLeader(msgPayload) |
|
|
|
consensusObj.ProcessMessageLeader(msgPayload) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
utils.GetLogInstance().Info("NET: Validator received consensus message") |
|
|
|
// utils.GetLogInstance().Info("NET: Validator received consensus message")
|
|
|
|
consensusObj.ProcessMessageValidator(msgPayload) |
|
|
|
consensusObj.ProcessMessageValidator(msgPayload) |
|
|
|
// TODO(minhdoan): add logic to check if the current blockchain is not sync with other consensus
|
|
|
|
// TODO(minhdoan): add logic to check if the current blockchain is not sync with other consensus
|
|
|
|
// we should switch to other state rather than DoingConsensus.
|
|
|
|
// we should switch to other state rather than DoingConsensus.
|
|
|
@ -144,10 +144,10 @@ func (node *Node) messageHandler(content []byte, sender string) { |
|
|
|
msgPayload, _ := proto.GetDRandMessagePayload(content) |
|
|
|
msgPayload, _ := proto.GetDRandMessagePayload(content) |
|
|
|
if node.DRand != nil { |
|
|
|
if node.DRand != nil { |
|
|
|
if node.DRand.IsLeader { |
|
|
|
if node.DRand.IsLeader { |
|
|
|
utils.GetLogInstance().Info("NET: DRand Leader received message") |
|
|
|
// utils.GetLogInstance().Info("NET: DRand Leader received message")
|
|
|
|
node.DRand.ProcessMessageLeader(msgPayload) |
|
|
|
node.DRand.ProcessMessageLeader(msgPayload) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
utils.GetLogInstance().Info("NET: DRand Validator received message") |
|
|
|
// utils.GetLogInstance().Info("NET: DRand Validator received message")
|
|
|
|
node.DRand.ProcessMessageValidator(msgPayload) |
|
|
|
node.DRand.ProcessMessageValidator(msgPayload) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
@ -343,9 +343,9 @@ func (node *Node) AddNewBlock(newBlock *types.Block) { |
|
|
|
|
|
|
|
|
|
|
|
func (node *Node) pingMessageHandler(msgPayload []byte, sender string) int { |
|
|
|
func (node *Node) pingMessageHandler(msgPayload []byte, sender string) int { |
|
|
|
if sender != "" { |
|
|
|
if sender != "" { |
|
|
|
_, ok := node.duplicatedPing[sender] |
|
|
|
_, ok := node.duplicatedPing.Load(sender) |
|
|
|
if !ok { |
|
|
|
if !ok { |
|
|
|
node.duplicatedPing[sender] = true |
|
|
|
node.duplicatedPing.Store(sender, true) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
// duplicated ping message return
|
|
|
|
// duplicated ping message return
|
|
|
|
return 0 |
|
|
|
return 0 |
|
|
|