|
|
|
@ -334,7 +334,7 @@ bool MarkBlockAsReceived(const uint256& hash) {
@@ -334,7 +334,7 @@ bool MarkBlockAsReceived(const uint256& hash) {
|
|
|
|
|
// Requires cs_main.
|
|
|
|
|
// returns false, still setting pit, if the block was already in flight from the same peer
|
|
|
|
|
// pit will only be valid as long as the same cs_main lock is being held
|
|
|
|
|
bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const Consensus::Params& consensusParams, const CBlockIndex* pindex = NULL, std::list<QueuedBlock>::iterator** pit = NULL) { |
|
|
|
|
bool MarkBlockAsInFlight(NodeId nodeid, const uint256& hash, const CBlockIndex* pindex = NULL, std::list<QueuedBlock>::iterator** pit = NULL) { |
|
|
|
|
CNodeState *state = State(nodeid); |
|
|
|
|
assert(state != NULL); |
|
|
|
|
|
|
|
|
@ -2060,7 +2060,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
@@ -2060,7 +2060,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|
|
|
|
if ((!fAlreadyInFlight && nodestate->nBlocksInFlight < MAX_BLOCKS_IN_TRANSIT_PER_PEER) || |
|
|
|
|
(fAlreadyInFlight && blockInFlightIt->second.first == pfrom->GetId())) { |
|
|
|
|
std::list<QueuedBlock>::iterator* queuedBlockIt = NULL; |
|
|
|
|
if (!MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), chainparams.GetConsensus(), pindex, &queuedBlockIt)) { |
|
|
|
|
if (!MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), pindex, &queuedBlockIt)) { |
|
|
|
|
if (!(*queuedBlockIt)->partialBlock) |
|
|
|
|
(*queuedBlockIt)->partialBlock.reset(new PartiallyDownloadedBlock(&mempool)); |
|
|
|
|
else { |
|
|
|
@ -2364,7 +2364,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
@@ -2364,7 +2364,7 @@ bool static ProcessMessage(CNode* pfrom, const std::string& strCommand, CDataStr
|
|
|
|
|
} |
|
|
|
|
uint32_t nFetchFlags = GetFetchFlags(pfrom); |
|
|
|
|
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash())); |
|
|
|
|
MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), chainparams.GetConsensus(), pindex); |
|
|
|
|
MarkBlockAsInFlight(pfrom->GetId(), pindex->GetBlockHash(), pindex); |
|
|
|
|
LogPrint(BCLog::NET, "Requesting block %s from peer=%d\n", |
|
|
|
|
pindex->GetBlockHash().ToString(), pfrom->GetId()); |
|
|
|
|
} |
|
|
|
@ -3219,7 +3219,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
@@ -3219,7 +3219,7 @@ bool SendMessages(CNode* pto, CConnman& connman, const std::atomic<bool>& interr
|
|
|
|
|
BOOST_FOREACH(const CBlockIndex *pindex, vToDownload) { |
|
|
|
|
uint32_t nFetchFlags = GetFetchFlags(pto); |
|
|
|
|
vGetData.push_back(CInv(MSG_BLOCK | nFetchFlags, pindex->GetBlockHash())); |
|
|
|
|
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), consensusParams, pindex); |
|
|
|
|
MarkBlockAsInFlight(pto->GetId(), pindex->GetBlockHash(), pindex); |
|
|
|
|
LogPrint(BCLog::NET, "Requesting block %s (%d) peer=%d\n", pindex->GetBlockHash().ToString(), |
|
|
|
|
pindex->nHeight, pto->GetId()); |
|
|
|
|
} |
|
|
|
|