From b0875eb3fea0934f3a6651fbc22aac12e33e15e5 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 24 Aug 2014 02:08:05 +0200 Subject: Allow BatchWrite to destroy its input, reducing copying --- src/coins.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/coins.h') diff --git a/src/coins.h b/src/coins.h index ff60288163..2b657299e3 100644 --- a/src/coins.h +++ b/src/coins.h @@ -291,8 +291,9 @@ public: // Modify the currently active block hash virtual bool SetBestBlock(const uint256 &hashBlock); - // Do a bulk modification (multiple SetCoins + one SetBestBlock) - virtual bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock); + // Do a bulk modification (multiple SetCoins + one SetBestBlock). + // The passed mapCoins can be modified. + virtual bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); // Calculate statistics about the unspent transaction output set virtual bool GetStats(CCoinsStats &stats); @@ -316,7 +317,7 @@ public: uint256 GetBestBlock(); bool SetBestBlock(const uint256 &hashBlock); void SetBackend(CCoinsView &viewIn); - bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock); + bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); bool GetStats(CCoinsStats &stats); }; @@ -337,7 +338,7 @@ public: bool HaveCoins(const uint256 &txid); uint256 GetBestBlock(); bool SetBestBlock(const uint256 &hashBlock); - bool BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock); + bool BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock); // Return a modifiable reference to a CCoins. Check HaveCoins first. // Many methods explicitly require a CCoinsViewCache because of this method, to reduce @@ -346,6 +347,7 @@ public: // Push the modifications applied to this cache to its base. // Failure to call this method before destruction will cause the changes to be forgotten. + // If false is returned, the state of this cache (and its backing view) will be undefined. bool Flush(); // Calculate the size of the cache (in number of transactions) -- cgit v1.2.3