mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
alias BlockDownloadMap for mapBlocksInFlight
This commit is contained in:
parent
ccc431d53e
commit
86cff8bf18
1 changed files with 6 additions and 5 deletions
|
@ -899,7 +899,8 @@ private:
|
||||||
*/
|
*/
|
||||||
void FindNextBlocksToDownload(const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
void FindNextBlocksToDownload(const Peer& peer, unsigned int count, std::vector<const CBlockIndex*>& vBlocks, NodeId& nodeStaller) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
|
||||||
|
|
||||||
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> > mapBlocksInFlight GUARDED_BY(cs_main);
|
typedef std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator>> BlockDownloadMap;
|
||||||
|
BlockDownloadMap mapBlocksInFlight GUARDED_BY(cs_main);
|
||||||
|
|
||||||
/** When our tip was last updated. */
|
/** When our tip was last updated. */
|
||||||
std::atomic<std::chrono::seconds> m_last_tip_update{0s};
|
std::atomic<std::chrono::seconds> m_last_tip_update{0s};
|
||||||
|
@ -1117,7 +1118,7 @@ std::chrono::microseconds PeerManagerImpl::NextInvToInbounds(std::chrono::micros
|
||||||
|
|
||||||
bool PeerManagerImpl::IsBlockRequested(const uint256& hash)
|
bool PeerManagerImpl::IsBlockRequested(const uint256& hash)
|
||||||
{
|
{
|
||||||
return mapBlocksInFlight.find(hash) != mapBlocksInFlight.end();
|
return mapBlocksInFlight.count(hash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PeerManagerImpl::RemoveBlockRequest(const uint256& hash, std::optional<NodeId> from_peer)
|
void PeerManagerImpl::RemoveBlockRequest(const uint256& hash, std::optional<NodeId> from_peer)
|
||||||
|
@ -1161,7 +1162,7 @@ bool PeerManagerImpl::BlockRequested(NodeId nodeid, const CBlockIndex& block, st
|
||||||
assert(state != nullptr);
|
assert(state != nullptr);
|
||||||
|
|
||||||
// Short-circuit most stuff in case it is from the same node
|
// Short-circuit most stuff in case it is from the same node
|
||||||
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator itInFlight = mapBlocksInFlight.find(hash);
|
BlockDownloadMap::iterator itInFlight = mapBlocksInFlight.find(hash);
|
||||||
if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
|
if (itInFlight != mapBlocksInFlight.end() && itInFlight->second.first == nodeid) {
|
||||||
if (pit) {
|
if (pit) {
|
||||||
*pit = &itInFlight->second.second;
|
*pit = &itInFlight->second.second;
|
||||||
|
@ -4274,7 +4275,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
nodestate->m_last_block_announcement = GetTime();
|
nodestate->m_last_block_announcement = GetTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator blockInFlightIt = mapBlocksInFlight.find(pindex->GetBlockHash());
|
BlockDownloadMap::iterator blockInFlightIt = mapBlocksInFlight.find(pindex->GetBlockHash());
|
||||||
bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end();
|
bool fAlreadyInFlight = blockInFlightIt != mapBlocksInFlight.end();
|
||||||
|
|
||||||
if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here
|
if (pindex->nStatus & BLOCK_HAVE_DATA) // Nothing to do here
|
||||||
|
@ -4433,7 +4434,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
||||||
{
|
{
|
||||||
LOCK(cs_main);
|
LOCK(cs_main);
|
||||||
|
|
||||||
std::map<uint256, std::pair<NodeId, std::list<QueuedBlock>::iterator> >::iterator it = mapBlocksInFlight.find(resp.blockhash);
|
BlockDownloadMap::iterator it = mapBlocksInFlight.find(resp.blockhash);
|
||||||
if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock ||
|
if (it == mapBlocksInFlight.end() || !it->second.second->partialBlock ||
|
||||||
it->second.first != pfrom.GetId()) {
|
it->second.first != pfrom.GetId()) {
|
||||||
LogPrint(BCLog::NET, "Peer %d sent us block transactions for block we weren't expecting\n", pfrom.GetId());
|
LogPrint(BCLog::NET, "Peer %d sent us block transactions for block we weren't expecting\n", pfrom.GetId());
|
||||||
|
|
Loading…
Add table
Reference in a new issue