From 8e044b0e6ddee561a7aed99d2346db5ba44efb69 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Thu, 16 Nov 2017 04:30:23 +0000 Subject: [PATCH] p2p/addrbook: some comments --- p2p/addrbook.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/p2p/addrbook.go b/p2p/addrbook.go index 1101ffeef..00b7ef759 100644 --- a/p2p/addrbook.go +++ b/p2p/addrbook.go @@ -237,6 +237,7 @@ func (a *AddrBook) PickAddress(newBias int) *NetAddress { } // MarkGood marks the peer as good and moves it into an "old" bucket. +// XXX: we never call this! func (a *AddrBook) MarkGood(addr *NetAddress) { a.mtx.Lock() defer a.mtx.Unlock() @@ -304,6 +305,7 @@ func (a *AddrBook) GetSelection() []*NetAddress { // Fisher-Yates shuffle the array. We only need to do the first // `numAddresses' since we are throwing the rest. + // XXX: What's the point of this if we already loop randomly through addrLookup ? for i := 0; i < numAddresses; i++ { // pick a number between current index and the end j := rand.Intn(len(allAddr)-i) + i @@ -400,17 +402,17 @@ func (a *AddrBook) Save() { func (a *AddrBook) saveRoutine() { defer a.wg.Done() - dumpAddressTicker := time.NewTicker(dumpAddressInterval) + saveFileTicker := time.NewTicker(dumpAddressInterval) out: for { select { - case <-dumpAddressTicker.C: + case <-saveFileTicker.C: a.saveToFile(a.filePath) case <-a.Quit: break out } } - dumpAddressTicker.Stop() + saveFileTicker.Stop() a.saveToFile(a.filePath) a.Logger.Info("Address handler done") }