|
|
|
@ -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<CDBIterator> pcursor;
|
|
|
|
|
std::pair<char, COutPoint> keyTmp;
|
|
|
|
|
|
|
|
|
|
friend class CCoinsViewDB;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<CCoinsViewCursor> CCoinsViewDB::Cursor() const
|
|
|
|
|
{
|
|
|
|
|
auto i = std::make_unique<CCoinsViewDBCursor>(
|
|
|
|
|