Force re-requesting of IS locked TXs

This commit is contained in:
Alexander Block 2020-04-07 13:23:29 +02:00
parent ef14b19f05
commit 4bfc20cb67
3 changed files with 11 additions and 5 deletions

View File

@ -1345,7 +1345,7 @@ void CInstantSendManager::AskNodesForLockedTx(const uint256& txid)
txid.ToString(), pnode->GetId());
CInv inv(MSG_TX, txid);
RequestObject(pnode->GetId(), inv, GetTimeMicros());
RequestObject(pnode->GetId(), inv, GetTimeMicros(), true);
}
}
for (CNode* pnode : nodesToAskFor) {

View File

@ -736,7 +736,7 @@ int64_t CalculateObjectGetDataTime(const CInv& inv, int64_t current_time, bool u
return process_time;
}
void RequestObject(CNodeState* state, const CInv& inv, int64_t nNow) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void RequestObject(CNodeState* state, const CInv& inv, int64_t nNow, bool fForce = false) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
AssertLockHeld(cs_main);
CNodeState::TxDownloadState& peer_download_state = state->m_tx_download;
@ -754,16 +754,22 @@ void RequestObject(CNodeState* state, const CInv& inv, int64_t nNow) EXCLUSIVE_L
int64_t process_time = CalculateObjectGetDataTime(inv, nNow, !state->fPreferredDownload);
peer_download_state.m_tx_process_time.emplace(process_time, inv);
if (fForce) {
// make sure this object is actually requested ASAP
g_erased_object_requests.erase(inv.hash);
g_already_asked_for.erase(inv.hash);
}
}
void RequestObject(NodeId nodeId, const CInv& inv, int64_t nNow) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
void RequestObject(NodeId nodeId, const CInv& inv, int64_t nNow, bool fForce) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
{
AssertLockHeld(cs_main);
auto* state = State(nodeId);
if (!state) {
return;
}
RequestObject(state, inv, nNow);
RequestObject(state, inv, nNow, fForce);
}
size_t GetRequestedObjectCount(NodeId nodeId)

View File

@ -85,7 +85,7 @@ void Misbehaving(NodeId nodeid, int howmuch, const std::string& message="");
bool IsBanned(NodeId nodeid);
void EraseObjectRequest(const uint256& hash);
void RequestObject(NodeId nodeId, const CInv& inv, int64_t nNow);
void RequestObject(NodeId nodeId, const CInv& inv, int64_t nNow, bool fForce=false);
size_t GetRequestedObjectCount(NodeId nodeId);
#endif // BITCOIN_NET_PROCESSING_H