2022-09-24 14:44:34 +00:00
|
|
|
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) {
|
2022-09-24 20:09:04 +00:00
|
|
|
bootnodes := NetworkConfigs[net].bootNodes
|
2022-09-24 14:44:34 +00:00
|
|
|
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
|
|
|
|
}
|