@@ -42,19 +42,19 @@ CCoinsMap::iterator CCoinsViewCache::FetchCoins(const COutPoint &outpoint) const
42
42
if (!base->GetCoins (outpoint, tmp))
43
43
return cacheCoins.end ();
44
44
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 ()) {
46
46
// The parent only has an empty entry for this outpoint; we can consider our
47
47
// version as fresh.
48
48
ret->second .flags = CCoinsCacheEntry::FRESH;
49
49
}
50
- cachedCoinsUsage += ret->second .coins .DynamicMemoryUsage ();
50
+ cachedCoinsUsage += ret->second .coin .DynamicMemoryUsage ();
51
51
return ret;
52
52
}
53
53
54
54
bool CCoinsViewCache::GetCoins (const COutPoint &outpoint, Coin &coin) const {
55
55
CCoinsMap::const_iterator it = FetchCoins (outpoint);
56
56
if (it != cacheCoins.end ()) {
57
- coin = it->second .coins ;
57
+ coin = it->second .coin ;
58
58
return true ;
59
59
}
60
60
return false ;
@@ -68,17 +68,17 @@ void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possi
68
68
std::tie (it, inserted) = cacheCoins.emplace (std::piecewise_construct, std::forward_as_tuple (outpoint), std::tuple<>());
69
69
bool fresh = false ;
70
70
if (!inserted) {
71
- cachedCoinsUsage -= it->second .coins .DynamicMemoryUsage ();
71
+ cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
72
72
}
73
73
if (!possible_overwrite) {
74
- if (!it->second .coins .IsPruned ()) {
74
+ if (!it->second .coin .IsPruned ()) {
75
75
throw std::logic_error (" Adding new coin that replaces non-pruned entry" );
76
76
}
77
77
fresh = !(it->second .flags & CCoinsCacheEntry::DIRTY);
78
78
}
79
- it->second .coins = std::move (coin);
79
+ it->second .coin = std::move (coin);
80
80
it->second .flags |= CCoinsCacheEntry::DIRTY | (fresh ? CCoinsCacheEntry::FRESH : 0 );
81
- cachedCoinsUsage += it->second .coins .DynamicMemoryUsage ();
81
+ cachedCoinsUsage += it->second .coin .DynamicMemoryUsage ();
82
82
}
83
83
84
84
void AddCoins (CCoinsViewCache& cache, const CTransaction &tx, int nHeight) {
@@ -94,15 +94,15 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight) {
94
94
void CCoinsViewCache::SpendCoin (const COutPoint &outpoint, Coin* moveout) {
95
95
CCoinsMap::iterator it = FetchCoins (outpoint);
96
96
if (it == cacheCoins.end ()) return ;
97
- cachedCoinsUsage -= it->second .coins .DynamicMemoryUsage ();
97
+ cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
98
98
if (moveout) {
99
- *moveout = std::move (it->second .coins );
99
+ *moveout = std::move (it->second .coin );
100
100
}
101
101
if (it->second .flags & CCoinsCacheEntry::FRESH) {
102
102
cacheCoins.erase (it);
103
103
} else {
104
104
it->second .flags |= CCoinsCacheEntry::DIRTY;
105
- it->second .coins .Clear ();
105
+ it->second .coin .Clear ();
106
106
}
107
107
}
108
108
@@ -113,13 +113,13 @@ const Coin& CCoinsViewCache::AccessCoin(const COutPoint &outpoint) const {
113
113
if (it == cacheCoins.end ()) {
114
114
return coinEmpty;
115
115
} else {
116
- return it->second .coins ;
116
+ return it->second .coin ;
117
117
}
118
118
}
119
119
120
120
bool CCoinsViewCache::HaveCoins (const COutPoint &outpoint) const {
121
121
CCoinsMap::const_iterator it = FetchCoins (outpoint);
122
- return (it != cacheCoins.end () && !it->second .coins .IsPruned ());
122
+ return (it != cacheCoins.end () && !it->second .coin .IsPruned ());
123
123
}
124
124
125
125
bool CCoinsViewCache::HaveCoinsInCache (const COutPoint &outpoint) const {
@@ -144,12 +144,12 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
144
144
if (itUs == cacheCoins.end ()) {
145
145
// The parent cache does not have an entry, while the child does
146
146
// 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 ())) {
148
148
// Otherwise we will need to create it in the parent
149
149
// and move the data up and mark it as dirty
150
150
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 ();
153
153
entry.flags = CCoinsCacheEntry::DIRTY;
154
154
// We can mark it FRESH in the parent if it was FRESH in the child
155
155
// Otherwise it might have just been flushed from the parent's cache
@@ -162,21 +162,21 @@ bool CCoinsViewCache::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlockIn
162
162
// parent cache entry has unspent outputs. If this ever happens,
163
163
// it means the FRESH flag was misapplied and there is a logic
164
164
// 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 ())
166
166
throw std::logic_error (" FRESH flag misapplied to cache entry for base transaction with spendable outputs" );
167
167
168
168
// 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 ()) {
170
170
// The grandparent does not have an entry, and the child is
171
171
// modified and being pruned. This means we can just delete
172
172
// it from the parent.
173
- cachedCoinsUsage -= itUs->second .coins .DynamicMemoryUsage ();
173
+ cachedCoinsUsage -= itUs->second .coin .DynamicMemoryUsage ();
174
174
cacheCoins.erase (itUs);
175
175
} else {
176
176
// 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 ();
180
180
itUs->second .flags |= CCoinsCacheEntry::DIRTY;
181
181
// NOTE: It is possible the child has a FRESH flag here in
182
182
// the event the entry we found in the parent is pruned. But
@@ -204,7 +204,7 @@ void CCoinsViewCache::Uncache(const COutPoint& hash)
204
204
{
205
205
CCoinsMap::iterator it = cacheCoins.find (hash);
206
206
if (it != cacheCoins.end () && it->second .flags == 0 ) {
207
- cachedCoinsUsage -= it->second .coins .DynamicMemoryUsage ();
207
+ cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
208
208
cacheCoins.erase (it);
209
209
}
210
210
}
0 commit comments