|
53 | 53 |
|
54 | 54 | using node::ReadBlockFromDisk;
|
55 | 55 | using node::ReadRawBlockFromDisk;
|
56 |
| -using node::fImporting; |
57 | 56 | using node::fPruneMode;
|
58 |
| -using node::fReindex; |
59 | 57 |
|
60 | 58 | /** How long to cache transactions in mapRelay for normal relay */
|
61 | 59 | static constexpr auto RELAY_TX_CACHE_TIME = 15min;
|
@@ -1730,8 +1728,7 @@ bool PeerManagerImpl::BlockRequestAllowed(const CBlockIndex* pindex)
|
1730 | 1728 |
|
1731 | 1729 | std::optional<std::string> PeerManagerImpl::FetchBlock(NodeId peer_id, const CBlockIndex& block_index)
|
1732 | 1730 | {
|
1733 |
| - if (fImporting) return "Importing..."; |
1734 |
| - if (fReindex) return "Reindexing..."; |
| 1731 | + if (m_chainman.m_blockman.LoadingBlocks()) return "Loading blocks ..."; |
1735 | 1732 |
|
1736 | 1733 | // Ensure this peer exists and hasn't been disconnected
|
1737 | 1734 | PeerRef peer = GetPeerRef(peer_id);
|
@@ -3679,7 +3676,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
3679 | 3676 | LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
|
3680 | 3677 |
|
3681 | 3678 | UpdateBlockAvailability(pfrom.GetId(), inv.hash);
|
3682 |
| - if (!fAlreadyHave && !fImporting && !fReindex && !IsBlockRequested(inv.hash)) { |
| 3679 | + if (!fAlreadyHave && !m_chainman.m_blockman.LoadingBlocks() && !IsBlockRequested(inv.hash)) { |
3683 | 3680 | // Headers-first is the primary method of announcement on
|
3684 | 3681 | // the network. If a node fell back to sending blocks by
|
3685 | 3682 | // inv, it may be for a re-org, or because we haven't
|
@@ -3889,7 +3886,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
3889 | 3886 | return;
|
3890 | 3887 | }
|
3891 | 3888 |
|
3892 |
| - if (fImporting || fReindex) { |
| 3889 | + if (m_chainman.m_blockman.LoadingBlocks()) { |
3893 | 3890 | LogPrint(BCLog::NET, "Ignoring getheaders from peer=%d while importing/reindexing\n", pfrom.GetId());
|
3894 | 3891 | return;
|
3895 | 3892 | }
|
@@ -4171,7 +4168,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
4171 | 4168 | if (msg_type == NetMsgType::CMPCTBLOCK)
|
4172 | 4169 | {
|
4173 | 4170 | // Ignore cmpctblock received while importing
|
4174 |
| - if (fImporting || fReindex) { |
| 4171 | + if (m_chainman.m_blockman.LoadingBlocks()) { |
4175 | 4172 | LogPrint(BCLog::NET, "Unexpected cmpctblock message received from peer %d\n", pfrom.GetId());
|
4176 | 4173 | return;
|
4177 | 4174 | }
|
@@ -4387,7 +4384,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
4387 | 4384 | if (msg_type == NetMsgType::BLOCKTXN)
|
4388 | 4385 | {
|
4389 | 4386 | // Ignore blocktxn received while importing
|
4390 |
| - if (fImporting || fReindex) { |
| 4387 | + if (m_chainman.m_blockman.LoadingBlocks()) { |
4391 | 4388 | LogPrint(BCLog::NET, "Unexpected blocktxn message received from peer %d\n", pfrom.GetId());
|
4392 | 4389 | return;
|
4393 | 4390 | }
|
@@ -4462,7 +4459,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
4462 | 4459 | if (msg_type == NetMsgType::HEADERS)
|
4463 | 4460 | {
|
4464 | 4461 | // Ignore headers received while importing
|
4465 |
| - if (fImporting || fReindex) { |
| 4462 | + if (m_chainman.m_blockman.LoadingBlocks()) { |
4466 | 4463 | LogPrint(BCLog::NET, "Unexpected headers message received from peer %d\n", pfrom.GetId());
|
4467 | 4464 | return;
|
4468 | 4465 | }
|
@@ -4507,7 +4504,7 @@ void PeerManagerImpl::ProcessMessage(CNode& pfrom, const std::string& msg_type,
|
4507 | 4504 | if (msg_type == NetMsgType::BLOCK)
|
4508 | 4505 | {
|
4509 | 4506 | // Ignore block received while importing
|
4510 |
| - if (fImporting || fReindex) { |
| 4507 | + if (m_chainman.m_blockman.LoadingBlocks()) { |
4511 | 4508 | LogPrint(BCLog::NET, "Unexpected block message received from peer %d\n", pfrom.GetId());
|
4512 | 4509 | return;
|
4513 | 4510 | }
|
@@ -5092,7 +5089,7 @@ void PeerManagerImpl::CheckForStaleTipAndEvictPeers()
|
5092 | 5089 | if (now > m_stale_tip_check_time) {
|
5093 | 5090 | // Check whether our tip is stale, and if so, allow using an extra
|
5094 | 5091 | // outbound peer
|
5095 |
| - if (!fImporting && !fReindex && m_connman.GetNetworkActive() && m_connman.GetUseAddrmanOutgoing() && TipMayBeStale()) { |
| 5092 | + if (!m_chainman.m_blockman.LoadingBlocks() && m_connman.GetNetworkActive() && m_connman.GetUseAddrmanOutgoing() && TipMayBeStale()) { |
5096 | 5093 | LogPrintf("Potential stale tip detected, will try using extra outbound peer (last tip update: %d seconds ago)\n",
|
5097 | 5094 | count_seconds(now - m_last_tip_update.load()));
|
5098 | 5095 | m_connman.SetTryNewOutboundPeer(true);
|
@@ -5399,7 +5396,7 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
5399 | 5396 | }
|
5400 | 5397 | }
|
5401 | 5398 |
|
5402 |
| - if (!state.fSyncStarted && CanServeBlocks(*peer) && !fImporting && !fReindex) { |
| 5399 | + if (!state.fSyncStarted && CanServeBlocks(*peer) && !m_chainman.m_blockman.LoadingBlocks()) { |
5403 | 5400 | // Only actively request headers from a single peer, unless we're close to today.
|
5404 | 5401 | if ((nSyncStarted == 0 && sync_blocks_and_headers_from_peer) || m_chainman.m_best_header->Time() > GetAdjustedTime() - 24h) {
|
5405 | 5402 | const CBlockIndex* pindexStart = m_chainman.m_best_header;
|
|
0 commit comments