Add consensus view Id and checks

pull/6/head
Rongjian Lan 7 years ago
parent 271106289e
commit 0498d87059
  1. 1
      consensus/consensus_leader.go
  2. 10
      consensus/consensus_validator.go

@ -289,6 +289,7 @@ func (consensus *Consensus) processResponseMessage(payload []byte) {
// TODO: do followups on the consensus
log.Printf("HOORAY!!! CONSENSUS REACHED AMONG %d NODES!!!\n", len(consensus.validators))
consensus.ResetState()
consensus.consensusId++
consensus.ReadySignal <- 1
}
// TODO: composes new block and broadcast the new block to validators

@ -73,7 +73,10 @@ func (consensus *Consensus) processAnnounceMessage(payload []byte) {
consensus.blockHash = blockHash
// verify block data
if consensusId != consensus.consensusId {
log.Println("Received message with consensus Id: %s. My consensus Id: %s", consensusId, consensus.consensusId)
return
}
// sign block
// TODO: return the signature(commit) to leader
@ -160,6 +163,10 @@ func (consensus *Consensus) processChallengeMessage(payload []byte) {
_ = signature
// verify block data and the aggregated signatures
if consensusId != consensus.consensusId {
log.Println("Received message with consensus Id: %s. My consensus Id: %s", consensusId, consensus.consensusId)
return
}
// sign the message
@ -170,6 +177,7 @@ func (consensus *Consensus) processChallengeMessage(payload []byte) {
// Set state to RESPONSE_DONE
consensus.state = RESPONSE_DONE
consensus.consensusId++
}
// Construct the response message to send to leader (assumption the consensus data is already verified)

Loading…
Cancel
Save