Modify getblocktxn handler not to drop requests for old blocks
This commit is contained in:
committed by
lateminer
parent
e13c064eec
commit
dc8f0bd8de
14
src/main.cpp
14
src/main.cpp
@@ -5453,7 +5453,19 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
}
|
||||
|
||||
if (it->second->nHeight < chainActive.Height() - MAX_BLOCKTXN_DEPTH) {
|
||||
// If an older block is requested (should never happen in practice,
|
||||
// but can happen in tests) send a block response instead of a
|
||||
// blocktxn response. Sending a full block response instead of a
|
||||
// small blocktxn response is preferable in the case where a peer
|
||||
// might maliciously send lots of getblocktxn requests to trigger
|
||||
// expensive disk reads, because it will require the peer to
|
||||
// actually receive all the data read from disk over the network.
|
||||
LogPrint("net", "Peer %d sent us a getblocktxn for a block > %i deep", pfrom->id, MAX_BLOCKTXN_DEPTH);
|
||||
CInv inv;
|
||||
inv.type = MSG_BLOCK;
|
||||
inv.hash = req.blockhash;
|
||||
pfrom->vRecvGetData.push_back(inv);
|
||||
ProcessGetData(pfrom, chainparams.GetConsensus());
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -5768,7 +5780,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
|
||||
if (!fAlreadyInFlight && mapBlocksInFlight.size() == 1 && pindex->pprev->IsValid(BLOCK_VALID_CHAIN)) {
|
||||
// We seem to be rather well-synced, so it appears pfrom was the first to provide us
|
||||
// with this block! Let's get them to announce using compact blocks in the future.
|
||||
MaybeSetPeerAsAnnouncingHeaderAndIDs(nodestate, pfrom, connman);
|
||||
MaybeSetPeerAsAnnouncingHeaderAndIDs(nodestate, pfrom);
|
||||
}
|
||||
|
||||
BlockTransactionsRequest req;
|
||||
|
||||
Reference in New Issue
Block a user