refactor: inline constant return value of TxIndex::DB::WriteTxs

This commit is contained in:
Lőrinc committed 2025-08-13 15:47:44 -07:00
1 parent 50b63a5698
commit d1847cf5b5
1 file changed
+4 -4
+4 -4
View File
@@ -28,7 +28,7 @@ public:
bool ReadTxPos(const Txid& txid, CDiskTxPos& pos) const; bool ReadTxPos(const Txid& txid, CDiskTxPos& pos) const;
/// Write a batch of transaction positions to the DB. /// Write a batch of transaction positions to the DB.
[[nodiscard]] bool WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& v_pos); void WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& v_pos);
}; };
TxIndex::DB::DB(size_t n_cache_size, bool f_memory, bool f_wipe) : TxIndex::DB::DB(size_t n_cache_size, bool f_memory, bool f_wipe) :
@@ -40,14 +40,13 @@ bool TxIndex::DB::ReadTxPos(const Txid& txid, CDiskTxPos& pos) const
return Read(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos); return Read(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos);
} }
bool TxIndex::DB::WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& v_pos) void TxIndex::DB::WriteTxs(const std::vector<std::pair<Txid, CDiskTxPos>>& v_pos)
{ {
CDBBatch batch(*this); CDBBatch batch(*this);
for (const auto& [txid, pos] : v_pos) { for (const auto& [txid, pos] : v_pos) {
batch.Write(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos); batch.Write(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos);
} }
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) TxIndex::TxIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe)
@@ -69,7 +68,8 @@ bool TxIndex::CustomAppend(const interfaces::BlockInfo& block)
vPos.emplace_back(tx->GetHash(), pos); vPos.emplace_back(tx->GetHash(), pos);
pos.nTxOffset += ::GetSerializeSize(TX_WITH_WITNESS(*tx)); pos.nTxOffset += ::GetSerializeSize(TX_WITH_WITNESS(*tx));
} }
return m_db->WriteTxs(vPos); m_db->WriteTxs(vPos);
return true;
} }
BaseIndex::DB& TxIndex::GetDB() const { return *m_db; } BaseIndex::DB& TxIndex::GetDB() const { return *m_db; }