only enable randomness service on leader

consensus readched on AWS deployment

Signed-off-by: Leo Chen <leo@harmony.one>
pull/498/head
Leo Chen 6 years ago
parent ba02ec922a
commit f02ff769d3
  1. 2
      cmd/harmony.go
  2. 8
      drand/drand.go
  3. 2
      node/service_setup.go

@ -279,7 +279,7 @@ func main() {
// Add randomness protocol
// TODO: enable drand only for beacon chain
// TODO: put this in a better place other than main.
dRand := drand.New(host, shardID, peers, leader, currentNode.ConfirmedBlockChannel)
dRand := drand.New(host, shardID, peers, leader, currentNode.ConfirmedBlockChannel, *isLeader)
currentNode.Consensus.RegisterPRndChannel(dRand.PRndChannel)
currentNode.Consensus.RegisterRndChannel(dRand.RndChannel)
currentNode.DRand = dRand

@ -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 {

@ -71,8 +71,6 @@ func (node *Node) setupForBeaconValidator() {
node.serviceManager.RegisterService(service.PeerDiscovery, discovery.New(node.host, nodeConfig, chanPeer))
// Register networkinfo service.
node.serviceManager.RegisterService(service.NetworkInfo, networkinfo.New(node.host, p2p.GroupIDBeacon, chanPeer))
// Register randomness service
node.serviceManager.RegisterService(service.Randomness, randomness.New(node.DRand))
}
func (node *Node) setupForNewNode() {

Loading…
Cancel
Save