PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Public Member Functions | Public Attributes | Friends | List of all members
CCoins Class Reference

#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
 
bool IsCoinStake () const
 
unsigned int GetSerializeSize (int nType, int nVersion) const
 
template<typename Stream >
void Serialize (Stream &s, int nType, int nVersion) const
 
template<typename Stream >
void Unserialize (Stream &s, int nType, int nVersion)
 
bool Spend (const COutPoint &out, CTxInUndo &undo)
 mark an outpoint spent, and construct undo information More...
 
bool Spend (int 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...
 
bool fCoinStake
 
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

Note - for PRCY we added fCoinStake to the 2nd bit. Keep in mind when reading the following and adjust as needed.

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 77 of file coins.h.

Constructor & Destructor Documentation

◆ CCoins() [1/2]

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

construct a CCoins from a CTransaction, at a given height

Definition at line 105 of file coins.h.

Here is the call graph for this function:

◆ CCoins() [2/2]

CCoins::CCoins ( )
inline

empty constructor

Definition at line 120 of file coins.h.

Member Function Documentation

◆ CalcMaskSize()

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 19 of file coins.cpp.

Here is the caller graph for this function:

◆ Cleanup()

void CCoins::Cleanup ( )
inline

remove spent outputs at the end of vout

Definition at line 123 of file coins.h.

Here is the caller graph for this function:

◆ Clear()

void CCoins::Clear ( )
inline

Definition at line 110 of file coins.h.

Here is the caller graph for this function:

◆ ClearUnspendable()

void CCoins::ClearUnspendable ( )
inline

Definition at line 131 of file coins.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ DynamicMemoryUsage()

size_t CCoins::DynamicMemoryUsage ( ) const
inline

Definition at line 290 of file coins.h.

◆ FromTx()

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

Definition at line 94 of file coins.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetSerializeSize()

unsigned int CCoins::GetSerializeSize ( int  nType,
int  nVersion 
) const
inline

Definition at line 178 of file coins.h.

Here is the call graph for this function:

◆ IsAvailable()

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

check whether a particular output is still available

Definition at line 275 of file coins.h.

Here is the caller graph for this function:

◆ IsCoinBase()

bool CCoins::IsCoinBase ( ) const
inline

Definition at line 168 of file coins.h.

Here is the caller graph for this function:

◆ IsCoinStake()

bool CCoins::IsCoinStake ( ) const
inline

Definition at line 173 of file coins.h.

Here is the caller graph for this function:

◆ IsPruned()

bool CCoins::IsPruned ( ) const
inline

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

Definition at line 282 of file coins.h.

Here is the caller graph for this function:

◆ Serialize()

template<typename Stream >
void CCoins::Serialize ( Stream &  s,
int  nType,
int  nVersion 
) const
inline

Definition at line 203 of file coins.h.

Here is the call graph for this function:

◆ Spend() [1/2]

bool CCoins::Spend ( const COutPoint out,
CTxInUndo undo 
)

mark an outpoint spent, and construct undo information

Definition at line 38 of file coins.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Spend() [2/2]

bool CCoins::Spend ( int  nPos)

mark a vout spent

Definition at line 58 of file coins.cpp.

Here is the call graph for this function:

◆ swap()

void CCoins::swap ( CCoins to)
inline

Definition at line 140 of file coins.h.

Here is the caller graph for this function:

◆ Unserialize()

template<typename Stream >
void CCoins::Unserialize ( Stream &  s,
int  nType,
int  nVersion 
)
inline

Definition at line 233 of file coins.h.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator!=

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

Definition at line 161 of file coins.h.

◆ operator==

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

equality test

Definition at line 150 of file coins.h.

Member Data Documentation

◆ fCoinBase

bool CCoins::fCoinBase

whether transaction is a coinbase

Definition at line 81 of file coins.h.

◆ fCoinStake

bool CCoins::fCoinStake

Definition at line 82 of file coins.h.

◆ nHeight

int CCoins::nHeight

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

Definition at line 88 of file coins.h.

◆ nVersion

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 92 of file coins.h.

◆ vout

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 85 of file coins.h.


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