|
|
|
@ -38,12 +38,11 @@ type Consensus struct { |
|
|
|
|
// BlockHeader to run consensus on
|
|
|
|
|
blockHeader []byte |
|
|
|
|
// Shard Id which this node belongs to
|
|
|
|
|
ShardIDShardID uint32 |
|
|
|
|
ShardID uint32 |
|
|
|
|
|
|
|
|
|
// global consensus mutex
|
|
|
|
|
mutex sync.Mutex |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Validator specific fields
|
|
|
|
|
// Blocks received but not done with consensus yet
|
|
|
|
|
blocksReceived map[uint32]*BlockConsensusStatus |
|
|
|
@ -90,6 +89,7 @@ const ( |
|
|
|
|
CHALLENGE_DONE |
|
|
|
|
RESPONSE_DONE |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
// Returns string name for the ConsensusState enum
|
|
|
|
|
func (state ConsensusState) String() string { |
|
|
|
|
names := [...]string{ |
|
|
|
@ -131,11 +131,11 @@ func NewConsensus(ip, port, ShardID string, peers []p2p.Peer, leader p2p.Peer) C |
|
|
|
|
consensus.Log.Crit("Regex Compilation Failed", "err", err, "consensus", consensus) |
|
|
|
|
} |
|
|
|
|
consensus.consensusId = 0 |
|
|
|
|
myShardIDShardID, err := strconv.Atoi(ShardID) |
|
|
|
|
myShardID, err := strconv.Atoi(ShardID) |
|
|
|
|
if err != nil { |
|
|
|
|
panic("Unparseable shard Id" + ShardID) |
|
|
|
|
} |
|
|
|
|
consensus.ShardIDShardID = uint32(myShardIDShardID) |
|
|
|
|
consensus.ShardID = uint32(myShardID) |
|
|
|
|
|
|
|
|
|
// For validators
|
|
|
|
|
consensus.blocksReceived = make(map[uint32]*BlockConsensusStatus) |
|
|
|
@ -176,5 +176,5 @@ func (consensus *Consensus) String() string { |
|
|
|
|
} else { |
|
|
|
|
duty = "VLD" // validator
|
|
|
|
|
} |
|
|
|
|
return fmt.Sprintf("[%s, %s, %v, %v, %s]", duty, consensus.priKey, consensus.ShardIDShardID, consensus.nodeId, consensus.state) |
|
|
|
|
return fmt.Sprintf("[%s, %s, %v, %v, %s]", duty, consensus.priKey, consensus.ShardID, consensus.nodeId, consensus.state) |
|
|
|
|
} |
|
|
|
|