From 0f8a5a4dd530549d37c43da52c923ac3b2af1a03 Mon Sep 17 00:00:00 2001 From: James O'Beirne Date: Fri, 18 Jun 2021 14:14:15 -0400 Subject: move-only(ish): don't expose CCoinsViewDBCursor No need for this to be a part of the header anymore. Includes a small reference type style change. --- src/txdb.cpp | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'src/txdb.cpp') diff --git a/src/txdb.cpp b/src/txdb.cpp index bd0e9f7317..e6469ee159 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -168,6 +168,28 @@ bool CBlockTreeDB::ReadLastBlockFile(int &nFile) { return Read(DB_LAST_BLOCK, nFile); } +/** Specialization of CCoinsViewCursor to iterate over a CCoinsViewDB */ +class CCoinsViewDBCursor: public CCoinsViewCursor +{ +public: + CCoinsViewDBCursor(CDBIterator* pcursorIn, const uint256&hashBlockIn): + CCoinsViewCursor(hashBlockIn), pcursor(pcursorIn) {} + ~CCoinsViewDBCursor() {} + + bool GetKey(COutPoint &key) const override; + bool GetValue(Coin &coin) const override; + unsigned int GetValueSize() const override; + + bool Valid() const override; + void Next() override; + +private: + std::unique_ptr pcursor; + std::pair keyTmp; + + friend class CCoinsViewDB; +}; + std::unique_ptr CCoinsViewDB::Cursor() const { auto i = std::make_unique( -- cgit v1.2.3