aboutsummaryrefslogtreecommitdiff
path: root/src/coins.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-04-19 09:34:30 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2017-06-26 10:45:48 -0700
commit013a56aa1af985894b3eaf7c325647b0b74e4456 (patch)
treee09581eda1ae2da213a85f699acc47e312c4e1e8 /src/coins.h
parentb3a279cd58d9ae0e107c7fee81f598635e53f9e1 (diff)
downloadbitcoin-013a56aa1af985894b3eaf7c325647b0b74e4456.tar.xz
Non-atomic flushing using the blockchain as replay journal
Diffstat (limited to 'src/coins.h')
-rw-r--r--src/coins.h13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/coins.h b/src/coins.h
index 4774c9f6a6..de3264f46e 100644
--- a/src/coins.h
+++ b/src/coins.h
@@ -155,6 +155,12 @@ public:
//! Retrieve the block hash whose state this CCoinsView currently represents
virtual uint256 GetBestBlock() const;
+ //! Retrieve the range of blocks that may have been only partially written.
+ //! If the database is in a consistent state, the result is the empty vector.
+ //! Otherwise, a two-element vector is returned consisting of the new and
+ //! the old block hash, in that order.
+ virtual std::vector<uint256> GetHeadBlocks() const;
+
//! Do a bulk modification (multiple Coin changes + BestBlock change).
//! The passed mapCoins can be modified.
virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
@@ -181,6 +187,7 @@ public:
bool GetCoin(const COutPoint &outpoint, Coin &coin) const override;
bool HaveCoin(const COutPoint &outpoint) const override;
uint256 GetBestBlock() const override;
+ std::vector<uint256> GetHeadBlocks() const override;
void SetBackend(CCoinsView &viewIn);
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) override;
CCoinsViewCursor *Cursor() const override;
@@ -289,10 +296,12 @@ private:
};
//! Utility function to add all of a transaction's outputs to a cache.
-// It assumes that overwrites are only possible for coinbase transactions,
+// When check is false, this assumes that overwrites are only possible for coinbase transactions.
+// When check is true, the underlying view may be queried to determine whether an addition is
+// an overwrite.
// TODO: pass in a boolean to limit these possible overwrites to known
// (pre-BIP34) cases.
-void AddCoins(CCoinsViewCache& cache, const CTransaction& tx, int nHeight);
+void AddCoins(CCoinsViewCache& cache, const CTransaction& tx, int nHeight, bool check = false);
//! Utility function to find any unspent output with a given txid.
const Coin& AccessByTxid(const CCoinsViewCache& cache, const uint256& txid);