mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
txdb: don't reset during in-memory cache resize
We can't support a reset of the dbwrapper object when in-memory configuration is used because it results in the permanent loss of coins. This only affects unittest configurations (since that's the only place we use in-memory CCoinsViewDB instances).
This commit is contained in:
parent
f6e2da5fb7
commit
ad949ba449
1 changed files with 9 additions and 5 deletions
|
@ -47,12 +47,16 @@ CCoinsViewDB::CCoinsViewDB(fs::path ldb_path, size_t nCacheSize, bool fMemory, b
|
||||||
|
|
||||||
void CCoinsViewDB::ResizeCache(size_t new_cache_size)
|
void CCoinsViewDB::ResizeCache(size_t new_cache_size)
|
||||||
{
|
{
|
||||||
|
// We can't do this operation with an in-memory DB since we'll lose all the coins upon
|
||||||
|
// reset.
|
||||||
|
if (!m_is_memory) {
|
||||||
// Have to do a reset first to get the original `m_db` state to release its
|
// Have to do a reset first to get the original `m_db` state to release its
|
||||||
// filesystem lock.
|
// filesystem lock.
|
||||||
m_db.reset();
|
m_db.reset();
|
||||||
m_db = MakeUnique<CDBWrapper>(
|
m_db = MakeUnique<CDBWrapper>(
|
||||||
m_ldb_path, new_cache_size, m_is_memory, /*fWipe*/ false, /*obfuscate*/ true);
|
m_ldb_path, new_cache_size, m_is_memory, /*fWipe*/ false, /*obfuscate*/ true);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bool CCoinsViewDB::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
bool CCoinsViewDB::GetCoin(const COutPoint &outpoint, Coin &coin) const {
|
||||||
return m_db->Read(CoinEntry(&outpoint), coin);
|
return m_db->Read(CoinEntry(&outpoint), coin);
|
||||||
|
|
Loading…
Add table
Reference in a new issue