From 753cb1563b688bf24888c233700591860a65c2a0 Mon Sep 17 00:00:00 2001 From: "Wladimir J. van der Laan" Date: Thu, 14 Apr 2016 17:54:40 +0200 Subject: [PATCH] Merge #7874: Improve AlreadyHave c6cb6f7 Avoid unnecessary database access for unknown transactions (Alex Morcos) --- src/net_processing.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index d98675975..ebfd673b4 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -691,10 +691,12 @@ bool static AlreadyHave(const CInv& inv) EXCLUSIVE_LOCKS_REQUIRED(cs_main) recentRejects->reset(); } + // Use pcoinsTip->HaveCoinsInCache as a quick approximation to exclude + // requesting or processing some txs which have already been included in a block return recentRejects->contains(inv.hash) || mempool.exists(inv.hash) || mapOrphanTransactions.count(inv.hash) || - pcoinsTip->HaveCoins(inv.hash); + pcoinsTip->HaveCoinsInCache(inv.hash); } case MSG_BLOCK: