mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-05 10:42:13 +02:00
refactor: inline constant return value of CDBWrapper::WriteBatch
`WriteBatch` can only ever return `true` - its errors are handled by throwing a `throw dbwrapper_error` instead. The boolean return value is quite confusing, especially since it's symmetric with `CDBWrapper::Read`, which catches the exceptions and returns a boolean instead. We're removing the constant return value and inlining `true` for its usages.
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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)));
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -46,7 +46,8 @@ bool TxIndex::DB::WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& 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<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe)
|
||||
|
||||
Reference in New Issue
Block a user