mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-02-15 01:49:40 +00:00
refactor: inline constant return value of TxIndex::DB::WriteTxs
This commit is contained in:
parent
50b63a5698
commit
d1847cf5b5
@ -28,7 +28,7 @@ public:
|
||||
bool ReadTxPos(const Txid& txid, CDiskTxPos& pos) const;
|
||||
|
||||
/// 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) :
|
||||
@ -40,14 +40,13 @@ bool TxIndex::DB::ReadTxPos(const Txid& txid, CDiskTxPos& pos) const
|
||||
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);
|
||||
for (const auto& [txid, pos] : v_pos) {
|
||||
batch.Write(std::make_pair(DB_TXINDEX, txid.ToUint256()), pos);
|
||||
}
|
||||
WriteBatch(batch);
|
||||
return true;
|
||||
}
|
||||
|
||||
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);
|
||||
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; }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user