Changeset View
Changeset View
Standalone View
Standalone View
src/coins.cpp
// Copyright (c) 2012-2016 The Bitcoin Core developers | // Copyright (c) 2012-2016 The Bitcoin Core developers | ||||
// Distributed under the MIT software license, see the accompanying | // Distributed under the MIT software license, see the accompanying | ||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | // file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||||
#include <coins.h> | #include <coins.h> | ||||
#include <consensus/consensus.h> | #include <consensus/consensus.h> | ||||
#include <memusage.h> | #include <memusage.h> | ||||
#include <random.h> | #include <random.h> | ||||
#include <version.h> | #include <version.h> | ||||
#include <cassert> | #include <cassert> | ||||
bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { | bool CCoinsView::GetCoin(const COutPoint &outpoint, Coin &coin) const { | ||||
return false; | return false; | ||||
} | } | ||||
bool CCoinsView::HaveCoin(const COutPoint &outpoint) const { | |||||
return false; | |||||
} | |||||
uint256 CCoinsView::GetBestBlock() const { | uint256 CCoinsView::GetBestBlock() const { | ||||
return uint256(); | return uint256(); | ||||
} | } | ||||
std::vector<uint256> CCoinsView::GetHeadBlocks() const { | std::vector<uint256> CCoinsView::GetHeadBlocks() const { | ||||
return std::vector<uint256>(); | return std::vector<uint256>(); | ||||
} | } | ||||
bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { | bool CCoinsView::BatchWrite(CCoinsMap &mapCoins, const uint256 &hashBlock) { | ||||
return false; | return false; | ||||
} | } | ||||
CCoinsViewCursor *CCoinsView::Cursor() const { | CCoinsViewCursor *CCoinsView::Cursor() const { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
bool CCoinsView::HaveCoin(const COutPoint &outpoint) const { | |||||
Coin coin; | |||||
return GetCoin(outpoint, coin); | |||||
} | |||||
CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) {} | CCoinsViewBacked::CCoinsViewBacked(CCoinsView *viewIn) : base(viewIn) {} | ||||
bool CCoinsViewBacked::GetCoin(const COutPoint &outpoint, Coin &coin) const { | bool CCoinsViewBacked::GetCoin(const COutPoint &outpoint, Coin &coin) const { | ||||
return base->GetCoin(outpoint, coin); | return base->GetCoin(outpoint, coin); | ||||
} | } | ||||
bool CCoinsViewBacked::HaveCoin(const COutPoint &outpoint) const { | bool CCoinsViewBacked::HaveCoin(const COutPoint &outpoint) const { | ||||
return base->HaveCoin(outpoint); | return base->HaveCoin(outpoint); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 53 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
bool CCoinsViewCache::GetCoin(const COutPoint &outpoint, Coin &coin) const { | bool CCoinsViewCache::GetCoin(const COutPoint &outpoint, Coin &coin) const { | ||||
CCoinsMap::const_iterator it = FetchCoin(outpoint); | CCoinsMap::const_iterator it = FetchCoin(outpoint); | ||||
if (it == cacheCoins.end()) { | if (it == cacheCoins.end()) { | ||||
return false; | return false; | ||||
} | } | ||||
coin = it->second.coin; | coin = it->second.coin; | ||||
return true; | return !coin.IsSpent(); | ||||
} | } | ||||
void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin coin, | void CCoinsViewCache::AddCoin(const COutPoint &outpoint, Coin coin, | ||||
bool possible_overwrite) { | bool possible_overwrite) { | ||||
assert(!coin.IsSpent()); | assert(!coin.IsSpent()); | ||||
if (coin.GetTxOut().scriptPubKey.IsUnspendable()) { | if (coin.GetTxOut().scriptPubKey.IsUnspendable()) { | ||||
return; | return; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 236 Lines • Show Last 20 Lines |