aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-04-15 16:36:39 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-04-15 16:43:21 +0200
commit9e47fcec1798e1db9a32ae243605e8245ffdb273 (patch)
tree233e8ae0b6d19e5e42b791b26bbc43c514f430c7 /src/txdb.h
parentbe14ca5e8c0f0e8cd8ef511ccb9c41f245d62fbf (diff)
parent509cb006d514cece5ab7680094f033c8dc8a2318 (diff)
downloadbitcoin-9e47fcec1798e1db9a32ae243605e8245ffdb273.tar.xz
Merge #7756: Add cursor to iterate over utxo set, use this in `gettxoutsetinfo`
509cb00 txdb: Add Cursor() method to CCoinsView to iterate over UTXO set (Wladimir J. van der Laan)
Diffstat (limited to 'src/txdb.h')
-rw-r--r--src/txdb.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/txdb.h b/src/txdb.h
index 22e0c5704c..749802f0e5 100644
--- a/src/txdb.h
+++ b/src/txdb.h
@@ -26,6 +26,8 @@ static const int64_t nMaxDbCache = sizeof(void*) > 4 ? 16384 : 1024;
//! min. -dbcache in (MiB)
static const int64_t nMinDbCache = 4;
+class CCoinsViewDBCursor;
+
/** CCoinsView backed by the coin database (chainstate/) */
class CCoinsViewDB : public CCoinsView
{
@@ -38,7 +40,29 @@ public:
bool HaveCoins(const uint256 &txid) const;
uint256 GetBestBlock() const;
bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock);
- bool GetStats(CCoinsStats &stats) const;
+ CCoinsViewCursor *Cursor() const;
+};
+
+/** Specialization of CCoinsViewCursor to iterate over a CCoinsViewDB */
+class CCoinsViewDBCursor: public CCoinsViewCursor
+{
+public:
+ ~CCoinsViewDBCursor() {}
+
+ bool GetKey(uint256 &key) const;
+ bool GetValue(CCoins &coins) const;
+ unsigned int GetValueSize() const;
+
+ bool Valid() const;
+ void Next();
+
+private:
+ CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256 &hashBlockIn):
+ CCoinsViewCursor(hashBlockIn), pcursor(pcursorIn) {}
+ boost::scoped_ptr<CDBIterator> pcursor;
+ std::pair<char, uint256> keyTmp;
+
+ friend class CCoinsViewDB;
};
/** Access to the block database (blocks/index/) */