@@ -312,7 +312,7 @@ class PeerManagerImpl final : public PeerManager
312312 /* * Implement PeerManager */
313313 void StartScheduledTasks (CScheduler& scheduler) override ;
314314 void CheckForStaleTipAndEvictPeers () override ;
315- bool FetchBlock (NodeId id, const CBlockIndex& block_index) override ;
315+ std::optional<std::string> FetchBlock (NodeId id, const CBlockIndex& block_index) override ;
316316 bool GetNodeStateStats (NodeId nodeid, CNodeStateStats& stats) const override ;
317317 bool IgnoresIncomingTxs () override { return m_ignore_incoming_txs; }
318318 void SendPings () override ;
@@ -1428,21 +1428,22 @@ bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)
14281428 (GetBlockProofEquivalentTime (*pindexBestHeader, *pindex, *pindexBestHeader, m_chainparams.GetConsensus ()) < STALE_RELAY_AGE_LIMIT);
14291429}
14301430
1431- bool PeerManagerImpl::FetchBlock (NodeId id, const CBlockIndex& block_index)
1431+ std::optional<std::string> PeerManagerImpl::FetchBlock (NodeId id, const CBlockIndex& block_index)
14321432{
1433- if (fImporting || fReindex ) return false ;
1433+ if (fImporting ) return " Importing..." ;
1434+ if (fReindex ) return " Reindexing..." ;
14341435
14351436 LOCK (cs_main);
14361437 // Ensure this peer exists and hasn't been disconnected
14371438 CNodeState* state = State (id);
1438- if (state == nullptr ) return false ;
1439+ if (state == nullptr ) return " Peer does not exist " ;
14391440 // Ignore pre-segwit peers
1440- if (!state->fHaveWitness ) return false ;
1441+ if (!state->fHaveWitness ) return " Pre-SegWit peer " ;
14411442
14421443 // Mark block as in-flight unless it already is (for this peer).
14431444 // If a block was already in-flight for a different peer, its BLOCKTXN
14441445 // response will be dropped.
1445- if (!BlockRequested (id, block_index)) return false ;
1446+ if (!BlockRequested (id, block_index)) return " Already requested from this peer " ;
14461447
14471448 // Construct message to request the block
14481449 const uint256& hash{block_index.GetBlockHash ()};
@@ -1455,15 +1456,11 @@ bool PeerManagerImpl::FetchBlock(NodeId id, const CBlockIndex& block_index)
14551456 return true ;
14561457 });
14571458
1458- if (success) {
1459- LogPrint (BCLog::NET, " Requesting block %s from peer=%d\n " ,
1460- hash.ToString (), id);
1461- } else {
1462- RemoveBlockRequest (hash);
1463- LogPrint (BCLog::NET, " Failed to request block %s from peer=%d\n " ,
1459+ if (!success) return " Node not fully connected" ;
1460+
1461+ LogPrint (BCLog::NET, " Requesting block %s from peer=%d\n " ,
14641462 hash.ToString (), id);
1465- }
1466- return success;
1463+ return std::nullopt ;
14671464}
14681465
14691466std::unique_ptr<PeerManager> PeerManager::make (const CChainParams& chainparams, CConnman& connman, AddrMan& addrman,
0 commit comments