|
|
|
@ -55,7 +55,7 @@ bool CCoinsView::SetCoins(const uint256 &txid, const CCoins &coins) { return fal
@@ -55,7 +55,7 @@ bool CCoinsView::SetCoins(const uint256 &txid, const CCoins &coins) { return fal
|
|
|
|
|
bool CCoinsView::HaveCoins(const uint256 &txid) { return false; } |
|
|
|
|
uint256 CCoinsView::GetBestBlock() { return uint256(0); } |
|
|
|
|
bool CCoinsView::SetBestBlock(const uint256 &hashBlock) { return false; } |
|
|
|
|
bool CCoinsView::BatchWrite(const std::map<uint256, CCoins> &mapCoins, const uint256 &hashBlock) { return false; } |
|
|
|
|
bool CCoinsView::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) { return false; } |
|
|
|
|
bool CCoinsView::GetStats(CCoinsStats &stats) { return false; } |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -66,7 +66,7 @@ bool CCoinsViewBacked::HaveCoins(const uint256 &txid) { return base->HaveCoins(t
@@ -66,7 +66,7 @@ bool CCoinsViewBacked::HaveCoins(const uint256 &txid) { return base->HaveCoins(t
|
|
|
|
|
uint256 CCoinsViewBacked::GetBestBlock() { return base->GetBestBlock(); } |
|
|
|
|
bool CCoinsViewBacked::SetBestBlock(const uint256 &hashBlock) { return base->SetBestBlock(hashBlock); } |
|
|
|
|
void CCoinsViewBacked::SetBackend(CCoinsView &viewIn) { base = &viewIn; } |
|
|
|
|
bool CCoinsViewBacked::BatchWrite(const std::map<uint256, CCoins> &mapCoins, const uint256 &hashBlock) { return base->BatchWrite(mapCoins, hashBlock); } |
|
|
|
|
bool CCoinsViewBacked::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlock) { return base->BatchWrite(mapCoins, hashBlock); } |
|
|
|
|
bool CCoinsViewBacked::GetStats(CCoinsStats &stats) { return base->GetStats(stats); } |
|
|
|
|
|
|
|
|
|
CCoinsViewCache::CCoinsViewCache(CCoinsView &baseIn, bool fDummy) : CCoinsViewBacked(baseIn), hashBlock(0) { } |
|
|
|
@ -83,20 +83,20 @@ bool CCoinsViewCache::GetCoins(const uint256 &txid, CCoins &coins) {
@@ -83,20 +83,20 @@ bool CCoinsViewCache::GetCoins(const uint256 &txid, CCoins &coins) {
|
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
std::map<uint256,CCoins>::iterator CCoinsViewCache::FetchCoins(const uint256 &txid) { |
|
|
|
|
std::map<uint256,CCoins>::iterator it = cacheCoins.lower_bound(txid); |
|
|
|
|
CCoinsMap::iterator CCoinsViewCache::FetchCoins(const uint256 &txid) { |
|
|
|
|
CCoinsMap::iterator it = cacheCoins.lower_bound(txid); |
|
|
|
|
if (it != cacheCoins.end() && it->first == txid) |
|
|
|
|
return it; |
|
|
|
|
CCoins tmp; |
|
|
|
|
if (!base->GetCoins(txid,tmp)) |
|
|
|
|
return cacheCoins.end(); |
|
|
|
|
std::map<uint256,CCoins>::iterator ret = cacheCoins.insert(it, std::make_pair(txid, CCoins())); |
|
|
|
|
CCoinsMap::iterator ret = cacheCoins.insert(it, std::make_pair(txid, CCoins())); |
|
|
|
|
tmp.swap(ret->second); |
|
|
|
|
return ret; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
CCoins &CCoinsViewCache::GetCoins(const uint256 &txid) { |
|
|
|
|
std::map<uint256,CCoins>::iterator it = FetchCoins(txid); |
|
|
|
|
CCoinsMap::iterator it = FetchCoins(txid); |
|
|
|
|
assert(it != cacheCoins.end()); |
|
|
|
|
return it->second; |
|
|
|
|
} |
|
|
|
@ -121,8 +121,8 @@ bool CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
@@ -121,8 +121,8 @@ bool CCoinsViewCache::SetBestBlock(const uint256 &hashBlockIn) {
|
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
bool CCoinsViewCache::BatchWrite(const std::map<uint256, CCoins> &mapCoins, const uint256 &hashBlockIn) { |
|
|
|
|
for (std::map<uint256, CCoins>::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++) |
|
|
|
|
bool CCoinsViewCache::BatchWrite(const CCoinsMap &mapCoins, const uint256 &hashBlockIn) { |
|
|
|
|
for (CCoinsMap::const_iterator it = mapCoins.begin(); it != mapCoins.end(); it++) |
|
|
|
|
cacheCoins[it->first] = it->second; |
|
|
|
|
hashBlock = hashBlockIn; |
|
|
|
|
return true; |
|
|
|
|