mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
Move CCoins-related logic to coins.{cpp.h}
This commit is contained in:
43
src/core.cpp
43
src/core.cpp
@@ -183,49 +183,6 @@ uint64_t CTxOutCompressor::DecompressAmount(uint64_t x)
|
||||
return n;
|
||||
}
|
||||
|
||||
// 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(const COutPoint &out, CTxInUndo &undo) {
|
||||
if (out.n >= vout.size())
|
||||
return false;
|
||||
if (vout[out.n].IsNull())
|
||||
return false;
|
||||
undo = CTxInUndo(vout[out.n]);
|
||||
vout[out.n].SetNull();
|
||||
Cleanup();
|
||||
if (vout.size() == 0) {
|
||||
undo.nHeight = nHeight;
|
||||
undo.fCoinBase = fCoinBase;
|
||||
undo.nVersion = this->nVersion;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CCoins::Spend(int nPos) {
|
||||
CTxInUndo undo;
|
||||
COutPoint out(0, nPos);
|
||||
return Spend(out, undo);
|
||||
}
|
||||
|
||||
uint256 CBlockHeader::GetHash() const
|
||||
{
|
||||
return Hash(BEGIN(nVersion), END(nNonce));
|
||||
|
||||
Reference in New Issue
Block a user