Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Public Member Functions | Protected Attributes | Private Member Functions | List of all members
CCoinsViewCache Class Reference

CCoinsView that adds a memory cache for transactions to another CCoinsView. More...

#include <coins.h>

+ Inheritance diagram for CCoinsViewCache:
+ Collaboration diagram for CCoinsViewCache:

Public Member Functions

 CCoinsViewCache (CCoinsView &baseIn, bool fDummy=false)
 
bool GetCoins (const uint256 &txid, CCoins &coins)
 
bool SetCoins (const uint256 &txid, const CCoins &coins)
 
bool HaveCoins (const uint256 &txid)
 
uint256 GetBestBlock ()
 
bool SetBestBlock (const uint256 &hashBlock)
 
bool BatchWrite (const std::map< uint256, CCoins > &mapCoins, const uint256 &hashBlock)
 
CCoinsGetCoins (const uint256 &txid)
 
bool Flush ()
 
unsigned int GetCacheSize ()
 
int64_t GetValueIn (const CTransaction &tx)
 Amount of bitcoins coming in to a transaction Note that lightweight clients may not know anything besides the hash of previous transactions, so may not be able to calculate this. More...
 
bool HaveInputs (const CTransaction &tx)
 
double GetPriority (const CTransaction &tx, int nHeight)
 
const CTxOutGetOutputFor (const CTxIn &input)
 
- Public Member Functions inherited from CCoinsViewBacked
 CCoinsViewBacked (CCoinsView &viewIn)
 
void SetBackend (CCoinsView &viewIn)
 
bool GetStats (CCoinsStats &stats)
 
- Public Member Functions inherited from CCoinsView
virtual ~CCoinsView ()
 

Protected Attributes

uint256 hashBlock
 
std::map< uint256, CCoinscacheCoins
 
- Protected Attributes inherited from CCoinsViewBacked
CCoinsViewbase
 

Private Member Functions

std::map< uint256, CCoins >::iterator FetchCoins (const uint256 &txid)
 

Detailed Description

CCoinsView that adds a memory cache for transactions to another CCoinsView.

Definition at line 308 of file coins.h.

Constructor & Destructor Documentation

CCoinsViewCache::CCoinsViewCache ( CCoinsView baseIn,
bool  fDummy = false 
)

Definition at line 72 of file coins.cpp.

Member Function Documentation

bool CCoinsViewCache::BatchWrite ( const std::map< uint256, CCoins > &  mapCoins,
const uint256 hashBlock 
)
virtual

Reimplemented from CCoinsViewBacked.

Definition at line 124 of file coins.cpp.

References cacheCoins, and hashBlock.

std::map< uint256, CCoins >::iterator CCoinsViewCache::FetchCoins ( const uint256 txid)
private

Definition at line 86 of file coins.cpp.

References CCoinsViewBacked::base, cacheCoins, CCoinsView::GetCoins(), and CCoins::swap().

Referenced by GetCoins(), and HaveCoins().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CCoinsViewCache::Flush ( )

Definition at line 131 of file coins.cpp.

References CCoinsViewBacked::base, CCoinsView::BatchWrite(), cacheCoins, and hashBlock.

Referenced by ConnectTip(), DisconnectTip(), Shutdown(), and WriteChainState().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

uint256 CCoinsViewCache::GetBestBlock ( )
virtual

Reimplemented from CCoinsViewBacked.

Definition at line 113 of file coins.cpp.

References CCoinsViewBacked::base, CCoinsView::GetBestBlock(), and hashBlock.

Referenced by AcceptToMemoryPool(), CheckInputs(), ConnectBlock(), DisconnectBlock(), gettxout(), and LoadBlockIndexDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int CCoinsViewCache::GetCacheSize ( )

Definition at line 138 of file coins.cpp.

References cacheCoins.

Referenced by VerifyDB(), and WriteChainState().

+ Here is the caller graph for this function:

bool CCoinsViewCache::GetCoins ( const uint256 txid,
CCoins coins 
)
virtual

Reimplemented from CCoinsViewBacked.

