Bitcoin Core  0.14.99
P2P Digital Currency
Public Member Functions | Public Attributes | Friends | List of all members
CCoins Class Reference

Pruned version of CTransaction: only retains metadata and unspent transaction outputs. More...

#include <coins.h>

Public Member Functions

void FromTx (const CTransaction &tx, int nHeightIn)
 
 CCoins (const CTransaction &tx, int nHeightIn)
 construct a CCoins from a CTransaction, at a given height More...
 
void Clear ()
 
 CCoins ()
 empty constructor More...
 
void Cleanup ()
 remove spent outputs at the end of vout More...
 
void ClearUnspendable ()
 
void swap (CCoins &to)
 
void CalcMaskSize (unsigned int &nBytes, unsigned int &nNonzeroBytes) const
 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 More...
 
bool IsCoinBase () const
 
template<typename Stream >
void Serialize (Stream &s) const
 
template<typename Stream >
void Unserialize (Stream &s)
 
bool Spend (uint32_t nPos)
 mark a vout spent More...
 
bool IsAvailable (unsigned int nPos) const
 check whether a particular output is still available More...
 
bool IsPruned () const
 check whether the entire CCoins is spent note that only !IsPruned() CCoins can be serialized More...
 
size_t DynamicMemoryUsage () const
 

Public Attributes

bool fCoinBase
 whether transaction is a coinbase More...
 
std::vector< CTxOutvout
 unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are dropped More...
 
int nHeight
 at which height this transaction was included in the active block chain More...
 
int nVersion
 version of the CTransaction; accesses to this value should probably check for nHeight as well, as new tx version will probably only be introduced at certain heights More...
 

Friends

bool operator== (const CCoins &a, const CCoins &b)
 equality test More...
 
bool operator!= (const CCoins &a, const CCoins &b)
 

Detailed Description

Pruned version of CTransaction: only retains metadata and unspent transaction outputs.

Serialized format:

The nCode value consists of:

Example: 0104835800816115944e077fe7c803cfa57f29b36bf87c1d358bb85e <><><-----------------------------------------—><-—> | \ | / version code vout[1] height

Example: 0109044086ef97d5790061b01caab50f1b8e9c50a5057eb43c2d9563a4eebbd123008c988f1a4a4de2161e0f50aac7f17e7f9555caa486af3b <><><–><-----------------------------------------------—><-------------------------------------------—><-—> / \ \ | | / version code unspentness vout[4] vout[16] height

Definition at line 75 of file coins.h.

Constructor & Destructor Documentation

CCoins::CCoins ( const CTransaction tx,
int  nHeightIn 
)
inline

construct a CCoins from a CTransaction, at a given height

Definition at line 100 of file coins.h.

Here is the call graph for this function:

CCoins::CCoins ( )
inline

empty constructor

Definition at line 112 of file coins.h.

Member Function Documentation

void CCoins::CalcMaskSize ( unsigned int &  nBytes,
unsigned int &  nNonzeroBytes 
) const

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

Definition at line 17 of file coins.cpp.

Here is the caller graph for this function:

void CCoins::Cleanup ( )
inline

remove spent outputs at the end of vout

Definition at line 115 of file coins.h.

Here is the caller graph for this function:

void CCoins::Clear ( )
inline

Definition at line 104 of file coins.h.

Here is the call graph for this function:

Here is the caller graph for this function:

void CCoins::ClearUnspendable ( )
inline

Definition at line 122 of file coins.h.

Here is the call graph for this function:

Here is the caller graph for this function:

size_t CCoins::DynamicMemoryUsage ( ) const
inline

Definition at line 237 of file coins.h.

Here is the caller graph for this function:

void CCoins::FromTx ( const CTransaction tx,
int  nHeightIn 
)
inline

Definition at line 91 of file coins.h.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CCoins::IsAvailable ( unsigned int  nPos) const
inline

check whether a particular output is still available

Definition at line 224 of file coins.h.

Here is the caller graph for this function:

bool CCoins::IsCoinBase ( ) const
inline

Definition at line 153 of file coins.h.

Here is the caller graph for this function:

bool CCoins::IsPruned ( ) const
inline

check whether the entire CCoins is spent note that only !IsPruned() CCoins can be serialized

Definition at line 230 of file coins.h.

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename Stream >
void CCoins::Serialize ( Stream &  s) const
inline

Definition at line 158 of file coins.h.

Here is the call graph for this function:

bool CCoins::Spend ( uint32_t  nPos)

mark a vout spent

Definition at line 35 of file coins.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void CCoins::swap ( CCoins to)
inline

Definition at line 130 of file coins.h.

Here is the caller graph for this function:

template<typename Stream >
void CCoins::Unserialize ( Stream &  s)
inline

Definition at line 187 of file coins.h.

Here is the call graph for this function:

Friends And Related Function Documentation

bool operator!= ( const CCoins a,
const CCoins b 
)
friend

Definition at line 147 of file coins.h.

bool operator== ( const CCoins a,
const CCoins b 
)
friend

equality test

Definition at line 138 of file coins.h.

Member Data Documentation

bool CCoins::fCoinBase

whether transaction is a coinbase

Definition at line 79 of file coins.h.

int CCoins::nHeight

at which height this transaction was included in the active block chain

Definition at line 85 of file coins.h.

int CCoins::nVersion

version of the CTransaction; accesses to this value should probably check for nHeight as well, as new tx version will probably only be introduced at certain heights

Definition at line 89 of file coins.h.

std::vector<CTxOut> CCoins::vout

unspent transaction outputs; spent outputs are .IsNull(); spent outputs at the end of the array are dropped

Definition at line 82 of file coins.h.


The documentation for this class was generated from the following files: