mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
Various performance tweaks to CCoinsView
* Pass txid's to CCoinsView functions by reference instead of by value * Add a method to swap CCoins, and use it in some places to avoid a allocating copy + destruct. * Optimize CCoinsViewCache::FetchCoins to do only a single search through the backing map.
This commit is contained in:
@@ -22,17 +22,17 @@ void static BatchWriteHashBestChain(CLevelDBBatch &batch, const uint256 &hash) {
|
||||
CCoinsViewDB::CCoinsViewDB(size_t nCacheSize, bool fMemory, bool fWipe) : db(GetDataDir() / "coins", nCacheSize, fMemory, fWipe) {
|
||||
}
|
||||
|
||||
bool CCoinsViewDB::GetCoins(uint256 txid, CCoins &coins) {
|
||||
bool CCoinsViewDB::GetCoins(const uint256 &txid, CCoins &coins) {
|
||||
return db.Read(make_pair('c', txid), coins);
|
||||
}
|
||||
|
||||
bool CCoinsViewDB::SetCoins(uint256 txid, const CCoins &coins) {
|
||||
bool CCoinsViewDB::SetCoins(const uint256 &txid, const CCoins &coins) {
|
||||
CLevelDBBatch batch;
|
||||
BatchWriteCoins(batch, txid, coins);
|
||||
return db.WriteBatch(batch);
|
||||
}
|
||||
|
||||
bool CCoinsViewDB::HaveCoins(uint256 txid) {
|
||||
bool CCoinsViewDB::HaveCoins(const uint256 &txid) {
|
||||
return db.Exists(make_pair('c', txid));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user