From 4291823cc4a72ceb8bb31cd515ded38ef84ef125 Mon Sep 17 00:00:00 2001 From: Yahtoo Ma Date: Sun, 22 Apr 2018 13:36:54 +0800 Subject: [PATCH] Add peer start dial seeds function --- p2p/switch.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/p2p/switch.go b/p2p/switch.go index f009929d..d2f8f0f0 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -329,6 +329,12 @@ func (sw *Switch) DialSeeds(addrBook *AddrBook, seeds []string) error { addrBook.Save() } + //permute the list, dial them in random order. + perm := rand.Perm(len(netAddrs)) + for i := 0; i < len(perm)/2; i++ { + j := perm[i] + sw.dialSeed(netAddrs[j]) + } return nil } -- 2.11.0