mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-25 04:47:18 +00:00
Lookup Bootnode instead of Random Nodes (#3555)
* add workspace change * change to lookup bootnode
This commit is contained in:
parent
b7853f1fa8
commit
71098b6ed8
@ -97,7 +97,7 @@ func convertToMultiAddr(nodes []*enode.Node) []ma.Multiaddr {
|
|||||||
func convertToSingleMultiAddr(node *enode.Node) (ma.Multiaddr, error) {
|
func convertToSingleMultiAddr(node *enode.Node) (ma.Multiaddr, error) {
|
||||||
ip4 := node.IP().To4()
|
ip4 := node.IP().To4()
|
||||||
if ip4 == nil {
|
if ip4 == nil {
|
||||||
return nil, errors.New("node doesn't have an ip4 address")
|
return nil, errors.Errorf("node doesn't have an ip4 address, it's stated IP is %s", node.IP().String())
|
||||||
}
|
}
|
||||||
pubkey := node.Pubkey()
|
pubkey := node.Pubkey()
|
||||||
assertedKey := convertToInterfacePubkey(pubkey)
|
assertedKey := convertToInterfacePubkey(pubkey)
|
||||||
|
@ -190,10 +190,14 @@ func (s *Service) Disconnect(pid peer.ID) error {
|
|||||||
// listen for new nodes watches for new nodes in the network and adds them to the peerstore.
|
// listen for new nodes watches for new nodes in the network and adds them to the peerstore.
|
||||||
func (s *Service) listenForNewNodes() {
|
func (s *Service) listenForNewNodes() {
|
||||||
ticker := time.NewTicker(pollingPeriod)
|
ticker := time.NewTicker(pollingPeriod)
|
||||||
|
bootNode, err := enode.Parse(enode.ValidSchemes, s.cfg.BootstrapNodeAddr)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
nodes := s.dv5Listener.LookupRandom()
|
nodes := s.dv5Listener.Lookup(bootNode.ID())
|
||||||
multiAddresses := convertToMultiAddr(nodes)
|
multiAddresses := convertToMultiAddr(nodes)
|
||||||
s.connectWithAllPeers(multiAddresses)
|
s.connectWithAllPeers(multiAddresses)
|
||||||
case <-s.ctx.Done():
|
case <-s.ctx.Done():
|
||||||
|
Loading…
Reference in New Issue
Block a user