MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Cursor

Method Cursor

src/txdb.cpp:240–257  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

238};
239
240std::unique_ptr<CCoinsViewCursor> CCoinsViewDB::Cursor() const
241{
242 auto i = std::make_unique<CCoinsViewDBCursor>(
243 const_cast<CDBWrapper&>(*m_db).NewIterator(), GetBestBlock());
244 /* It seems that there are no "const iterators" for LevelDB. Since we
245 only need read operations on it, use a const-cast to get around
246 that restriction. */
247 i->pcursor->Seek(DB_COIN);
248 // Cache key of first record
249 if (i->pcursor->Valid()) {
250 CoinEntry entry(&i->keyTmp.second);
251 i->pcursor->GetKey(entry);
252 i->keyTmp.first = entry.key;
253 } else {
254 i->keyTmp.first = 0; // Make sure Valid() and GetKey() return false
255 }
256 return i;
257}
258
259bool CCoinsViewDBCursor::GetKey(COutPoint &key) const
260{

Callers 5

TestCoinsViewFunction · 0.45
scantxoutsetFunction · 0.45
PrepareUTXOSnapshotFunction · 0.45
ComputeUTXOStatsFunction · 0.45

Calls 4

NewIteratorMethod · 0.45
SeekMethod · 0.45
ValidMethod · 0.45
GetKeyMethod · 0.45

Tested by 1

TestCoinsViewFunction · 0.36