@@ -42,19 +42,19 @@ CCoinsMap::iterator CCoinsViewCache::FetchCoins(const COutPoint &outpoint) const
4242 if (!base->GetCoins (outpoint, tmp))
4343 return cacheCoins.end ();
4444 CCoinsMap::iterator ret = cacheCoins.emplace (std::piecewise_construct, std::forward_as_tuple (outpoint), std::forward_as_tuple (std::move (tmp))).first ;
45- if (ret->second .coins .IsPruned ()) {
45+ if (ret->second .coin .IsPruned ()) {
4646 // The parent only has an empty entry for this outpoint; we can consider our
4747 // version as fresh.
4848 ret->second .flags = CCoinsCacheEntry::FRESH;
4949 }
50- cachedCoinsUsage += ret->second .coins .DynamicMemoryUsage ();
50+ cachedCoinsUsage += ret->second .coin .DynamicMemoryUsage ();
5151 return ret;
5252}
5353
5454bool CCoinsViewCache::GetCoins (const COutPoint &outpoint, Coin &coin) const {
5555 CCoinsMap::const_iterator it = FetchCoins (outpoint);
5656 if (it != cacheCoins.end ()) {
57- coin = it->second .coins ;
57+ coin = it->second .coin ;
5858 return true ;
5959 }
6060 return false ;
@@ -68,17 +68,17 @@ void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possi
6868 std::tie (it, inserted) = cacheCoins.emplace (std::piecewise_construct, std::forward_as_tuple (outpoint), std::tuple<>());
6969 bool fresh = false ;
7070 if (!inserted) {
71- cachedCoinsUsage -= it->second .coins .DynamicMemoryUsage ();
71+ cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
7272 }
7373 if (!possible_overwrite) {
74- if (!it->second .coins .IsPruned ()) {
74+ if (!it->second .coin .IsPruned ()) {
7575 throw std::logic_error (" Adding new coin that replaces non-pruned entry" );
7676 }
7777 fresh = !(it->second .flags & CCoinsCacheEntry::DIRTY);
7878 }
79- it->second .coins = std::move (coin);
79+ it->second .coin = std::move (coin);
8080 it->second .flags |= CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0 );
81- cachedCoinsUsage += it->second .coins .DynamicMemoryUsage ();
81+ cachedCoinsUsage += it->second .coin .DynamicMemoryUsage ();
8282}
8383
8484void AddCoins (CCoinsViewCache& cache, const CTransaction &tx, int nHeight) {
@@ -94,15 +94,15 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight) {
9494void CCoinsViewCache::SpendCoin (const COutPoint &outpoint, Coin* moveout) {
9595 CCoinsMap::iterator it = FetchCoins (outpoint);
9696 if (it == cacheCoins.end ()) return ;
97- cachedCoinsUsage -= it->second .coins .DynamicMemoryUsage ();
97+ cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
9898 if (moveout) {
99- *moveout = std::move (it->second .coins );
99+ *moveout = std::move (it->second .coin );
100100 }
101101 if (it->second .flags & CCoinsCacheEntry::FRESH) {
102102 cacheCoins.erase (it);
103103 } else {
104104 it->second .flags |= CCoinsCacheEntry::DIRTY;
105- it->second .coins .Clear ();
105+ it->second .coin .Clear ();
106106 }
107107}
108108
@@ -113,13 +113,13 @@ const Coin& CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
113113 if (it == cacheCoins.end ()) {
114114 return coinEmpty;
115115 } else {
116- return it->second .coins ;
116+ return it->second .coin ;
117117 }
118118}
119119
120120bool CCoinsViewCache::HaveCoins (const COutPoint &outpoint) const {
121121 CCoinsMap::const_iterator it = FetchCoins (outpoint);
122- return (it != cacheCoins.end () && !it->second .coins .IsPruned ());
122+ return (it != cacheCoins.end () && !it->second .coin .IsPruned ());
123123}
124124
125125bool CCoinsViewCache::HaveCoinsInCache (const COutPoint &outpoint) const {
@@ -144,12 +144,12 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
144144 if (itUs == cacheCoins.end ()) {
145145 // The parent cache does not have an entry, while the child does
146146 // We can ignore it if it's both FRESH and pruned in the child
147- if (!(it->second .flags & CCoinsCacheEntry::FRESH && it->second .coins .IsPruned ())) {
147+ if (!(it->second .flags & CCoinsCacheEntry::FRESH && it->second .coin .IsPruned ())) {
148148 // Otherwise we will need to create it in the parent
149149 // and move the data up and mark it as dirty
150150 CCoinsCacheEntry& entry = cacheCoins[it->first ];
151- entry.coins = std::move (it->second .coins );
152- cachedCoinsUsage += entry.coins .DynamicMemoryUsage ();
151+ entry.coin = std::move (it->second .coin );
152+ cachedCoinsUsage += entry.coin .DynamicMemoryUsage ();
153153 entry.flags = CCoinsCacheEntry::DIRTY;
154154 // We can mark it FRESH in the parent if it was FRESH in the child
155155 // Otherwise it might have just been flushed from the parent's cache
@@ -162,21 +162,21 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
162162 // parent cache entry has unspent outputs. If this ever happens,
163163 // it means the FRESH flag was misapplied and there is a logic
164164 // error in the calling code.
165- if ((it->second .flags & CCoinsCacheEntry::FRESH) && !itUs->second .coins .IsPruned ())
165+ if ((it->second .flags & CCoinsCacheEntry::FRESH) && !itUs->second .coin .IsPruned ())
166166 throw std::logic_error (" FRESH flag misapplied to cache entry for base transaction with spendable outputs" );
167167
168168 // Found the entry in the parent cache
169- if ((itUs->second .flags & CCoinsCacheEntry::FRESH) && it->second .coins .IsPruned ()) {
169+ if ((itUs->second .flags & CCoinsCacheEntry::FRESH) && it->second .coin .IsPruned ()) {
170170 // The grandparent does not have an entry, and the child is
171171 // modified and being pruned. This means we can just delete
172172 // it from the parent.
173- cachedCoinsUsage -= itUs->second .coins .DynamicMemoryUsage ();
173+ cachedCoinsUsage -= itUs->second .coin .DynamicMemoryUsage ();
174174 cacheCoins.erase (itUs);
175175 } else {
176176 // A normal modification.
177- cachedCoinsUsage -= itUs->second .coins .DynamicMemoryUsage ();
178- itUs->second .coins = std::move (it->second .coins );
179- cachedCoinsUsage += itUs->second .coins .DynamicMemoryUsage ();
177+ cachedCoinsUsage -= itUs->second .coin .DynamicMemoryUsage ();
178+ itUs->second .coin = std::move (it->second .coin );
179+ cachedCoinsUsage += itUs->second .coin .DynamicMemoryUsage ();
180180 itUs->second .flags |= CCoinsCacheEntry::DIRTY;
181181 // NOTE: It is possible the child has a FRESH flag here in
182182 // the event the entry we found in the parent is pruned. But
@@ -204,7 +204,7 @@ void CCoinsViewCache::Uncache(const COutPoint& hash)
204204{
205205 CCoinsMap::iterator it = cacheCoins.find (hash);
206206 if (it != cacheCoins.end () && it->second .flags == 0 ) {
207- cachedCoinsUsage -= it->second .coins .DynamicMemoryUsage ();
207+ cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
208208 cacheCoins.erase (it);
209209 }
210210}
0 commit comments