|
|
@ -167,6 +167,9 @@ type Node struct { |
|
|
|
TestBankKeys []*ecdsa.PrivateKey |
|
|
|
TestBankKeys []*ecdsa.PrivateKey |
|
|
|
ContractKeys []*ecdsa.PrivateKey |
|
|
|
ContractKeys []*ecdsa.PrivateKey |
|
|
|
ContractAddresses []common.Address |
|
|
|
ContractAddresses []common.Address |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Group Message Receiver
|
|
|
|
|
|
|
|
groupReceiver p2p.GroupReceiver |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Blockchain returns the blockchain from node
|
|
|
|
// Blockchain returns the blockchain from node
|
|
|
@ -274,6 +277,9 @@ func New(host p2p.Host, consensus *bft.Consensus, db ethdb.Database) *Node { |
|
|
|
node.OfflinePeers = make(chan p2p.Peer) |
|
|
|
node.OfflinePeers = make(chan p2p.Peer) |
|
|
|
go node.RemovePeersHandler() |
|
|
|
go node.RemovePeersHandler() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// start the goroutine to receive group message
|
|
|
|
|
|
|
|
go node.ReceiveGroupMessage() |
|
|
|
|
|
|
|
|
|
|
|
return &node |
|
|
|
return &node |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -587,6 +593,13 @@ func (node *Node) setupForShardValidator() { |
|
|
|
func (node *Node) setupForBeaconLeader() { |
|
|
|
func (node *Node) setupForBeaconLeader() { |
|
|
|
chanPeer := make(chan p2p.Peer) |
|
|
|
chanPeer := make(chan p2p.Peer) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
node.groupReceiver, err = node.host.GroupReceiver(p2p.GroupIDBeacon) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
utils.GetLogInstance().Error("create group receiver error", "msg", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Register peer discovery service. "0" is the beacon shard ID. No need to do staking for beacon chain node.
|
|
|
|
// Register peer discovery service. "0" is the beacon shard ID. No need to do staking for beacon chain node.
|
|
|
|
node.serviceManager.RegisterService(service_manager.PeerDiscovery, discovery.New(node.host, "0", chanPeer, nil)) |
|
|
|
node.serviceManager.RegisterService(service_manager.PeerDiscovery, discovery.New(node.host, "0", chanPeer, nil)) |
|
|
|
// Register networkinfo service. "0" is the beacon shard ID
|
|
|
|
// Register networkinfo service. "0" is the beacon shard ID
|
|
|
@ -603,6 +616,13 @@ func (node *Node) setupForBeaconLeader() { |
|
|
|
func (node *Node) setupForBeaconValidator() { |
|
|
|
func (node *Node) setupForBeaconValidator() { |
|
|
|
chanPeer := make(chan p2p.Peer) |
|
|
|
chanPeer := make(chan p2p.Peer) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
node.groupReceiver, err = node.host.GroupReceiver(p2p.GroupIDBeacon) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
utils.GetLogInstance().Error("create group receiver error", "msg", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Register peer discovery service. "0" is the beacon shard ID. No need to do staking for beacon chain node.
|
|
|
|
// Register peer discovery service. "0" is the beacon shard ID. No need to do staking for beacon chain node.
|
|
|
|
node.serviceManager.RegisterService(service_manager.PeerDiscovery, discovery.New(node.host, "0", chanPeer, nil)) |
|
|
|
node.serviceManager.RegisterService(service_manager.PeerDiscovery, discovery.New(node.host, "0", chanPeer, nil)) |
|
|
|
// Register networkinfo service. "0" is the beacon shard ID
|
|
|
|
// Register networkinfo service. "0" is the beacon shard ID
|
|
|
@ -613,6 +633,13 @@ func (node *Node) setupForNewNode() { |
|
|
|
chanPeer := make(chan p2p.Peer) |
|
|
|
chanPeer := make(chan p2p.Peer) |
|
|
|
stakingPeer := make(chan p2p.Peer) |
|
|
|
stakingPeer := make(chan p2p.Peer) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var err error |
|
|
|
|
|
|
|
node.groupReceiver, err = node.host.GroupReceiver(p2p.GroupIDBeacon) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
utils.GetLogInstance().Error("create group receiver error", "msg", err) |
|
|
|
|
|
|
|
return |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Register staking service.
|
|
|
|
// Register staking service.
|
|
|
|
node.serviceManager.RegisterService(service_manager.Staking, staking.New(stakingPeer)) |
|
|
|
node.serviceManager.RegisterService(service_manager.Staking, staking.New(stakingPeer)) |
|
|
|
// Register peer discovery service. "0" is the beacon shard ID
|
|
|
|
// Register peer discovery service. "0" is the beacon shard ID
|
|
|
|