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 <cassert> | #include <cassert> | ||||
/** | |||||
* calculate number of bytes for the bitmask, and its number of non-zero bytes | |||||
* each bit in the bitmask represents the availability of one output, but the | |||||
* availabilities of the first two outputs are encoded separately | |||||
*/ | |||||
void CCoins::CalcMaskSize(unsigned int &nBytes, | |||||
unsigned int &nNonzeroBytes) const { | |||||
unsigned int nLastUsedByte = 0; | |||||
for (unsigned int b = 0; 2 + b * 8 < vout.size(); b++) { | |||||
bool fZero = true; | |||||
for (unsigned int i = 0; i < 8 && 2 + b * 8 + i < vout.size(); i++) { | |||||
if (!vout[2 + b * 8 + i].IsNull()) { | |||||
fZero = false; | |||||
continue; | |||||
} | |||||
} | |||||
if (!fZero) { | |||||
nLastUsedByte = b + 1; | |||||
nNonzeroBytes++; | |||||
} | |||||
} | |||||
nBytes += nLastUsedByte; | |||||
} | |||||
bool CCoins::Spend(uint32_t nPos) { | |||||
if (nPos >= vout.size() || vout[nPos].IsNull()) return false; | |||||
vout[nPos].SetNull(); | |||||
Cleanup(); | |||||
return true; | |||||
} | |||||
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 { | bool CCoinsView::HaveCoin(const COutPoint &outpoint) const { | ||||
return false; | return false; | ||||
} | } | ||||
uint256 CCoinsView::GetBestBlock() const { | uint256 CCoinsView::GetBestBlock() const { | ||||
return uint256(); | return uint256(); | ||||
▲ Show 20 Lines • Show All 317 Lines • Show Last 20 Lines |