mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Merge 7317e14a44 into merged_master (Bitcoin PR bitcoin/bitcoin#22263)
This commit is contained in:
commit
3c48d95401
6 changed files with 37 additions and 34 deletions
29
src/txdb.cpp
29
src/txdb.cpp
|
|
@ -194,9 +194,34 @@ bool CBlockTreeDB::ReadLastBlockFile(int &nFile) {
|
|||
return Read(DB_LAST_BLOCK, nFile);
|
||||
}
|
||||
|
||||
CCoinsViewCursor *CCoinsViewDB::Cursor() const
|
||||
/** Specialization of CCoinsViewCursor to iterate over a CCoinsViewDB */
|
||||
class CCoinsViewDBCursor: public CCoinsViewCursor
|
||||
{
|
||||
CCoinsViewDBCursor *i = new CCoinsViewDBCursor(const_cast<CDBWrapper&>(*m_db).NewIterator(), GetBestBlock());
|
||||
public:
|
||||
// Prefer using CCoinsViewDB::Cursor() since we want to perform some
|
||||
// cache warmup on instantiation.
|
||||
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>(
|
||||
const_cast<CDBWrapper&>(*m_db).NewIterator(), GetBestBlock());
|
||||
/* It seems that there are no "const iterators" for LevelDB. Since we
|
||||
only need read operations on it, use a const-cast to get around
|
||||
that restriction. */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue