diff options
| author | Pieter Wuille <[email protected]> | 2013-01-20 18:05:34 +0100 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2013-01-26 18:46:12 +0100 |
| commit | f369d02c51077ffa1644954d0478e93966e1bb72 (patch) | |
| tree | 2d4d583878dae9762388a890a8d64d355d09ceef /src/txdb.cpp | |
| parent | Merge pull request #2213 from Diapolo/translations (diff) | |
| download | discoin-f369d02c51077ffa1644954d0478e93966e1bb72.tar.xz discoin-f369d02c51077ffa1644954d0478e93966e1bb72.zip | |
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.
Diffstat (limited to 'src/txdb.cpp')
| -rw-r--r-- | src/txdb.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp index 78fa0279b..ca4e6c9bd 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -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)); } |