|
|
|
@ -121,7 +121,7 @@ func NewConsensus(ip, port, ShardID string, peers []p2p.Peer, leader p2p.Peer) * |
|
|
|
|
|
|
|
|
|
consensus.leader = leader |
|
|
|
|
for _, peer := range peers { |
|
|
|
|
consensus.validators.Store(utils.GetUniqueIdFromPeer(peer), peer) |
|
|
|
|
consensus.validators.Store(utils.GetUniqueIDFromPeer(peer), peer) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Initialize cosign bitmap
|
|
|
|
@ -146,7 +146,7 @@ func NewConsensus(ip, port, ShardID string, peers []p2p.Peer, leader p2p.Peer) * |
|
|
|
|
|
|
|
|
|
// For now use socket address as 16 byte Id
|
|
|
|
|
// TODO: populate with correct Id
|
|
|
|
|
consensus.nodeID = utils.GetUniqueIdFromPeer(p2p.Peer{IP: ip, Port: port}) |
|
|
|
|
consensus.nodeID = utils.GetUniqueIDFromPeer(p2p.Peer{IP: ip, Port: port}) |
|
|
|
|
|
|
|
|
|
// Set private key for myself so that I can sign messages.
|
|
|
|
|
consensus.priKey = crypto.Ed25519Curve.Scalar().SetInt64(int64(consensus.nodeID)) |
|
|
|
@ -239,12 +239,12 @@ func (consensus *Consensus) AddPeers(peers []p2p.Peer) int { |
|
|
|
|
count := 0 |
|
|
|
|
|
|
|
|
|
for _, peer := range peers { |
|
|
|
|
_, ok := consensus.validators.Load(utils.GetUniqueIdFromPeer(peer)) |
|
|
|
|
_, ok := consensus.validators.Load(utils.GetUniqueIDFromPeer(peer)) |
|
|
|
|
if !ok { |
|
|
|
|
if peer.ValidatorID == -1 { |
|
|
|
|
peer.ValidatorID = int(consensus.uniqueIDInstance.GetUniqueID()) |
|
|
|
|
} |
|
|
|
|
consensus.validators.Store(utils.GetUniqueIdFromPeer(peer), peer) |
|
|
|
|
consensus.validators.Store(utils.GetUniqueIDFromPeer(peer), peer) |
|
|
|
|
consensus.PublicKeys = append(consensus.PublicKeys, peer.PubKey) |
|
|
|
|
} |
|
|
|
|
count++ |
|
|
|
|