fix beacon node detection for p2p protocol

pull/4351/head
“GheisMohammadi” 2 years ago committed by Casey Gardiner
parent e5f18d3f36
commit cc93332b5d
  1. 13
      api/service/stagedstreamsync/downloader.go
  2. 4
      api/service/stagedstreamsync/downloaders.go
  3. 13
      hmy/downloader/downloader.go
  4. 4
      hmy/downloader/downloaders.go

@ -36,15 +36,16 @@ type (
) )
// NewDownloader creates a new downloader // NewDownloader creates a new downloader
func NewDownloader(host p2p.Host, bc core.BlockChain, config Config) *Downloader { func NewDownloader(host p2p.Host, bc core.BlockChain, isBeaconNode bool, config Config) *Downloader {
config.fixValues() config.fixValues()
sp := sync.NewProtocol(sync.Config{ sp := sync.NewProtocol(sync.Config{
Chain: bc, Chain: bc,
Host: host.GetP2PHost(), Host: host.GetP2PHost(),
Discovery: host.GetDiscovery(), Discovery: host.GetDiscovery(),
ShardID: nodeconfig.ShardID(bc.ShardID()), ShardID: nodeconfig.ShardID(bc.ShardID()),
Network: config.Network, Network: config.Network,
BeaconNode: isBeaconNode,
SmSoftLowCap: config.SmSoftLowCap, SmSoftLowCap: config.SmSoftLowCap,
SmHardLowCap: config.SmHardLowCap, SmHardLowCap: config.SmHardLowCap,

@ -17,7 +17,7 @@ type Downloaders struct {
// NewDownloaders creates Downloaders for sync of multiple blockchains // NewDownloaders creates Downloaders for sync of multiple blockchains
func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downloaders { func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downloaders {
ds := make(map[uint32]*Downloader) ds := make(map[uint32]*Downloader)
isBeaconNode := len(bcs) == 1
for _, bc := range bcs { for _, bc := range bcs {
if bc == nil { if bc == nil {
continue continue
@ -25,7 +25,7 @@ func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downlo
if _, ok := ds[bc.ShardID()]; ok { if _, ok := ds[bc.ShardID()]; ok {
continue continue
} }
ds[bc.ShardID()] = NewDownloader(host, bc, config) ds[bc.ShardID()] = NewDownloader(host, bc, isBeaconNode, config)
} }
return &Downloaders{ return &Downloaders{
ds: ds, ds: ds,

@ -44,15 +44,16 @@ type (
) )
// NewDownloader creates a new downloader // NewDownloader creates a new downloader
func NewDownloader(host p2p.Host, bc core.BlockChain, config Config) *Downloader { func NewDownloader(host p2p.Host, bc core.BlockChain, isBeaconNode bool, config Config) *Downloader {
config.fixValues() config.fixValues()
sp := sync.NewProtocol(sync.Config{ sp := sync.NewProtocol(sync.Config{
Chain: bc, Chain: bc,
Host: host.GetP2PHost(), Host: host.GetP2PHost(),
Discovery: host.GetDiscovery(), Discovery: host.GetDiscovery(),
ShardID: nodeconfig.ShardID(bc.ShardID()), ShardID: nodeconfig.ShardID(bc.ShardID()),
Network: config.Network, Network: config.Network,
BeaconNode: isBeaconNode,
SmSoftLowCap: config.SmSoftLowCap, SmSoftLowCap: config.SmSoftLowCap,
SmHardLowCap: config.SmHardLowCap, SmHardLowCap: config.SmHardLowCap,

@ -17,7 +17,7 @@ type Downloaders struct {
// NewDownloaders creates Downloaders for sync of multiple blockchains // NewDownloaders creates Downloaders for sync of multiple blockchains
func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downloaders { func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downloaders {
ds := make(map[uint32]*Downloader) ds := make(map[uint32]*Downloader)
isBeaconNode := len(bcs) == 1
for _, bc := range bcs { for _, bc := range bcs {
if bc == nil { if bc == nil {
continue continue
@ -25,7 +25,7 @@ func NewDownloaders(host p2p.Host, bcs []core.BlockChain, config Config) *Downlo
if _, ok := ds[bc.ShardID()]; ok { if _, ok := ds[bc.ShardID()]; ok {
continue continue
} }
ds[bc.ShardID()] = NewDownloader(host, bc, config) ds[bc.ShardID()] = NewDownloader(host, bc, isBeaconNode, config)
} }
return &Downloaders{ return &Downloaders{
ds: ds, ds: ds,

Loading…
Cancel
Save