diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-03-20 12:28:05 -0400 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-03-20 12:28:18 -0400 |
commit | 93623eea71e7159e367b1b1888418099a5307983 (patch) | |
tree | 1122e929787a82e48822cebf7c028afbd14dbfdd | |
parent | 81f732bcaa30edcc16a0d85e3d56e7a1d4845ae1 (diff) | |
parent | fa11c036e97f18d31cffaf7430fbe84fe44efbcc (diff) |
Merge #15623: refactor: Expose UndoReadFromDisk in header
fa11c036e9 refactor: Expose UndoReadFromDisk in header (MarcoFalke)
Pull request description:
It is not possible to calculate the fee of a non-mempool transaction in RPCs unless txindex is active or the prevtxs are passed in through the RPC.
Fix that issue for confirmed txs by exposing `UndoReadFromDisk` in the header file.
This pull is a requirement for
* rpc: faster getblockstats using BlockUndo data #14802
* Index for BIP 157 block filters #14121
* my local patches
Tree-SHA512: 859ea5f2dfb4feac612b50faeb0e2b6c07b83f1d983e519d7647a78058d85c0390fd09ec66b460ae7a4c3b273e81b0013ee9f4bb8dfba0c4782ffaa1fa453ea6
-rw-r--r-- | src/validation.cpp | 10 | ||||
-rw-r--r-- | src/validation.h | 6 |
2 files changed, 7 insertions, 9 deletions
diff --git a/src/validation.cpp b/src/validation.cpp index a9b5bcf4a4..ae3985485e 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -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> @@ -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); @@ -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()) { @@ -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. diff --git a/src/validation.h b/src/validation.h index 0acca013b5..d84e3a0dbc 100644 --- a/src/validation.h +++ b/src/validation.h @@ -21,6 +21,7 @@ #include <versionbits.h> #include <algorithm> +#include <atomic> #include <exception> #include <map> #include <memory> @@ -30,10 +31,9 @@ #include <utility> #include <vector> -#include <atomic> - class CBlockIndex; class CBlockTreeDB; +class CBlockUndo; class CChainParams; class CCoinsViewDB; class CInv; @@ -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 */ |