Definition at line 74 of file coins.cpp.

References CCoinsViewBacked::base, cacheCoins, and CCoinsView::GetCoins().

Referenced by CTxMemPool::check(), CheckInputs(), ConnectBlock(), CreateNewBlock(), DisconnectBlock(), GetOutputFor(), GetPriority(), GetTransaction(), gettxout(), HaveInputs(), sendrawtransaction(), signrawtransaction(), TransactionDesc::toHTML(), and UpdateCoins().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CCoins & CCoinsViewCache::GetCoins ( const uint256 txid)

Definition at line 98 of file coins.cpp.

References cacheCoins, and FetchCoins().

+ Here is the call graph for this function:

const CTxOut & CCoinsViewCache::GetOutputFor ( const CTxIn input)

Definition at line 142 of file coins.cpp.

References GetCoins(), COutPoint::hash, CCoins::IsAvailable(), COutPoint::n, CTxIn::prevout, and CCoins::vout.

Referenced by AreInputsStandard(), GetP2SHSigOpCount(), and GetValueIn().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

double CCoinsViewCache::GetPriority ( const CTransaction tx,
int  nHeight 
)

Definition at line 182 of file coins.cpp.

References CTransaction::ComputePriority(), GetCoins(), COutPoint::hash, CCoins::IsAvailable(), CTransaction::IsCoinBase(), COutPoint::n, CCoins::nHeight, CTxIn::prevout, CTransaction::vin, and CCoins::vout.

Referenced by AcceptToMemoryPool().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t CCoinsViewCache::GetValueIn ( const CTransaction tx)

Amount of bitcoins coming in to a transaction Note that lightweight clients may not know anything besides the hash of previous transactions, so may not be able to calculate this.

Parameters
[in]txtransaction for which we are checking input total
Returns
Sum of value of all inputs (scriptSigs)

Definition at line 149 of file coins.cpp.

References GetOutputFor(), CTransaction::IsCoinBase(), CTxOut::nValue, and CTransaction::vin.

Referenced by AcceptToMemoryPool(), ConnectBlock(), and CreateNewBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CCoinsViewCache::HaveCoins ( const uint256 txid)
virtual

Reimplemented from CCoinsViewBacked.

Definition at line 109 of file coins.cpp.

References cacheCoins, and FetchCoins().

Referenced by AcceptToMemoryPool(), AlreadyHave(), ConnectBlock(), CreateNewBlock(), DisconnectBlock(), and HaveInputs().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CCoinsViewCache::HaveInputs ( const CTransaction tx)

Definition at line 161 of file coins.cpp.

References GetCoins(), COutPoint::hash, HaveCoins(), CCoins::IsAvailable(), CTransaction::IsCoinBase(), COutPoint::n, and CTransaction::vin.

Referenced by AcceptToMemoryPool(), CheckInputs(), ConnectBlock(), and CreateNewBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CCoinsViewCache::SetBestBlock ( const uint256 hashBlock)
virtual

Reimplemented from CCoinsViewBacked.

Definition at line 119 of file coins.cpp.

References hashBlock.

Referenced by ConnectBlock(), and DisconnectBlock().

+ Here is the caller graph for this function:

bool CCoinsViewCache::SetCoins ( const uint256 txid,
const CCoins coins 
)
virtual

Reimplemented from CCoinsViewBacked.

Definition at line 104 of file coins.cpp.

References cacheCoins.

Referenced by DisconnectBlock(), signrawtransaction(), and UpdateCoins().

+ Here is the caller graph for this function:

Member Data Documentation

std::map<uint256,CCoins> CCoinsViewCache::cacheCoins
protected

Definition at line 312 of file coins.h.

Referenced by BatchWrite(), FetchCoins(), Flush(), GetCacheSize(), GetCoins(), HaveCoins(), and SetCoins().

uint256 CCoinsViewCache::hashBlock
protected

Definition at line 311 of file coins.h.

Referenced by BatchWrite(), Flush(), GetBestBlock(), and SetBestBlock().


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