Skip to content

Commit

Permalink
refactor: Expose UndoReadFromDisk in header
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoFalke authored and marcinja committed Mar 20, 2019
1 parent 81f732b commit f53dca6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
#include <txmempool.h>
#include <ui_interface.h>
#include <undo.h>
#include <util/system.h>
#include <util/moneystr.h>
#include <util/strencodings.h>
#include <util/system.h>
#include <validationinterface.h>
#include <warnings.h>

Expand Down Expand Up @@ -1455,9 +1455,7 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, const CCoinsVi
return true;
}

namespace {

bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
static bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint256& hashBlock, const CMessageHeader::MessageStartChars& messageStart)
{
// Open history file to append
CAutoFile fileout(OpenUndoFile(pos), SER_DISK, CLIENT_VERSION);
Expand All @@ -1484,7 +1482,7 @@ bool UndoWriteToDisk(const CBlockUndo& blockundo, FlatFilePos& pos, const uint25
return true;
}

static bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex *pindex)
bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex)
{
FlatFilePos pos = pindex->GetUndoPos();
if (pos.IsNull()) {
Expand Down Expand Up @@ -1533,8 +1531,6 @@ static bool AbortNode(CValidationState& state, const std::string& strMessage, co
return state.Error(strMessage);
}

} // namespace

/**
* Restore the UTXO in a Coin at a given COutPoint
* @param undo The Coin to be restored.
Expand Down
6 changes: 4 additions & 2 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <versionbits.h>

#include <algorithm>
#include <atomic>
#include <exception>
#include <map>
#include <memory>
Expand All @@ -30,10 +31,9 @@
#include <utility>
#include <vector>

#include <atomic>

class CBlockIndex;
class CBlockTreeDB;
class CBlockUndo;
class CChainParams;
class CCoinsViewDB;
class CInv;
Expand Down Expand Up @@ -391,6 +391,8 @@ bool ReadBlockFromDisk(CBlock& block, const CBlockIndex* pindex, const Consensus
bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const FlatFilePos& pos, const CMessageHeader::MessageStartChars& message_start);
bool ReadRawBlockFromDisk(std::vector<uint8_t>& block, const CBlockIndex* pindex, const CMessageHeader::MessageStartChars& message_start);

bool UndoReadFromDisk(CBlockUndo& blockundo, const CBlockIndex* pindex);

/** Functions for validating blocks and updating the block tree */

/** Context-independent validity checks */
Expand Down

0 comments on commit f53dca6

Please sign in to comment.