From 3533fb4d33ecc94a789cb5d4489da22a68fb2168 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 5 Jun 2017 11:50:47 -0400 Subject: Return a bool in SpendCoin to restore pre-per-utxo assert semantics Since its free to do so, assert that Spends succeeded when we expect them to. --- src/coins.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/coins.h') diff --git a/src/coins.h b/src/coins.h index 476db8f37c..4a0eaadc82 100644 --- a/src/coins.h +++ b/src/coins.h @@ -238,7 +238,7 @@ public: * If no unspent output exists for the passed outpoint, this call * has no effect. */ - void SpendCoin(const COutPoint &outpoint, Coin* moveto = nullptr); + bool SpendCoin(const COutPoint &outpoint, Coin* moveto = nullptr); /** * Push the modifications applied to this cache to its base. -- cgit v1.2.3 From 9417d7a336e71ee31ce673a6de5abb3d56941204 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Mon, 5 Jun 2017 20:28:08 -0400 Subject: Be much more agressive in AccessCoin docs. While the current implementation is pretty free, there is a lot of possibility for this to blow up in our face with future changes, especially as the backing map gets tweaked. --- src/coins.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/coins.h') diff --git a/src/coins.h b/src/coins.h index 4a0eaadc82..89613a61b4 100644 --- a/src/coins.h +++ b/src/coins.h @@ -222,8 +222,13 @@ public: /** * Return a reference to Coin in the cache, or a pruned one if not found. This is - * more efficient than GetCoin. Modifications to other cache entries are - * allowed while accessing the returned pointer. + * more efficient than GetCoin. + * + * Generally, do not hold the reference returned for more than a short scope. + * While the current implementation allows for modifications to the contents + * of the cache while holding the reference, this behavior should not be relied + * on! To be safe, best to not hold the returned reference through any other + * calls to this cache. */ const Coin& AccessCoin(const COutPoint &output) const; -- cgit v1.2.3