diff --git a/config/bootstrap.json b/config/bootstrap.json new file mode 100644 index 000000000..65197dc9c --- /dev/null +++ b/config/bootstrap.json @@ -0,0 +1,26 @@ +[ + { + "name": "Pactus", + "email": "info@pactus.org", + "website": "https://pactus.org", + "address": "/dns/bootstrap1.pactus.org/tcp/21888/p2p/12D3KooWMnDsu8TDTk2VV8uD8zsNSB6eUkqtQs6ttg4bHq9zNaBe" + }, + { + "name": "Pactus", + "email": "info@pactus.org", + "website": "https://pactus.org", + "address": "/dns/bootstrap2.pactus.org/tcp/21888/p2p/12D3KooWM39ag7ghta49qybf7McADgT8FLakTYkCsiBvwdnjuG5q" + }, + { + "name": "Pactus", + "email": "info@pactus.org", + "website": "https://pactus.org", + "address": "/dns/bootstrap3.pactus.org/tcp/21888/p2p/12D3KooWBCPSZWheet6tMoHbVBCDfBwQm4yzCwcQ8hJ6NMCN97sj" + }, + { + "name": "Pactus", + "email": "info@pactus.org", + "website": "https://pactus.org", + "address": "/dns/bootstrap4.pactus.org/tcp/21888/p2p/12D3KooWKg6aLa77yAaqMCb45aH5iQuTr5GzRUWUCJ1sZYB5vnoL" + } +] diff --git a/config/config.go b/config/config.go index cdd21a116..546ff9210 100644 --- a/config/config.go +++ b/config/config.go @@ -3,6 +3,7 @@ package config import ( "bytes" _ "embed" + "encoding/json" "os" "github.com/pactus-project/pactus/consensus" @@ -20,8 +21,13 @@ import ( "github.com/pelletier/go-toml" ) -//go:embed example_config.toml -var exampleConfigBytes []byte +var ( + //go:embed example_config.toml + exampleConfigBytes []byte + + //go:embed bootstrap.json + bootstrapInfosBytes []byte +) type Config struct { Node *NodeConfig `toml:"node"` @@ -36,6 +42,13 @@ type Config struct { Nanomsg *nanomsg.Config `toml:"nanomsg"` } +type BootstrapInfo struct { + Name string `json:"name"` + Email string `json:"email"` + Website string `json:"website"` + Address string `json:"address"` +} + type NodeConfig struct { RewardAddresses []string `toml:"reward_addresses"` } @@ -79,12 +92,16 @@ func defaultConfig() *Config { func DefaultConfigMainnet() *Config { conf := defaultConfig() - conf.Network.DefaultBootstrapAddrStrings = []string{ - "/dns/bootstrap1.pactus.org/tcp/21888/p2p/12D3KooWMnDsu8TDTk2VV8uD8zsNSB6eUkqtQs6ttg4bHq9zNaBe", - "/dns/bootstrap2.pactus.org/tcp/21888/p2p/12D3KooWM39ag7ghta49qybf7McADgT8FLakTYkCsiBvwdnjuG5q", - "/dns/bootstrap3.pactus.org/tcp/21888/p2p/12D3KooWBCPSZWheet6tMoHbVBCDfBwQm4yzCwcQ8hJ6NMCN97sj", - "/dns/bootstrap4.pactus.org/tcp/21888/p2p/12D3KooWKg6aLa77yAaqMCb45aH5iQuTr5GzRUWUCJ1sZYB5vnoL", + + bootstrapNodes := make([]BootstrapInfo, 0) + if err := json.Unmarshal(bootstrapInfosBytes, &bootstrapNodes); err != nil { + panic(err) + } + + for _, node := range bootstrapNodes { + conf.Network.DefaultBootstrapAddrStrings = append(conf.Network.DefaultBootstrapAddrStrings, node.Address) } + conf.Network.MaxConns = 64 conf.Network.EnableNATService = false conf.Network.EnableUPnP = false