From 5f9696437f1fd52473cd002f2cea79516ca8d011 Mon Sep 17 00:00:00 2001 From: Pablo Greco Date: Thu, 23 Dec 2021 11:06:34 +0000 Subject: [PATCH] Remove block from in-flight list when a duplicate is received --- src/net_processing.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 042b58474a..cdb8795b7d 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3213,8 +3213,13 @@ void PeerManager::ProcessMessage(CNode& pfrom, const std::string& msg_type, CDat std::map::iterator> >::iterator blockInFlightIt = mapBlocksInFlight.find(pindex->GetBlockHash()); bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end(); - if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here + if (pindex->nStatus & BLOCK_HAVE_DATA) { + // Nothing to do here in bitcoin, elements needs to check if it obtained the block another way (submitblock) + if(MarkBlockAsReceived(pindex->GetBlockHash())) { + LogPrint(BCLog::NET, "Removed block %s from in-flight list because it was already downloaded\n", pindex->GetBlockHash().ToString()); + } return; + } if (pindex->nChainWork <= ::ChainActive().Tip()->nChainWork || // We know something better pindex->nTx != 0) { // We had this block at some point, but pruned it