Skip to content

Commit eb91835

Browse files
committed
Add setter for g_initial_block_download_completed
1 parent 3f56df5 commit eb91835

File tree

3 files changed

+17
-9
lines changed

3 files changed

+17
-9
lines changed

src/net_processing.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ void PeerLogicValidation::UpdatedBlockTip(const CBlockIndex *pindexNew, const CB
892892
const int nNewHeight = pindexNew->nHeight;
893893
connman->SetBestHeight(nNewHeight);
894894

895-
g_initial_block_download_completed = !fInitialDownload;
895+
SetServiceFlagsIBDCache(!fInitialDownload);
896896
if (!fInitialDownload) {
897897
// Find the hashes of all blocks that weren't previously in the best chain.
898898
std::vector<uint256> vHashes;

src/protocol.cpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# include <arpa/inet.h>
1313
#endif
1414

15-
std::atomic<bool> g_initial_block_download_completed(false);
15+
static std::atomic<bool> g_initial_block_download_completed(false);
1616

1717
namespace NetMsgType {
1818
const char *VERSION="version";
@@ -129,6 +129,17 @@ bool CMessageHeader::IsValid(const MessageStartChars& pchMessageStartIn) const
129129
}
130130

131131

132+
ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
133+
if ((services & NODE_NETWORK_LIMITED) && g_initial_block_download_completed) {
134+
return ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
135+
}
136+
return ServiceFlags(NODE_NETWORK | NODE_WITNESS);
137+
}
138+
139+
void SetServiceFlagsIBDCache(bool state) {
140+
g_initial_block_download_completed = state;
141+
}
142+
132143

133144
CAddress::CAddress() : CService()
134145
{

src/protocol.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ enum ServiceFlags : uint64_t {
278278
// BIP process.
279279
};
280280

281-
extern std::atomic<bool> g_initial_block_download_completed;
282281
/**
283282
* Gets the set of service flags which are "desirable" for a given peer.
284283
*
@@ -303,12 +302,10 @@ extern std::atomic<bool> g_initial_block_download_completed;
303302
* If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py
304303
* should be updated appropriately to filter for the same nodes.
305304
*/
306-
static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) {
307-
if ((services & NODE_NETWORK_LIMITED) && g_initial_block_download_completed) {
308-
return ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
309-
}
310-
return ServiceFlags(NODE_NETWORK | NODE_WITNESS);
311-
}
305+
ServiceFlags GetDesirableServiceFlags(ServiceFlags services);
306+
307+
/** Set the current IBD status in order to figure out the desirable service flags */
308+
void SetServiceFlagsIBDCache(bool status);
312309

313310
/**
314311
* A shortcut for (services & GetDesirableServiceFlags(services))

0 commit comments

Comments
 (0)