Skip to content

Commit fa247a3

Browse files
author
MarcoFalke
committed
refactor: Move block storage globals to blockstorage
However, keep a declaration in validation to make it possible to move smaller chunks to blockstorage without breaking compilation. Also, expose AbortNode in the header. Can be reviewed with --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
1 parent fa81c30 commit fa247a3

File tree

3 files changed

+30
-16
lines changed

3 files changed

+30
-16
lines changed

src/node/blockstorage.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,23 @@ bool fHavePruned = false;
2121
bool fPruneMode = false;
2222
uint64_t nPruneTarget = 0;
2323

24+
// TODO make namespace {
25+
RecursiveMutex cs_LastBlockFile;
26+
std::vector<CBlockFileInfo> vinfoBlockFile;
27+
int nLastBlockFile = 0;
28+
/** Global flag to indicate we should check to see if there are
29+
* block/undo files that should be deleted. Set on startup
30+
* or if we allocate more file space when we're in prune mode
31+
*/
32+
bool fCheckForPruning = false;
33+
34+
/** Dirty block index entries. */
35+
std::set<CBlockIndex*> setDirtyBlockIndex;
36+
37+
/** Dirty block file entries. */
38+
std::set<int> setDirtyFileInfo;
39+
// } // namespace
40+
2441
bool IsBlockPruned(const CBlockIndex* pblockindex)
2542
{
2643
return (fHavePruned && !(pblockindex->nStatus & BLOCK_HAVE_DATA) && pblockindex->nTx > 0);

src/validation.cpp

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,22 +148,16 @@ CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE);
148148
// Internal stuff
149149
namespace {
150150
CBlockIndex* pindexBestInvalid = nullptr;
151+
} // namespace
151152

152-
RecursiveMutex cs_LastBlockFile;
153-
std::vector<CBlockFileInfo> vinfoBlockFile;
154-
int nLastBlockFile = 0;
155-
/** Global flag to indicate we should check to see if there are
156-
* block/undo files that should be deleted. Set on startup
157-
* or if we allocate more file space when we're in prune mode
158-
*/
159-
bool fCheckForPruning = false;
160-
161-
/** Dirty block index entries. */
162-
std::set<CBlockIndex*> setDirtyBlockIndex;
163-
164-
/** Dirty block file entries. */
165-
std::set<int> setDirtyFileInfo;
166-
} // anon namespace
153+
// Internal stuff from blockstorage ...
154+
extern RecursiveMutex cs_LastBlockFile;
155+
extern std::vector<CBlockFileInfo> vinfoBlockFile;
156+
extern int nLastBlockFile;
157+
extern bool fCheckForPruning;
158+
extern std::set<CBlockIndex*> setDirtyBlockIndex;
159+
extern std::set<int> setDirtyFileInfo;
160+
// ... TODO move fully to blockstorage
167161

168162
CBlockIndex* BlockManager::LookupBlockIndex(const uint256& hash) const
169163
{
@@ -1515,7 +1509,7 @@ bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
15151509
return true;
15161510
}
15171511

1518-
static bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = bilingual_str())
1512+
bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage)
15191513
{
15201514
AbortNode(strMessage, userMessage);
15211515
return state.Error(strMessage);

src/validation.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <serialize.h>
2828
#include <util/check.h>
2929
#include <util/hasher.h>
30+
#include <util/translation.h>
3031

3132
#include <atomic>
3233
#include <map>
@@ -161,6 +162,8 @@ void StopScriptCheckWorkerThreads();
161162
CTransactionRef GetTransaction(const CBlockIndex* const block_index, const CTxMemPool* const mempool, const uint256& hash, const Consensus::Params& consensusParams, uint256& hashBlock);
162163
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params& consensusParams);
163164

165+
bool AbortNode(BlockValidationState& state, const std::string& strMessage, const bilingual_str& userMessage = bilingual_str{});
166+
164167
/** Guess verification progress (as a fraction between 0.0=genesis and 1.0=current tip). */
165168
double GuessVerificationProgress(const ChainTxData& data, const CBlockIndex* pindex);
166169

0 commit comments

Comments
 (0)