From 52f41459d53f9331f6c80fdd5737f706bdc31dbd Mon Sep 17 00:00:00 2001 From: Brannon King Date: Fri, 24 Sep 2021 10:58:55 -0400 Subject: [PATCH] fixed unnecessary peer disconnect --- server.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/server.go b/server.go index 0e57f622..6d1c20ec 100644 --- a/server.go +++ b/server.go @@ -1330,24 +1330,26 @@ func (sp *serverPeer) OnNotFound(p *peer.Peer, msg *wire.MsgNotFound) { case wire.InvTypeWitnessTx: numTxns++ default: - peerLog.Debugf("Invalid inv type '%d' in notfound message from %s", - inv.Type, sp) + peerLog.Infof("Invalid inv type '%d' in NotFound message from %s. Disconnecting...", inv.Type, sp) sp.Disconnect() return } } if numBlocks > 0 { blockStr := pickNoun(uint64(numBlocks), "block", "blocks") - reason := fmt.Sprintf("%d %v not found", numBlocks, blockStr) - if sp.addBanScore(20*numBlocks, 0, reason) { - return + reason := fmt.Sprintf("%d %v not found on %s", numBlocks, blockStr, sp) + if sp.addBanScore(20, 0, reason) { + return // once they fail to return us five block requests they're gone for good } } if numTxns > 0 { + // This is an expected situation if transactions in the mempool make it into a block before + // this node knows about said block. We don't want to ban them for that alone + peerLog.Debugf("%d transactions not found on %s", numTxns, sp) txStr := pickNoun(uint64(numTxns), "transaction", "transactions") - reason := fmt.Sprintf("%d %v not found", numBlocks, txStr) - if sp.addBanScore(0, 10*numTxns, reason) { - return + reason := fmt.Sprintf("%d %v not found on %s", numTxns, txStr, sp) + if sp.addBanScore(0, 25, reason) { + return // if they fail us four times in one minute, they're gone -- hitting them at new-block should be rare } }