erigon-pulse/cmd/lightclient/clparams/discover.go
Enrique Jose Avila Asapche b7606dcccb
added networkConfig.go (#5501)
* added networkConfig.go and mainnet config

* added goerli and sepolia networkConfig

* using map

* renaming to poop

* proper name

* fixed a bunch of stuff

Co-authored-by: giuliorebuffo <giuliorebuffo@system76-pc.localdomain>
2022-09-24 22:09:04 +02:00

28 lines
634 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 := NetworkConfigs[net].bootNodes
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
}