mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-05 18:42:19 +00:00
71112c1aae
* added peer discovery functionality * added discovery and connection to consensus layer bootnodes * lint Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
28 lines
624 B
Go
28 lines
624 B
Go
package clparams
|
|
|
|
import (
|
|
"github.com/ledgerwatch/erigon/crypto"
|
|
"github.com/ledgerwatch/erigon/p2p/discover"
|
|
"github.com/ledgerwatch/erigon/p2p/enode"
|
|
)
|
|
|
|
func GetDefaultDiscoveryConfig(net NetworkType) (*discover.Config, error) {
|
|
bootnodes := BootstrapNodes[net]
|
|
privateKey, err := crypto.GenerateKey()
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
enodes := []*enode.Node{}
|
|
for _, addr := range bootnodes {
|
|
enode, err := enode.Parse(enode.ValidSchemes, addr)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
enodes = append(enodes, enode)
|
|
}
|
|
return &discover.Config{
|
|
PrivateKey: privateKey,
|
|
Bootnodes: enodes,
|
|
}, nil
|
|
}
|