@@ -312,7 +312,7 @@ class PeerManagerImpl final : public PeerManager
312
312
/* * Implement PeerManager */
313
313
void StartScheduledTasks (CScheduler& scheduler) override ;
314
314
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 ;
316
316
bool GetNodeStateStats (NodeId nodeid, CNodeStateStats& stats) const override ;
317
317
bool IgnoresIncomingTxs () override { return m_ignore_incoming_txs; }
318
318
void SendPings () override ;
@@ -1428,21 +1428,22 @@ bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)
1428
1428
(GetBlockProofEquivalentTime (*pindexBestHeader, *pindex, *pindexBestHeader, m_chainparams.GetConsensus ()) < STALE_RELAY_AGE_LIMIT);
1429
1429
}
1430
1430
1431
- bool PeerManagerImpl::FetchBlock (NodeId id, const CBlockIndex& block_index)
1431
+ std::optional<std::string> PeerManagerImpl::FetchBlock (NodeId id, const CBlockIndex& block_index)
1432
1432
{
1433
- if (fImporting || fReindex ) return false ;
1433
+ if (fImporting ) return " Importing..." ;
1434
+ if (fReindex ) return " Reindexing..." ;
1434
1435
1435
1436
LOCK (cs_main);
1436
1437
// Ensure this peer exists and hasn't been disconnected
1437
1438
CNodeState* state = State (id);
1438
- if (state == nullptr ) return false ;
1439
+ if (state == nullptr ) return " Peer does not exist " ;
1439
1440
// Ignore pre-segwit peers
1440
- if (!state->fHaveWitness ) return false ;
1441
+ if (!state->fHaveWitness ) return " Pre-SegWit peer " ;
1441
1442
1442
1443
// Mark block as in-flight unless it already is (for this peer).
1443
1444
// If a block was already in-flight for a different peer, its BLOCKTXN
1444
1445
// response will be dropped.
1445
- if (!BlockRequested (id, block_index)) return false ;
1446
+ if (!BlockRequested (id, block_index)) return " Already requested from this peer " ;
1446
1447
1447
1448
// Construct message to request the block
1448
1449
const uint256& hash{block_index.GetBlockHash ()};
@@ -1455,15 +1456,11 @@ bool PeerManagerImpl::FetchBlock(NodeId id, const CBlockIndex& block_index)
1455
1456
return true ;
1456
1457
});
1457
1458
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 " ,
1464
1462
hash.ToString (), id);
1465
- }
1466
- return success;
1463
+ return std::nullopt;
1467
1464
}
1468
1465
1469
1466
std::unique_ptr<PeerManager> PeerManager::make (const CChainParams& chainparams, CConnman& connman, AddrMan& addrman,
0 commit comments