Changeset View
Changeset View
Standalone View
Standalone View
src/txdb.cpp
Show All 40 Lines | struct CoinEntry { | ||||
} | } | ||||
template <typename Stream> void Unserialize(Stream &s) { | template <typename Stream> void Unserialize(Stream &s) { | ||||
s >> key; | s >> key; | ||||
s >> outpoint->hash; | s >> outpoint->hash; | ||||
s >> VARINT(outpoint->n); | s >> VARINT(outpoint->n); | ||||
} | } | ||||
}; | }; | ||||
} | } // namespace | ||||
CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) | CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) | ||||
: db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) {} | : db(GetDataDir() / "chainstate", nCacheSize, fMemory, fWipe, true) {} | ||||
bool CCoinsViewDB::GetCoin(const COutPoint &outpoint, Coin &coin) const { | bool CCoinsViewDB::GetCoin(const COutPoint &outpoint, Coin &coin) const { | ||||
return db.Read(CoinEntry(&outpoint), coin); | return db.Read(CoinEntry(&outpoint), coin); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 257 Lines • ▼ Show 20 Lines | template <typename Stream> void Unserialize(Stream &s) { | ||||
if (vAvail[i]) { | if (vAvail[i]) { | ||||
::Unserialize(s, REF(CTxOutCompressor(vout[i]))); | ::Unserialize(s, REF(CTxOutCompressor(vout[i]))); | ||||
} | } | ||||
} | } | ||||
// coinbase height | // coinbase height | ||||
::Unserialize(s, VARINT(nHeight)); | ::Unserialize(s, VARINT(nHeight)); | ||||
} | } | ||||
}; | }; | ||||
} | } // namespace | ||||
/** | /** | ||||
* Upgrade the database from older formats. | * Upgrade the database from older formats. | ||||
* | * | ||||
* Currently implemented: from the per-tx utxo model (0.8..0.14.x) to per-txout. | * Currently implemented: from the per-tx utxo model (0.8..0.14.x) to per-txout. | ||||
*/ | */ | ||||
bool CCoinsViewDB::Upgrade() { | bool CCoinsViewDB::Upgrade() { | ||||
std::unique_ptr<CDBIterator> pcursor(db.NewIterator()); | std::unique_ptr<CDBIterator> pcursor(db.NewIterator()); | ||||
▲ Show 20 Lines • Show All 44 Lines • Show Last 20 Lines |