diff --git a/blockchain/pool.go b/blockchain/pool.go index 07d4a7705..7b4e2145a 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -21,7 +21,7 @@ const ( // numTotal = numPending + blocks in the pool we havnt synced yet var ( - requestTimeoutSeconds = time.Duration(1) + requestTimeoutSeconds = time.Duration(3) ) /* diff --git a/blockchain/reactor.go b/blockchain/reactor.go index 62d398cc8..971c72a36 100644 --- a/blockchain/reactor.go +++ b/blockchain/reactor.go @@ -24,7 +24,8 @@ const ( trySyncIntervalMS = 100 // stop syncing when last block's time is // within this much of the system time. - stopSyncingDurationMinutes = 10 + // stopSyncingDurationMinutes = 10 + // ask for best height every 10s statusUpdateIntervalSeconds = 10 // check if we should switch to consensus reactor diff --git a/config/config.go b/config/config.go index 1c5462f0d..121861a7d 100644 --- a/config/config.go +++ b/config/config.go @@ -39,7 +39,11 @@ Moniker = "anonymous" Network = "tendermint_testnet3" ListenAddr = "0.0.0.0:46656" # First node to connect to. Command-line overridable. -SeedNode = "188.166.55.222:46656" +SeedNode = "" +# Pool of seeds. Best to use these, and specify one on command line +# if needed to override +SeedNodes = ["navytoad.chaintest.net:46656", "whiteferret.chaintest.net:46656", "magentagriffin.chaintest.net:46656", "greensalamander.chaintest.net:46656", "blackshadow.chaintest.net:46656", "purpleanteater.chaintest.net:46656", "pinkpenguin.chaintest.net:46656", "polkapig.chaintest.net:46656", "128.199.230.153:8080"] + [DB] # The only other available backend is "memdb" @@ -153,7 +157,7 @@ func Init(rootDir string) { } // Confused? - // app.Debug() + //app.Debug() } // Check if a file exists; if not, ensure the directory is made and write the file @@ -182,7 +186,7 @@ func ParseFlags(args []string) { // Declare flags flags.BoolVar(&printHelp, "help", false, "Print this help message.") flags.String("listen_addr", app.GetString("ListenAddr"), "Listen address. (0.0.0.0:0 means any interface, any port)") - flags.String("seed_node", app.GetString("SeedNode"), "Address of seed node") + flags.String("seed_node", app.GetString("SeedNode"), "Address of seed nodes") flags.String("rpc_http_listen_addr", app.GetString("RPC.HTTP.ListenAddr"), "RPC listen address. Port required") flags.Bool("fast_sync", app.GetBool("FastSync"), "Fast blockchain syncing") flags.String("log_stdout_level", app.GetString("Log.Stdout.Level"), "Stdout log level") diff --git a/node/node.go b/node/node.go index 52e2d26fd..3bbd2897f 100644 --- a/node/node.go +++ b/node/node.go @@ -1,6 +1,7 @@ package node import ( + "math/rand" "net" "net/http" "os" @@ -143,7 +144,26 @@ func (n *Node) AddListener(l p2p.Listener) { } func (n *Node) DialSeed() { - addr := p2p.NewNetAddressString(config.App().GetString("SeedNode")) + // if the single seed node is available, use only it + prioritySeed := config.App().GetString("SeedNode") + if prioritySeed != "" { + addr := p2p.NewNetAddressString(prioritySeed) + n.dialSeed(addr) + return + } + + // permute the list, dial half of them + seeds := config.App().GetStringSlice("SeedNodes") + perm := rand.Perm(len(seeds)) + // TODO: we shouldn't necessarily connect to all of them every time ... + for i := 0; i < len(perm); i++ { + j := perm[i] + addr := p2p.NewNetAddressString(seeds[j]) + n.dialSeed(addr) + } +} + +func (n *Node) dialSeed(addr *p2p.NetAddress) { peer, err := n.sw.DialPeerWithAddress(addr) if err != nil { log.Error("Error dialing seed", "error", err) @@ -221,7 +241,7 @@ func RunNode() { n.Start() // If seedNode is provided by config, dial out. - if config.App().GetString("SeedNode") != "" { + if config.App().GetString("SeedNode") != "" || len(config.App().GetStringSlice("SeedNodes")) != 0 { n.DialSeed() }