Cursor for iterating over the linked list of flagged entries in CCoinsViewCache.
Declared in <coins.h>
struct CoinsViewCacheCursor;
This is a helper struct to encapsulate the diverging logic between a non-erasing CCoinsViewCache::Sync and an erasing CCoinsViewCache::Flush. This allows the receiver of CCoinsView::BatchWrite to iterate through the flagged entries without knowing the caller's intent.
However, the receiver can still call CoinsViewCacheCursor::WillErase to see if the caller will erase the entry after BatchWrite returns. If so, the receiver can perform optimizations such as moving the coin out of the CCoinsCachEntry instead of copying it.
| Name | Description |
|---|---|
CoinsViewCacheCursor [constructor] | If will_erase is not set, iterating through the cursor will erase spent coins from the map, and other coins will be unflagged (removing them from the linked list). If will_erase is set, the underlying map and linked list will not be modified, as the caller is expected to wipe the entire map anyway. This is an optimization compared to erasing all entries as the cursor iterates them when will_erase is set. Calling CCoinsMap::clear() afterwards is faster because a CoinsCachePair cannot be coerced back into a CCoinsMap::iterator to be erased, and must therefore be looked up again by key in the CCoinsMap before being erased. |
Begin | Get the first flagged entry in the linked list. |
End | Get the one-past-the-end sentinel of the linked list. |
GetDirtyCount | Report the number of dirty entries remaining to iterate. |
GetTotalCount | Report the total number of entries in the underlying map. |
NextAndMaybeErase | Return the next entry after current, possibly erasing current |
WillErase | Report whether the given entry will be erased after BatchWrite returns. |