diff --git a/src/net_processing.cpp b/src/net_processing.cpp --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -1074,7 +1074,7 @@ const int nNewHeight = pindexNew->nHeight; connman->SetBestHeight(nNewHeight); - g_initial_block_download_completed = !fInitialDownload; + SetServiceFlagsIBDCache(!fInitialDownload); if (!fInitialDownload) { // Find the hashes of all blocks that weren't previously in the best // chain. diff --git a/src/protocol.h b/src/protocol.h --- a/src/protocol.h +++ b/src/protocol.h @@ -323,7 +323,6 @@ NODE_AVALANCHE = (1 << 24), }; -extern std::atomic g_initial_block_download_completed; /** * Gets the set of service flags which are "desirable" for a given peer. * @@ -348,13 +347,13 @@ * If the NODE_NONE return value is changed, contrib/seeds/makeseeds.py * should be updated appropriately to filter for the same nodes. */ -static ServiceFlags GetDesirableServiceFlags(ServiceFlags services) { - if ((services & NODE_NETWORK_LIMITED) && - g_initial_block_download_completed) { - return ServiceFlags(NODE_NETWORK_LIMITED); - } - return ServiceFlags(NODE_NETWORK); -} +ServiceFlags GetDesirableServiceFlags(ServiceFlags services); + +/** + * Set the current IBD status in order to figure out the desirable service + * flags + */ +void SetServiceFlagsIBDCache(bool status); /** * A shortcut for (services & GetDesirableServiceFlags(services)) diff --git a/src/protocol.cpp b/src/protocol.cpp --- a/src/protocol.cpp +++ b/src/protocol.cpp @@ -14,7 +14,7 @@ #include #endif -std::atomic g_initial_block_download_completed(false); +static std::atomic g_initial_block_download_completed(false); namespace NetMsgType { const char *VERSION = "version"; @@ -183,6 +183,18 @@ return false; } +ServiceFlags GetDesirableServiceFlags(ServiceFlags services) { + if ((services & NODE_NETWORK_LIMITED) && + g_initial_block_download_completed) { + return ServiceFlags(NODE_NETWORK_LIMITED); + } + return ServiceFlags(NODE_NETWORK); +} + +void SetServiceFlagsIBDCache(bool state) { + g_initial_block_download_completed = state; +} + CAddress::CAddress() : CService() { Init(); }