diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index fe5f9cb0893..cb9abee563f 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -274,7 +274,7 @@ CDBWrapper::~CDBWrapper() DBContext().options.env = nullptr; } -bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync) +void CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync) { const bool log_memory = LogAcceptCategory(BCLog::LEVELDB, BCLog::Level::Debug); double mem_before = 0; @@ -288,7 +288,6 @@ bool CDBWrapper::WriteBatch(CDBBatch& batch, bool fSync) LogDebug(BCLog::LEVELDB, "WriteBatch memory usage: db=%s, before=%.1fMiB, after=%.1fMiB\n", m_name, mem_before, mem_after); } - return true; } size_t CDBWrapper::DynamicMemoryUsage() const diff --git a/src/dbwrapper.h b/src/dbwrapper.h index b9b98bd96ad..94e452db76b 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -234,7 +234,8 @@ public: { CDBBatch batch(*this); batch.Write(key, value); - return WriteBatch(batch, fSync); + WriteBatch(batch, fSync); + return true; } //! @returns filesystem path to the on-disk data. @@ -259,10 +260,11 @@ public: { CDBBatch batch(*this); batch.Erase(key); - return WriteBatch(batch, fSync); + WriteBatch(batch, fSync); + return true; } - bool WriteBatch(CDBBatch& batch, bool fSync = false); + void WriteBatch(CDBBatch& batch, bool fSync = false); // Get an estimate of LevelDB memory usage (in bytes). size_t DynamicMemoryUsage() const; diff --git a/src/index/base.cpp b/src/index/base.cpp index fdd0e0d8af2..0fdb5af3ba1 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -262,7 +262,7 @@ bool BaseIndex::Commit() ok = CustomCommit(batch); if (ok) { GetDB().WriteBestBlock(batch, GetLocator(*m_chain, m_best_block_index.load()->GetBlockHash())); - ok = GetDB().WriteBatch(batch); + GetDB().WriteBatch(batch); } } if (!ok) { diff --git a/src/index/blockfilterindex.cpp b/src/index/blockfilterindex.cpp index 2ccae3a221b..c56d787907a 100644 --- a/src/index/blockfilterindex.cpp +++ b/src/index/blockfilterindex.cpp @@ -338,7 +338,7 @@ bool BlockFilterIndex::CustomRemove(const interfaces::BlockInfo& block) // But since this creates new references to the filter, the position should get updated here // atomically as well in case Commit fails. batch.Write(DB_FILTER_POS, m_next_filter_pos); - if (!m_db->WriteBatch(batch)) return false; + m_db->WriteBatch(batch); // Update cached header to the previous block hash m_last_header = *Assert(ReadFilterHeader(block.height - 1, *Assert(block.prev_hash))); diff --git a/src/index/coinstatsindex.cpp b/src/index/coinstatsindex.cpp index 96693f7f48a..8f172d706a7 100644 --- a/src/index/coinstatsindex.cpp +++ b/src/index/coinstatsindex.cpp @@ -263,7 +263,7 @@ bool CoinStatsIndex::CustomRemove(const interfaces::BlockInfo& block) return false; } - if (!m_db->WriteBatch(batch)) return false; + m_db->WriteBatch(batch); if (!ReverseBlock(block)) { return false; // failure cause logged internally diff --git a/src/index/txindex.cpp b/src/index/txindex.cpp index 11dd856e1b6..16038a3a2b6 100644 --- a/src/index/txindex.cpp +++ b/src/index/txindex.cpp @@ -46,7 +46,8 @@ bool TxIndex::DB::WriteTxs(const std::vector>& v_pos for (const auto& [txid, pos] : v_pos) { batch.Write(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos); } - return WriteBatch(batch); + WriteBatch(batch); + return true; } TxIndex::TxIndex(std::unique_ptr chain, size_t n_cache_size, bool f_memory, bool f_wipe) diff --git a/src/node/blockstorage.cpp b/src/node/blockstorage.cpp index 3c01ff2e8d6..f1d4be6b706 100644 --- a/src/node/blockstorage.cpp +++ b/src/node/blockstorage.cpp @@ -88,7 +88,8 @@ bool BlockTreeDB::WriteBatchSync(const std::vectorGetBlockHash()), CDiskBlockIndex{bi}); } - return WriteBatch(batch, true); + WriteBatch(batch, true); + return true; } bool BlockTreeDB::WriteFlag(const std::string& name, bool fValue) diff --git a/src/test/dbwrapper_tests.cpp b/src/test/dbwrapper_tests.cpp index cd0f347b66e..7066665751d 100644 --- a/src/test/dbwrapper_tests.cpp +++ b/src/test/dbwrapper_tests.cpp @@ -173,7 +173,7 @@ BOOST_AUTO_TEST_CASE(dbwrapper_batch) // Remove key3 before it's even been written batch.Erase(key3); - BOOST_CHECK(dbw.WriteBatch(batch)); + dbw.WriteBatch(batch); BOOST_CHECK(dbw.Read(key, res)); BOOST_CHECK_EQUAL(res.ToString(), in.ToString()); diff --git a/src/txdb.cpp b/src/txdb.cpp index bb6ee2eb524..23824f39c06 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -149,9 +149,9 @@ bool CCoinsViewDB::BatchWrite(CoinsViewCacheCursor& cursor, const uint256 &hashB batch.Write(DB_BEST_BLOCK, hashBlock); LogDebug(BCLog::COINDB, "Writing final batch of %.2f MiB\n", batch.ApproximateSize() * (1.0 / 1048576.0)); - bool ret = m_db->WriteBatch(batch); + m_db->WriteBatch(batch); LogDebug(BCLog::COINDB, "Committed %u changed transaction outputs (out of %u) to coin database...\n", (unsigned int)changed, (unsigned int)count); - return ret; + return true; } size_t CCoinsViewDB::EstimateSize() const