From 88eb3e7af0b63b3bc059453d95f501789e399730 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Sun, 14 Jan 2018 01:40:29 -0500 Subject: [PATCH] some minor renames --- p2p/pex_reactor.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/p2p/pex_reactor.go b/p2p/pex_reactor.go index 7313f7d56..0c3567a35 100644 --- a/p2p/pex_reactor.go +++ b/p2p/pex_reactor.go @@ -21,6 +21,11 @@ const ( defaultEnsurePeersPeriod = 30 * time.Second minNumOutboundPeers = 10 maxPexMessageSize = 1048576 // 1MB + + // Seed/Crawler constants + defaultSeedDisconnectWaitPeriod = 2 * time.Minute + defaultCrawlPeerInterval = 2 * time.Minute + defaultCrawlPeersPeriod = 30 * time.Second ) // PEXReactor handles PEX (peer exchange) and ensures that an @@ -79,7 +84,13 @@ func (r *PEXReactor) OnStart() error { return err } - go r.ensurePeersRoutine() + // Check if this node should run + // in seed/crawler mode + if r.config.SeedMode { + go r.crawlPeersRoutine() + } else { + go r.ensurePeersRoutine() + } return nil } @@ -338,7 +349,7 @@ func (r *PEXReactor) checkSeeds() error { // Explores the network searching for more peers. (continuous) // Seed/Crawler Mode causes this node to quickly disconnect // from peers, except other seed nodes. -func (r *PEXReactor) seedCrawlerMode() { +func (r *PEXReactor) crawlPeersRoutine() { // Do an initial crawl r.crawlPeers()