mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-15 16:33:47 +00:00
Add more flags
This commit is contained in:
parent
74d384b6a4
commit
3acd7a12de
5 changed files with 230 additions and 115 deletions
24
command/server/chains/chain.go
Normal file
24
command/server/chains/chain.go
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
package chains
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/ethereum/go-ethereum/common"
|
||||||
|
"github.com/ethereum/go-ethereum/core"
|
||||||
|
)
|
||||||
|
|
||||||
|
type Chain struct {
|
||||||
|
Hash common.Hash
|
||||||
|
Genesis *core.Genesis
|
||||||
|
Bootnodes []string
|
||||||
|
NetworkId uint64
|
||||||
|
DNS []string
|
||||||
|
}
|
||||||
|
|
||||||
|
var chains = map[string]*Chain{
|
||||||
|
"mainnet": mainnetBor,
|
||||||
|
"mumbai": mumbaiTestnet,
|
||||||
|
}
|
||||||
|
|
||||||
|
func GetChain(name string) (*Chain, bool) {
|
||||||
|
chain, ok := chains[name]
|
||||||
|
return chain, ok
|
||||||
|
}
|
||||||
|
|
@ -8,48 +8,45 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
var BorMainnetGenesisHash = common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b")
|
var mainnetBor = &Chain{
|
||||||
|
Hash: common.HexToHash("0xa9c28ce2141b56c474f1dc504bee9b01eb1bd7d1a507580d5519d4437a97de1b"),
|
||||||
var BorMainnetChainConfig = ¶ms.ChainConfig{
|
NetworkId: 137,
|
||||||
ChainID: big.NewInt(137),
|
Genesis: &core.Genesis{
|
||||||
HomesteadBlock: big.NewInt(0),
|
Config: ¶ms.ChainConfig{
|
||||||
DAOForkBlock: nil,
|
ChainID: big.NewInt(137),
|
||||||
DAOForkSupport: true,
|
HomesteadBlock: big.NewInt(0),
|
||||||
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
DAOForkBlock: nil,
|
||||||
EIP150Block: big.NewInt(0),
|
DAOForkSupport: true,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
PetersburgBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
IstanbulBlock: big.NewInt(3395000),
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
MuirGlacierBlock: big.NewInt(3395000),
|
PetersburgBlock: big.NewInt(0),
|
||||||
BerlinBlock: big.NewInt(14750000),
|
IstanbulBlock: big.NewInt(3395000),
|
||||||
Bor: ¶ms.BorConfig{
|
MuirGlacierBlock: big.NewInt(3395000),
|
||||||
Period: 2,
|
BerlinBlock: big.NewInt(14750000),
|
||||||
ProducerDelay: 6,
|
Bor: ¶ms.BorConfig{
|
||||||
Sprint: 64,
|
Period: 2,
|
||||||
BackupMultiplier: 2,
|
ProducerDelay: 6,
|
||||||
ValidatorContract: "0x0000000000000000000000000000000000001000",
|
Sprint: 64,
|
||||||
StateReceiverContract: "0x0000000000000000000000000000000000001001",
|
BackupMultiplier: 2,
|
||||||
OverrideStateSyncRecords: map[string]int{
|
ValidatorContract: "0x0000000000000000000000000000000000001000",
|
||||||
"14949120": 8,
|
StateReceiverContract: "0x0000000000000000000000000000000000001001",
|
||||||
"14949184": 0,
|
OverrideStateSyncRecords: map[string]int{
|
||||||
"14953472": 0,
|
"14949120": 8,
|
||||||
"14953536": 5,
|
"14949184": 0,
|
||||||
"14953600": 0,
|
"14953472": 0,
|
||||||
"14953664": 0,
|
"14953536": 5,
|
||||||
"14953728": 0,
|
"14953600": 0,
|
||||||
"14953792": 0,
|
"14953664": 0,
|
||||||
"14953856": 0,
|
"14953728": 0,
|
||||||
|
"14953792": 0,
|
||||||
|
"14953856": 0,
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
//DefaultBorMainnet returns the Bor Mainnet network gensis block.
|
|
||||||
func DefaultBorMainnetGenesisBlock() *core.Genesis {
|
|
||||||
return &core.Genesis{
|
|
||||||
Config: BorMainnetChainConfig,
|
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Timestamp: 1590824836,
|
Timestamp: 1590824836,
|
||||||
GasLimit: 10000000,
|
GasLimit: 10000000,
|
||||||
|
|
@ -57,5 +54,9 @@ func DefaultBorMainnetGenesisBlock() *core.Genesis {
|
||||||
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
||||||
Alloc: readPrealloc("allocs/bor_mainnet.json"),
|
Alloc: readPrealloc("allocs/bor_mainnet.json"),
|
||||||
}
|
},
|
||||||
|
Bootnodes: []string{
|
||||||
|
"enode://0cb82b395094ee4a2915e9714894627de9ed8498fb881cec6db7c65e8b9a5bd7f2f25cc84e71e89d0947e51c76e85d0847de848c7782b13c0255247a6758178c@44.232.55.71:30303",
|
||||||
|
"enode://88116f4295f5a31538ae409e4d44ad40d22e44ee9342869e7d68bdec55b0f83c1530355ce8b41fbec0928a7d75a5745d528450d30aec92066ab6ba1ee351d710@159.203.9.164:30303",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,36 +8,34 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
)
|
)
|
||||||
|
|
||||||
var MumbaiGenesisHash = common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7")
|
var mumbaiTestnet = &Chain{
|
||||||
|
Hash: common.HexToHash("0x7b66506a9ebdbf30d32b43c5f15a3b1216269a1ec3a75aa3182b86176a2b1ca7"),
|
||||||
var MumbaiChainConfig = ¶ms.ChainConfig{
|
NetworkId: 80001,
|
||||||
ChainID: big.NewInt(80001),
|
Genesis: &core.Genesis{
|
||||||
HomesteadBlock: big.NewInt(0),
|
Config: ¶ms.ChainConfig{
|
||||||
DAOForkBlock: nil,
|
ChainID: big.NewInt(80001),
|
||||||
DAOForkSupport: true,
|
HomesteadBlock: big.NewInt(0),
|
||||||
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
DAOForkBlock: nil,
|
||||||
EIP150Block: big.NewInt(0),
|
DAOForkSupport: true,
|
||||||
EIP155Block: big.NewInt(0),
|
EIP150Hash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
EIP158Block: big.NewInt(0),
|
EIP150Block: big.NewInt(0),
|
||||||
ByzantiumBlock: big.NewInt(0),
|
EIP155Block: big.NewInt(0),
|
||||||
ConstantinopleBlock: big.NewInt(0),
|
EIP158Block: big.NewInt(0),
|
||||||
PetersburgBlock: big.NewInt(0),
|
ByzantiumBlock: big.NewInt(0),
|
||||||
IstanbulBlock: big.NewInt(2722000),
|
ConstantinopleBlock: big.NewInt(0),
|
||||||
MuirGlacierBlock: big.NewInt(2722000),
|
PetersburgBlock: big.NewInt(0),
|
||||||
BerlinBlock: big.NewInt(13996000),
|
IstanbulBlock: big.NewInt(2722000),
|
||||||
Bor: ¶ms.BorConfig{
|
MuirGlacierBlock: big.NewInt(2722000),
|
||||||
Period: 2,
|
BerlinBlock: big.NewInt(13996000),
|
||||||
ProducerDelay: 6,
|
Bor: ¶ms.BorConfig{
|
||||||
Sprint: 64,
|
Period: 2,
|
||||||
BackupMultiplier: 2,
|
ProducerDelay: 6,
|
||||||
ValidatorContract: "0x0000000000000000000000000000000000001000",
|
Sprint: 64,
|
||||||
StateReceiverContract: "0x0000000000000000000000000000000000001001",
|
BackupMultiplier: 2,
|
||||||
},
|
ValidatorContract: "0x0000000000000000000000000000000000001000",
|
||||||
}
|
StateReceiverContract: "0x0000000000000000000000000000000000001001",
|
||||||
|
},
|
||||||
func DefaultMumbaiGenesisBlock() *core.Genesis {
|
},
|
||||||
return &core.Genesis{
|
|
||||||
Config: MumbaiChainConfig,
|
|
||||||
Nonce: 0,
|
Nonce: 0,
|
||||||
Timestamp: 1558348305,
|
Timestamp: 1558348305,
|
||||||
GasLimit: 10000000,
|
GasLimit: 10000000,
|
||||||
|
|
@ -45,5 +43,9 @@ func DefaultMumbaiGenesisBlock() *core.Genesis {
|
||||||
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
Mixhash: common.HexToHash("0x0000000000000000000000000000000000000000000000000000000000000000"),
|
||||||
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
Coinbase: common.HexToAddress("0x0000000000000000000000000000000000000000"),
|
||||||
Alloc: readPrealloc("allocs/mumbai.json"),
|
Alloc: readPrealloc("allocs/mumbai.json"),
|
||||||
}
|
},
|
||||||
|
Bootnodes: []string{
|
||||||
|
"enode://320553cda00dfc003f499a3ce9598029f364fbb3ed1222fdc20a94d97dcc4d8ba0cd0bfa996579dcc6d17a534741fb0a5da303a90579431259150de66b597251@54.147.31.250:30303",
|
||||||
|
"enode://f0f48a8781629f95ff02606081e6e43e4aebd503f3d07fc931fad7dd5ca1ba52bd849a6f6c3be0e375cf13c9ae04d859c4a9ae3546dc8ed4f10aa5dbb47d4998@34.226.134.117:30303",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,9 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/eth"
|
"github.com/ethereum/go-ethereum/eth"
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers"
|
"github.com/ethereum/go-ethereum/ethstats"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/mattn/go-colorable"
|
"github.com/mattn/go-colorable"
|
||||||
"github.com/mattn/go-isatty"
|
"github.com/mattn/go-isatty"
|
||||||
|
|
@ -66,7 +67,12 @@ func (c *Command) Run(args []string) int {
|
||||||
// start the logger
|
// start the logger
|
||||||
setupLogger(*config.LogLevel)
|
setupLogger(*config.LogLevel)
|
||||||
|
|
||||||
// create the node
|
// load the chain genesis
|
||||||
|
if err := config.loadChain(); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
// create the node/stack
|
||||||
nodeCfg, err := config.buildNode()
|
nodeCfg, err := config.buildNode()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
@ -77,6 +83,14 @@ func (c *Command) Run(args []string) int {
|
||||||
}
|
}
|
||||||
c.node = stack
|
c.node = stack
|
||||||
|
|
||||||
|
// TODO: MakeChain?
|
||||||
|
// TODO: Metrics
|
||||||
|
// TODO: Node key, pre generate one
|
||||||
|
// TODO: apis
|
||||||
|
// TODO: account management
|
||||||
|
// TODO: Graphql
|
||||||
|
// TODO: embed
|
||||||
|
|
||||||
// register the ethereum backend
|
// register the ethereum backend
|
||||||
ethCfg, err := config.buildEth()
|
ethCfg, err := config.buildEth()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -86,7 +100,16 @@ func (c *Command) Run(args []string) int {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
c.node.RegisterAPIs(tracers.APIs(backend.APIBackend))
|
|
||||||
|
// This is the tracers api, not sure if this should be here, i do not think so.
|
||||||
|
// c.node.RegisterAPIs(tracers.APIs(backend.APIBackend))
|
||||||
|
|
||||||
|
// register ethash service
|
||||||
|
if config.EthStats != nil {
|
||||||
|
if err := ethstats.New(stack, backend.APIBackend, backend.Engine(), *config.EthStats); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// start the node
|
// start the node
|
||||||
if err := c.node.Start(); err != nil {
|
if err := c.node.Start(); err != nil {
|
||||||
|
|
@ -95,6 +118,16 @@ func (c *Command) Run(args []string) int {
|
||||||
return c.handleSignals()
|
return c.handleSignals()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Command) setupMetrics() {
|
||||||
|
if !metrics.Enabled {
|
||||||
|
// metrics are globally disabled
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start system runtime metrics collection
|
||||||
|
go metrics.CollectProcessMetrics(3 * time.Second)
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Command) handleSignals() int {
|
func (c *Command) handleSignals() int {
|
||||||
signalCh := make(chan os.Signal, 4)
|
signalCh := make(chan os.Signal, 4)
|
||||||
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
signal.Notify(signalCh, os.Interrupt, syscall.SIGTERM, syscall.SIGHUP)
|
||||||
|
|
|
||||||
|
|
@ -5,11 +5,13 @@ import (
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"github.com/ethereum/go-ethereum/command/server/chains"
|
||||||
"github.com/ethereum/go-ethereum/common/fdlimit"
|
"github.com/ethereum/go-ethereum/common/fdlimit"
|
||||||
"github.com/ethereum/go-ethereum/eth/downloader"
|
"github.com/ethereum/go-ethereum/eth/downloader"
|
||||||
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
"github.com/ethereum/go-ethereum/eth/ethconfig"
|
||||||
"github.com/ethereum/go-ethereum/node"
|
"github.com/ethereum/go-ethereum/node"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
|
"github.com/ethereum/go-ethereum/p2p/enode"
|
||||||
"github.com/imdario/mergo"
|
"github.com/imdario/mergo"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -30,6 +32,8 @@ func durPtr(d time.Duration) *time.Duration {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
|
chain *chains.Chain
|
||||||
|
|
||||||
Chain *string
|
Chain *string
|
||||||
Debug *bool
|
Debug *bool
|
||||||
LogLevel *string
|
LogLevel *string
|
||||||
|
|
@ -42,14 +46,21 @@ type Config struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type P2PConfig struct {
|
type P2PConfig struct {
|
||||||
MaxPeers *uint64
|
MaxPeers *uint64
|
||||||
Bind *string
|
Bind *string
|
||||||
Port *uint64
|
Port *uint64
|
||||||
NoDiscover *bool
|
NoDiscover *bool
|
||||||
V5Disc *bool
|
V5Disc *bool
|
||||||
Bootnodes []string
|
Discovery *P2PDiscovery
|
||||||
BootnodesV4 []string
|
}
|
||||||
BootnodesV5 []string
|
|
||||||
|
type P2PDiscovery struct {
|
||||||
|
Bootnodes []string
|
||||||
|
BootnodesV4 []string
|
||||||
|
BootnodesV5 []string
|
||||||
|
StaticNodes []string
|
||||||
|
TrustedNodes []string
|
||||||
|
DNS []string
|
||||||
}
|
}
|
||||||
|
|
||||||
type TxPoolConfig struct {
|
type TxPoolConfig struct {
|
||||||
|
|
@ -79,14 +90,19 @@ func DefaultConfig() *Config {
|
||||||
LogLevel: stringPtr("INFO"),
|
LogLevel: stringPtr("INFO"),
|
||||||
DataDir: stringPtr(""),
|
DataDir: stringPtr(""),
|
||||||
P2P: &P2PConfig{
|
P2P: &P2PConfig{
|
||||||
MaxPeers: uint64Ptr(30),
|
MaxPeers: uint64Ptr(30),
|
||||||
Bind: stringPtr("0.0.0.0"),
|
Bind: stringPtr("0.0.0.0"),
|
||||||
Port: uint64Ptr(30303),
|
Port: uint64Ptr(30303),
|
||||||
NoDiscover: boolPtr(false),
|
NoDiscover: boolPtr(false),
|
||||||
V5Disc: boolPtr(false),
|
V5Disc: boolPtr(false),
|
||||||
Bootnodes: []string{},
|
Discovery: &P2PDiscovery{
|
||||||
BootnodesV4: []string{},
|
Bootnodes: []string{},
|
||||||
BootnodesV5: []string{},
|
BootnodesV4: []string{},
|
||||||
|
BootnodesV5: []string{},
|
||||||
|
StaticNodes: []string{},
|
||||||
|
TrustedNodes: []string{},
|
||||||
|
DNS: []string{},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
SyncMode: stringPtr("fast"),
|
SyncMode: stringPtr("fast"),
|
||||||
EthStats: stringPtr(""),
|
EthStats: stringPtr(""),
|
||||||
|
|
@ -113,14 +129,31 @@ func readConfigFile(path string) (*Config, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Config) loadChain() error {
|
||||||
|
chain, ok := chains.GetChain(*c.Chain)
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("chain '%s' not found", *c.Chain)
|
||||||
|
}
|
||||||
|
c.chain = chain
|
||||||
|
|
||||||
|
// preload some default values that are on the chain file
|
||||||
|
if c.P2P.Discovery.Bootnodes == nil {
|
||||||
|
c.P2P.Discovery.Bootnodes = c.chain.Bootnodes
|
||||||
|
}
|
||||||
|
if c.P2P.Discovery.DNS == nil {
|
||||||
|
c.P2P.Discovery.DNS = c.chain.DNS
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (c *Config) buildEth() (*ethconfig.Config, error) {
|
func (c *Config) buildEth() (*ethconfig.Config, error) {
|
||||||
dbHandles, err := makeDatabaseHandles()
|
dbHandles, err := makeDatabaseHandles()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
n := ethconfig.Defaults
|
n := ethconfig.Defaults
|
||||||
//n.NetworkId = c.genesis.NetworkId
|
n.NetworkId = c.chain.NetworkId
|
||||||
//n.Genesis = c.genesis.Genesis
|
n.Genesis = c.chain.Genesis
|
||||||
|
|
||||||
// txpool options
|
// txpool options
|
||||||
{
|
{
|
||||||
|
|
@ -143,6 +176,12 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
||||||
fmt.Println(cfg)
|
fmt.Println(cfg)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// discovery (this params should be in node.Config)
|
||||||
|
{
|
||||||
|
n.EthDiscoveryURLs = c.P2P.Discovery.DNS
|
||||||
|
n.SnapDiscoveryURLs = c.P2P.Discovery.DNS
|
||||||
|
}
|
||||||
|
|
||||||
var syncMode downloader.SyncMode
|
var syncMode downloader.SyncMode
|
||||||
switch *c.SyncMode {
|
switch *c.SyncMode {
|
||||||
case "fast":
|
case "fast":
|
||||||
|
|
@ -152,22 +191,12 @@ func (c *Config) buildEth() (*ethconfig.Config, error) {
|
||||||
}
|
}
|
||||||
n.SyncMode = syncMode
|
n.SyncMode = syncMode
|
||||||
n.DatabaseHandles = dbHandles
|
n.DatabaseHandles = dbHandles
|
||||||
|
|
||||||
return &n, nil
|
return &n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) buildNode() (*node.Config, error) {
|
func (c *Config) buildNode() (*node.Config, error) {
|
||||||
/*
|
cfg := &node.Config{
|
||||||
bootstrap, err := parseBootnodes(c.genesis.Bootstrap)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
static, err := parseBootnodes(c.genesis.Static)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
n := &node.Config{
|
|
||||||
Name: "reader",
|
Name: "reader",
|
||||||
DataDir: *c.DataDir,
|
DataDir: *c.DataDir,
|
||||||
P2P: p2p.Config{
|
P2P: p2p.Config{
|
||||||
|
|
@ -182,16 +211,28 @@ func (c *Config) buildNode() (*node.Config, error) {
|
||||||
WSPort: int(*c.Ports.Websocket),
|
WSPort: int(*c.Ports.Websocket),
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
if *c.NoDiscovery {
|
|
||||||
// avoid incoming connections
|
|
||||||
n.P2P.MaxPeers = 0
|
|
||||||
// avoid outgoing connections
|
|
||||||
n.P2P.NoDiscovery = true
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return n, nil
|
// Discovery
|
||||||
|
var err error
|
||||||
|
if cfg.P2P.BootstrapNodes, err = parseBootnodes(c.P2P.Discovery.Bootnodes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if cfg.P2P.BootstrapNodesV5, err = parseBootnodes(c.P2P.Discovery.BootnodesV5); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if cfg.P2P.StaticNodes, err = parseBootnodes(c.P2P.Discovery.StaticNodes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
if cfg.P2P.TrustedNodes, err = parseBootnodes(c.P2P.Discovery.TrustedNodes); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if *c.P2P.NoDiscover {
|
||||||
|
// Disable networking, for now, we will not even allow incomming connections
|
||||||
|
cfg.P2P.MaxPeers = 0
|
||||||
|
cfg.P2P.NoDiscovery = true
|
||||||
|
}
|
||||||
|
return cfg, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Config) Merge(cc ...*Config) error {
|
func (c *Config) Merge(cc ...*Config) error {
|
||||||
|
|
@ -214,3 +255,17 @@ func makeDatabaseHandles() (int, error) {
|
||||||
}
|
}
|
||||||
return int(raised / 2), nil
|
return int(raised / 2), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func parseBootnodes(urls []string) ([]*enode.Node, error) {
|
||||||
|
dst := []*enode.Node{}
|
||||||
|
for _, url := range urls {
|
||||||
|
if url != "" {
|
||||||
|
node, err := enode.Parse(enode.ValidSchemes, url)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("invalid bootstrap url '%s': %v", url, err)
|
||||||
|
}
|
||||||
|
dst = append(dst, node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dst, nil
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue