addrmgr: skip never-successful addresses

A node that has never been successfully connected should not be
announced.  Also, change maxFailures from 10 to a more conservative 5.
This commit is contained in:
David Hill 2018-06-21 22:58:43 -04:00 committed by Dave Collins
parent d3731898e9
commit 4bbb9bc414
2 changed files with 7 additions and 3 deletions

View File

@ -143,14 +143,14 @@ const (
// maxFailures is the maximum number of failures we will accept without
// a success before considering an address bad.
maxFailures = 10
maxFailures = 5
// minBadDays is the number of days since the last success before we
// will consider evicting an address.
minBadDays = 7
// getAddrMax is the most addresses that we will send in response
// to a getAddr (in practise the most addresses we will return from a
// to a getAddr (in practice the most addresses we will return from a
// call to AddressCache()).
getAddrMax = 2500
@ -668,6 +668,10 @@ func (a *AddrManager) AddressCache() []*wire.NetAddress {
if v.isBad() {
continue
}
// Skip addresses that never succeeded.
if v.lastsuccess.IsZero() {
continue
}
allAddr = append(allAddr, v.na)
}

View File

@ -73,7 +73,7 @@ func (ka *KnownAddress) chance() float64 {
// 1) It claims to be from the future
// 2) It hasn't been seen in over a month
// 3) It has failed at least three times and never succeeded
// 4) It has failed ten times in the last week
// 4) It has failed a total of maxFailures in the last week
// All addresses that meet these criteria are assumed to be worthless and not
// worth keeping hold of.
func (ka *KnownAddress) isBad() bool {