10
10
11
11
#include < assert.h>
12
12
13
- bool CCoinsView::GetCoins (const COutPoint &outpoint, Coin &coin) const { return false ; }
14
- bool CCoinsView::HaveCoins (const COutPoint &outpoint) const { return false ; }
13
+ bool CCoinsView::GetCoin (const COutPoint &outpoint, Coin &coin) const { return false ; }
14
+ bool CCoinsView::HaveCoin (const COutPoint &outpoint) const { return false ; }
15
15
uint256 CCoinsView::GetBestBlock () const { return uint256 (); }
16
16
bool CCoinsView::BatchWrite (CCoinsMap &mapCoins, const uint256 &hashBlock) { return false ; }
17
17
CCoinsViewCursor *CCoinsView::Cursor () const { return 0 ; }
18
18
19
19
20
20
CCoinsViewBacked::CCoinsViewBacked (CCoinsView *viewIn) : base(viewIn) { }
21
- bool CCoinsViewBacked::GetCoins (const COutPoint &outpoint, Coin &coin) const { return base->GetCoins (outpoint, coin); }
22
- bool CCoinsViewBacked::HaveCoins (const COutPoint &outpoint) const { return base->HaveCoins (outpoint); }
21
+ bool CCoinsViewBacked::GetCoin (const COutPoint &outpoint, Coin &coin) const { return base->GetCoin (outpoint, coin); }
22
+ bool CCoinsViewBacked::HaveCoin (const COutPoint &outpoint) const { return base->HaveCoin (outpoint); }
23
23
uint256 CCoinsViewBacked::GetBestBlock () const { return base->GetBestBlock (); }
24
24
void CCoinsViewBacked::SetBackend (CCoinsView &viewIn) { base = &viewIn; }
25
25
bool CCoinsViewBacked::BatchWrite (CCoinsMap &mapCoins, const uint256 &hashBlock) { return base->BatchWrite (mapCoins, hashBlock); }
@@ -34,15 +34,15 @@ size_t CCoinsViewCache::DynamicMemoryUsage() const {
34
34
return memusage::DynamicUsage (cacheCoins) + cachedCoinsUsage;
35
35
}
36
36
37
- CCoinsMap::iterator CCoinsViewCache::FetchCoins (const COutPoint &outpoint) const {
37
+ CCoinsMap::iterator CCoinsViewCache::FetchCoin (const COutPoint &outpoint) const {
38
38
CCoinsMap::iterator it = cacheCoins.find (outpoint);
39
39
if (it != cacheCoins.end ())
40
40
return it;
41
41
Coin tmp;
42
- if (!base->GetCoins (outpoint, tmp))
42
+ if (!base->GetCoin (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 .coin .IsPruned ()) {
45
+ if (ret->second .coin .IsSpent ()) {
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;
@@ -51,8 +51,8 @@ CCoinsMap::iterator CCoinsViewCache::FetchCoins(const COutPoint &outpoint) const
51
51
return ret;
52
52
}
53
53
54
- bool CCoinsViewCache::GetCoins (const COutPoint &outpoint, Coin &coin) const {
55
- CCoinsMap::const_iterator it = FetchCoins (outpoint);
54
+ bool CCoinsViewCache::GetCoin (const COutPoint &outpoint, Coin &coin) const {
55
+ CCoinsMap::const_iterator it = FetchCoin (outpoint);
56
56
if (it != cacheCoins.end ()) {
57
57
coin = it->second .coin ;
58
58
return true ;
@@ -61,7 +61,7 @@ bool CCoinsViewCache::GetCoins(const COutPoint &outpoint, Coin &coin) const {
61
61
}
62
62
63
63
void CCoinsViewCache::AddCoin (const COutPoint &outpoint, Coin&& coin, bool possible_overwrite) {
64
- assert (!coin.IsPruned ());
64
+ assert (!coin.IsSpent ());
65
65
if (coin.out .scriptPubKey .IsUnspendable ()) return ;
66
66
CCoinsMap::iterator it;
67
67
bool inserted;
@@ -71,7 +71,7 @@ void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin&& coin, bool possi
71
71
cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
72
72
}
73
73
if (!possible_overwrite) {
74
- if (!it->second .coin .IsPruned ()) {
74
+ if (!it->second .coin .IsSpent ()) {
75
75
throw std::logic_error (" Adding new coin that replaces non-pruned entry" );
76
76
}
77
77
fresh = !(it->second .flags & CCoinsCacheEntry::DIRTY);
@@ -92,7 +92,7 @@ void AddCoins(CCoinsViewCache& cache, const CTransaction &tx, int nHeight) {
92
92
}
93
93
94
94
void CCoinsViewCache::SpendCoin (const COutPoint &outpoint, Coin* moveout) {
95
- CCoinsMap::iterator it = FetchCoins (outpoint);
95
+ CCoinsMap::iterator it = FetchCoin (outpoint);
96
96
if (it == cacheCoins.end ()) return ;
97
97
cachedCoinsUsage -= it->second .coin .DynamicMemoryUsage ();
98
98
if (moveout) {
@@ -109,20 +109,20 @@ void CCoinsViewCache::SpendCoin(const COutPoint &outpoint, Coin* moveout) {
109
109
static const Coin coinEmpty;
110
110
111
111
const Coin& CCoinsViewCache::AccessCoin (const COutPoint &outpoint) const {
112
- CCoinsMap::const_iterator it = FetchCoins (outpoint);
112
+ CCoinsMap::const_iterator it = FetchCoin (outpoint);
113
113
if (it == cacheCoins.end ()) {
114
114
return coinEmpty;
115
115
} else {
116
116
return it->second .coin ;
117
117
}
118
118
}
119
119
120
- bool CCoinsViewCache::HaveCoins (const COutPoint &outpoint) const {
121
- CCoinsMap::const_iterator it = FetchCoins (outpoint);
122
- return (it != cacheCoins.end () && !it->second .coin .IsPruned ());
120
+ bool CCoinsViewCache::HaveCoin (const COutPoint &outpoint) const {
121
+ CCoinsMap::const_iterator it = FetchCoin (outpoint);
122
+ return (it != cacheCoins.end () && !it->second .coin .IsSpent ());
123
123
}
124
124
125
- bool CCoinsViewCache::HaveCoinsInCache (const COutPoint &outpoint) const {
125
+ bool CCoinsViewCache::HaveCoinInCache (const COutPoint &outpoint) const {
126
126
CCoinsMap::const_iterator it = cacheCoins.find (outpoint);
127
127
return it != cacheCoins.end ();
128
128
}
@@ -144,7 +144,7 @@ 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 .coin .IsPruned ())) {
147
+ if (!(it->second .flags & CCoinsCacheEntry::FRESH && it->second .coin .IsSpent ())) {
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 ];
@@ -162,11 +162,11 @@ 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 .coin .IsPruned ())
165
+ if ((it->second .flags & CCoinsCacheEntry::FRESH) && !itUs->second .coin .IsSpent ())
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 .coin .IsPruned ()) {
169
+ if ((itUs->second .flags & CCoinsCacheEntry::FRESH) && it->second .coin .IsSpent ()) {
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.
@@ -229,7 +229,7 @@ bool CCoinsViewCache::HaveInputs(const CTransaction& tx) const
229
229
{
230
230
if (!tx.IsCoinBase ()) {
231
231
for (unsigned int i = 0 ; i < tx.vin .size (); i++) {
232
- if (!HaveCoins (tx.vin [i].prevout )) {
232
+ if (!HaveCoin (tx.vin [i].prevout )) {
233
233
return false ;
234
234
}
235
235
}
@@ -244,7 +244,7 @@ const Coin& AccessByTxid(const CCoinsViewCache& view, const uint256& txid)
244
244
COutPoint iter (txid, 0 );
245
245
while (iter.n < MAX_OUTPUTS_PER_BLOCK) {
246
246
const Coin& alternate = view.AccessCoin (iter);
247
- if (!alternate.IsPruned ()) return alternate;
247
+ if (!alternate.IsSpent ()) return alternate;
248
248
++iter.n ;
249
249
}
250
250
return coinEmpty;
0 commit comments