|
|
|
@ -67,7 +67,7 @@ type DRand struct { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// New creates a new dRand object
|
|
|
|
|
func New(host p2p.Host, ShardID string, peers []p2p.Peer, leader p2p.Peer, confirmedBlockChannel chan *types.Block) *DRand { |
|
|
|
|
func New(host p2p.Host, ShardID string, peers []p2p.Peer, leader p2p.Peer, confirmedBlockChannel chan *types.Block, isLeader bool) *DRand { |
|
|
|
|
dRand := DRand{} |
|
|
|
|
dRand.host = host |
|
|
|
|
|
|
|
|
@ -79,11 +79,7 @@ func New(host p2p.Host, ShardID string, peers []p2p.Peer, leader p2p.Peer, confi |
|
|
|
|
dRand.RndChannel = make(chan [64]byte) |
|
|
|
|
|
|
|
|
|
selfPeer := host.GetSelfPeer() |
|
|
|
|
if leader.Port == selfPeer.Port && leader.IP == selfPeer.IP { |
|
|
|
|
dRand.IsLeader = true |
|
|
|
|
} else { |
|
|
|
|
dRand.IsLeader = false |
|
|
|
|
} |
|
|
|
|
dRand.IsLeader = isLeader |
|
|
|
|
|
|
|
|
|
dRand.leader = leader |
|
|
|
|
for _, peer := range peers { |
|
|
|
|