Master Core  v0.0.9 - 2abfd2849db8ba7a83957c64eb976b406713c123
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
main.cpp File Reference
#include "main.h"
#include "addrman.h"
#include "alert.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "checkqueue.h"
#include "init.h"
#include "net.h"
#include "txdb.h"
#include "txmempool.h"
#include "ui_interface.h"
#include "util.h"
#include <sstream>
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
+ Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

struct  COrphanBlock
 
struct  COrphanTx
 
class  CMainCleanup
 

Functions

int mastercore_handler_disc_begin (int nBlockNow, CBlockIndex const *pBlockIndex)
 
int mastercore_handler_disc_end (int nBlockNow, CBlockIndex const *pBlockIndex)
 
int mastercore_handler_block_begin (int nBlockNow, CBlockIndex const *pBlockIndex)
 
int mastercore_handler_block_end (int nBlockNow, CBlockIndex const *pBlockIndex, unsigned int)
 
int mastercore_handler_tx (const CTransaction &tx, int nBlock, unsigned int idx, CBlockIndex const *pBlockIndex)
 
void EraseOrphansFor (NodeId peer)
 
void RegisterWallet (CWalletInterface *pwalletIn)
 Register a wallet to receive updates from core. More...
 
void UnregisterWallet (CWalletInterface *pwalletIn)
 Unregister a wallet from core. More...
 
void UnregisterAllWallets ()
 Unregister all wallets from core. More...
 
void SyncWithWallets (const uint256 &hash, const CTransaction &tx, const CBlock *pblock)
 Push an updated transaction to all registered wallets. More...
 
bool GetNodeStateStats (NodeId nodeid, CNodeStateStats &stats)
 Get statistics from node state. More...
 
void RegisterNodeSignals (CNodeSignals &nodeSignals)
 Register with a network node to receive its signals. More...
 
void UnregisterNodeSignals (CNodeSignals &nodeSignals)
 Unregister a network node. More...
 
bool AddOrphanTx (const CTransaction &tx, NodeId peer)
 
static void EraseOrphanTx (uint256 hash)
 
unsigned int LimitOrphanTxSize (unsigned int nMaxOrphans)
 
bool IsStandardTx (const CTransaction &tx, string &reason)
 Check for standard transaction types. More...
 
bool IsFinalTx (const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
 
bool AreInputsStandard (const CTransaction &tx, CCoinsViewCache &mapInputs)
 Check for standard transaction types. More...
 
unsigned int GetLegacySigOpCount (const CTransaction &tx)
 Count ECDSA signature operations the old-fashioned (pre-0.6) way. More...
 
unsigned int GetP2SHSigOpCount (const CTransaction &tx, CCoinsViewCache &inputs)
 Count ECDSA signature operations in pay-to-script-hash inputs. More...
 
bool CheckTransaction (const CTransaction &tx, CValidationState &state)
 
int64_t GetMinFee (const CTransaction &tx, unsigned int nBytes, bool fAllowFree, enum GetMinFee_mode mode)
 
bool AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee)
 (try to) add transaction to memory pool More...
 
bool GetTransaction (const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow)
 Retrieve a transaction (from memory pool, or from disk, if possible) More...
 
bool WriteBlockToDisk (CBlock &block, CDiskBlockPos &pos)
 Functions for disk access for blocks. More...
 
bool ReadBlockFromDisk (CBlock &block, const CDiskBlockPos &pos)
 
bool ReadBlockFromDisk (CBlock &block, const CBlockIndex *pindex)
 
static uint256 GetOrphanRoot (const uint256 &hash)
 
static void PruneOrphanBlocks ()
 
int64_t GetBlockValue (int nHeight, int64_t nFees)
 
unsigned int ComputeMinWork (unsigned int nBase, int64_t nTime)
 Calculate the minimum amount of work a received block needs, without knowing its direct parent. More...
 
unsigned int GetNextWorkRequired (const CBlockIndex *pindexLast, const CBlockHeader *pblock)
 
bool CheckProofOfWork (uint256 hash, unsigned int nBits)
 Check whether a block hash satisfies the proof-of-work requirement specified by nBits. More...
 
bool IsInitialBlockDownload ()
 Check whether we are doing an initial block download (synchronizing from disk or network) More...
 
void CheckForkWarningConditions ()
 
void CheckForkWarningConditionsOnNewFork (CBlockIndex *pindexNewForkTip)
 
void Misbehaving (NodeId pnode, int howmuch)
 Increase a node's misbehavior score. More...
 
static void InvalidChainFound (CBlockIndex *pindexNew)
 
static void InvalidBlockFound (CBlockIndex *pindex, const CValidationState &state)
 
void UpdateTime (CBlockHeader &block, const CBlockIndex *pindexPrev)
 
void UpdateCoins (const CTransaction &tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight, const uint256 &txhash)
 
bool VerifySignature (const CCoins &txFrom, const CTransaction &txTo, unsigned int nIn, unsigned int flags, int nHashType)
 Verify a signature. More...
 
bool CheckInputs (const CTransaction &tx, CValidationState &state, CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, std::vector< CScriptCheck > *pvChecks)
 
bool DisconnectBlock (CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool *pfClean)
 Functions for validating blocks and updating the block tree. More...
 
static void FlushBlockFile (bool fFinalize=false)
 
bool FindUndoPos (CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize)
 
void ThreadScriptCheck ()
 Run an instance of the script checking thread. More...
 
bool ConnectBlock (CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool fJustCheck)
 
static bool WriteChainState (CValidationState &state)
 
static void UpdateTip (CBlockIndex *pindexNew)
 
static bool DisconnectTip (CValidationState &state)
 
static bool ConnectTip (CValidationState &state, CBlockIndex *pindexNew)
 
static void FindMostWorkChain ()
 
bool ActivateBestChain (CValidationState &state)
 Find the best known block, and make it the tip of the block chain. More...
 
bool AddToBlockIndex (CBlock &block, CValidationState &state, const CDiskBlockPos &pos)
 
bool FindBlockPos (CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown=false)
 
bool CheckBlock (const CBlock &block, CValidationState &state, bool fCheckPOW, bool fCheckMerkleRoot)
 
bool AcceptBlock (CBlock &block, CValidationState &state, CDiskBlockPos *dbp)
 
void PushGetBlocks (CNode *pnode, CBlockIndex *pindexBegin, uint256 hashEnd)
 
bool ProcessBlock (CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp)
 Process an incoming block. More...
 
bool AbortNode (const std::string &strMessage)
 Abort with a message. More...
 
bool CheckDiskSpace (uint64_t nAdditionalBytes)
 Check whether enough disk space is available for an incoming block. More...
 
FILE * OpenDiskFile (const CDiskBlockPos &pos, const char *prefix, bool fReadOnly)
 
FILE * OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly)
 Open a block file (blk?????.dat) More...
 
FILE * OpenUndoFile (const CDiskBlockPos &pos, bool fReadOnly)
 Open an undo file (rev?????.dat) More...
 
CBlockIndexInsertBlockIndex (uint256 hash)
 Create a new block index entry for a given block hash. More...
 
static bool LoadBlockIndexDB ()
 
bool VerifyDB (int nCheckLevel, int nCheckDepth)
 Verify consistency of the block and coin databases. More...
 
void UnloadBlockIndex ()
 Unload database information. More...
 
bool LoadBlockIndex ()
 Load the block tree and coins database from disk. More...
 
bool InitBlockIndex ()
 Initialize a new block tree database + block data on disk. More...
 
void PrintBlockTree ()
 Print the loaded block tree. More...
 
bool LoadExternalBlockFile (FILE *fileIn, CDiskBlockPos *dbp)
 Import blocks from an external file. More...
 
string GetWarnings (string strFor)
 Format a string that describes several potential problems detected by the core. More...
 
static bool AlreadyHave (const CInv &inv)
 
static void ProcessGetData (CNode *pfrom)
 
static bool ProcessMessage (CNode *pfrom, string strCommand, CDataStream &vRecv)
 
bool ProcessMessages (CNode *pfrom)
 Process protocol messages received from a given node. More...
 
bool SendMessages (CNode *pto, bool fSendTrickle)
 Send queued protocol messages to be sent to a give node. More...
 

Variables

CCriticalSection cs_main
 
CTxMemPool mempool
 
map< uint256, CBlockIndex * > mapBlockIndex
 
CChain chainActive
 The currently-connected chain of blocks. More...
 
CChain chainMostWork
 The currently best known chain of headers (some of which may be invalid). More...
 
int64_t nTimeBestReceived = 0
 
int nScriptCheckThreads = 0
 
bool fImporting = false
 
bool fReindex = false
 
bool fBenchmark = false
 
bool fTxIndex = false
 
unsigned int nCoinCacheSize = 5000
 
map< uint256, COrphanBlock * > mapOrphanBlocks
 
multimap< uint256, COrphanBlock * > mapOrphanBlocksByPrev
 
map< uint256, COrphanTxmapOrphanTransactions
 
map< uint256, set< uint256 > > mapOrphanTransactionsByPrev
 
CScript COINBASE_FLAGS
 
const string strMessageMagic = "Bitcoin Signed Message:\n"
 
CCoinsViewCachepcoinsTip = NULL
 Global variable that points to the active CCoinsView (protected by cs_main) More...
 
CBlockTreeDBpblocktree = NULL
 Global variable that points to the active block tree (protected by cs_main) More...
 
static const int64_t nTargetTimespan = 14 * 24 * 60 * 60
 
static const int64_t nTargetSpacing = 10 * 60
 
static const int64_t nInterval = nTargetTimespan / nTargetSpacing
 
bool fLargeWorkForkFound = false
 
bool fLargeWorkInvalidChainFound = false
 
CBlockIndexpindexBestForkTip = NULL
 
CBlockIndexpindexBestForkBase = NULL
 
static CCheckQueue< CScriptCheckscriptcheckqueue (128)
 
class CMainCleanup instance_of_cmaincleanup
 

Function Documentation

bool AbortNode ( const std::string &  strMessage)

Abort with a message.

Definition at line 2798 of file main.cpp.

References LogPrintf, CClientUIInterface::MSG_ERROR, StartShutdown(), strMiscWarning, CClientUIInterface::ThreadSafeMessageBox, and uiInterface.

Referenced by CValidationState::Abort(), CheckDiskSpace(), and LoadExternalBlockFile().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AcceptBlock ( CBlock block,
CValidationState state,
CDiskBlockPos dbp 
)
bool AcceptToMemoryPool ( CTxMemPool pool,
CValidationState state,
const CTransaction tx,
bool  fLimitFree,
bool *  pfMissingInputs,
bool  fRejectInsaneFee 
)
bool ActivateBestChain ( CValidationState state)

Find the best known block, and make it the tip of the block chain.

Definition at line 2138 of file main.cpp.

References ConnectTip(), CChain::Contains(), CValidationState::CorruptionPossible(), DisconnectTip(), FindMostWorkChain(), GetArg(), CBlockIndex::GetBlockHash(), base_uint< BITS >::GetHex(), CChain::Height(), InvalidChainFound(), IsInitialBlockDownload(), CValidationState::IsInvalid(), LOCK, runCommand(), and CChain::Tip().

Referenced by AddToBlockIndex(), and AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AddOrphanTx ( const CTransaction tx,
NodeId  peer 
)

Definition at line 421 of file main.cpp.

References CTransaction::CURRENT_VERSION, CTransaction::GetHash(), COutPoint::hash, LogPrint(), CTxIn::prevout, SER_NETWORK, base_uint< BITS >::ToString(), and CTransaction::vin.

Referenced by ProcessMessage().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AddToBlockIndex ( CBlock block,
CValidationState state,
const CDiskBlockPos pos 
)
static bool AlreadyHave ( const CInv inv)
static

Definition at line 3269 of file main.cpp.

References CTxMemPool::exists(), CInv::hash, CCoinsViewCache::HaveCoins(), MSG_BLOCK, MSG_TX, and CInv::type.

Referenced by ProcessMessage(), and SendMessages().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool AreInputsStandard ( const CTransaction tx,
CCoinsViewCache mapInputs 
)

Check for standard transaction types.

Parameters
[in]mapInputsMap of previous transactions that have outputs we're spending
Returns
True if all inputs (scriptSigs) use only standard transaction forms

Definition at line 623 of file main.cpp.

References EvalScript(), CCoinsViewCache::GetOutputFor(), CTransaction::IsCoinBase(), CTxOut::scriptPubKey, ScriptSigArgsExpected(), Solver(), TX_SCRIPTHASH, and CTransaction::vin.

Referenced by AcceptToMemoryPool().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CheckBlock ( const CBlock block,
CValidationState state,
bool  fCheckPOW,
bool  fCheckMerkleRoot 
)

Definition at line 2339 of file main.cpp.

References CBlock::BuildMerkleTree(), CheckProofOfWork(), CheckTransaction(), CValidationState::DoS(), error(), GetAdjustedTime(), CBlockHeader::GetBlockTime(), CBlockHeader::GetHash(), GetLegacySigOpCount(), GetSerializeSize(), CBlock::GetTxHash(), CBlockHeader::hashMerkleRoot, CValidationState::Invalid(), MAX_BLOCK_SIGOPS, MAX_BLOCK_SIZE, CBlockHeader::nBits, PROTOCOL_VERSION, REJECT_INVALID, SER_NETWORK, CBlock::vMerkleTree, and CBlock::vtx.

Referenced by ConnectBlock(), ProcessBlock(), and VerifyDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CheckDiskSpace ( uint64_t  nAdditionalBytes)

Check whether enough disk space is available for an incoming block.

Definition at line 2806 of file main.cpp.

References _(), AbortNode(), GetDataDir(), and nMinDiskSpace.

Referenced by AppInit2(), FindBlockPos(), FindUndoPos(), and WriteChainState().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CheckForkWarningConditions ( )

Definition at line 1361 of file main.cpp.

References AssertLockHeld, GetArg(), CBlockIndex::GetBlockWork(), CChain::Height(), IsInitialBlockDownload(), LogPrintf, CBlockIndex::nChainWork, CBlockIndex::nHeight, CBlockIndex::phashBlock, runCommand(), CChain::Tip(), and base_uint< BITS >::ToString().

Referenced by AddToBlockIndex(), CheckForkWarningConditionsOnNewFork(), and InvalidChainFound().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void CheckForkWarningConditionsOnNewFork ( CBlockIndex pindexNewForkTip)

Definition at line 1407 of file main.cpp.

References AssertLockHeld, CheckForkWarningConditions(), CBlockIndex::GetBlockWork(), CChain::Height(), CBlockIndex::nChainWork, CBlockIndex::nHeight, CBlockIndex::pprev, and CChain::Tip().

Referenced by AddToBlockIndex().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CheckInputs ( const CTransaction tx,
CValidationState state,
CCoinsViewCache inputs,
bool  fScriptChecks,
unsigned int  flags,
std::vector< CScriptCheck > *  pvChecks 
)

Definition at line 1549 of file main.cpp.

References COINBASE_MATURITY, CValidationState::DoS(), error(), CCoinsViewCache::GetBestBlock(), CCoinsViewCache::GetCoins(), CTransaction::GetHash(), CTransaction::GetValueOut(), COutPoint::hash, CCoinsViewCache::HaveInputs(), CValidationState::Invalid(), CCoins::IsCoinBase(), CTransaction::IsCoinBase(), MoneyRange(), COutPoint::n, CCoins::nHeight, CBlockIndex::nHeight, REJECT_INVALID, REJECT_NONSTANDARD, SCRIPT_VERIFY_STRICTENC, CScriptCheck::swap(), base_uint< BITS >::ToString(), CTransaction::vin, and CCoins::vout.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CheckProofOfWork ( uint256  hash,
unsigned int  nBits 
)

Check whether a block hash satisfies the proof-of-work requirement specified by nBits.

Definition at line 1325 of file main.cpp.

References error(), CBigNum::getuint256(), Params(), and CBigNum::SetCompact().

Referenced by CheckBlock(), CBlockIndex::CheckIndex(), and ReadBlockFromDisk().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool CheckTransaction ( const CTransaction tx,
CValidationState state 
)

Definition at line 760 of file main.cpp.

References CValidationState::DoS(), error(), GetSerializeSize(), CTransaction::IsCoinBase(), COutPoint::IsNull(), MAX_BLOCK_SIZE, MAX_MONEY, MoneyRange(), CTxOut::nValue, CTxIn::prevout, PROTOCOL_VERSION, REJECT_INVALID, SER_NETWORK, CTransaction::vin, and CTransaction::vout.

Referenced by AcceptToMemoryPool(), CheckBlock(), and ReadKeyValue().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int ComputeMinWork ( unsigned int  nBase,
int64_t  nTime 
)

Calculate the minimum amount of work a received block needs, without knowing its direct parent.

Definition at line 1241 of file main.cpp.

References CBigNum::GetCompact(), Params(), CChainParams::ProofOfWorkLimit(), CBigNum::SetCompact(), and TestNet().

Referenced by ProcessBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ConnectBlock ( CBlock block,
CValidationState state,
CBlockIndex pindex,
CCoinsViewCache view,
bool  fJustCheck 
)

Definition at line 1758 of file main.cpp.

References _(), CValidationState::Abort(), CCheckQueueControl< T >::Add(), AssertLockHeld, BLOCK_HAVE_UNDO, BLOCK_VALID_MASK, BLOCK_VALID_SCRIPTS, CheckBlock(), CheckInputs(), CLIENT_VERSION, CValidationState::DoS(), error(), fBenchmark, FindUndoPos(), fTxIndex, g_signals, CCoinsViewCache::GetBestBlock(), CBlockIndex::GetBlockHash(), CBlockIndex::GetBlockPos(), GetBlockValue(), CCoinsViewCache::GetCoins(), CBlockHeader::GetHash(), GetLegacySigOpCount(), GetP2SHSigOpCount(), GetSerializeSize(), GetSizeOfCompactSize(), GetTimeMicros(), Checkpoints::GetTotalBlocksEstimate(), CBlock::GetTxHash(), CBlockIndex::GetUndoPos(), CCoinsViewCache::GetValueIn(), CTransaction::GetValueOut(), CChainParams::HashGenesisBlock(), CCoinsViewCache::HaveCoins(), CCoinsViewCache::HaveInputs(), CTransaction::IsCoinBase(), CDiskBlockPos::IsNull(), LogPrintf, MAX_BLOCK_SIGOPS, CBlockIndex::nFile, CBlockIndex::nHeight, CDiskBlockPos::nPos, CBlockIndex::nStatus, CBlockIndex::nTime, CDiskTxPos::nTxOffset, CBlockIndex::nUndoPos, Params(), CBlockIndex::phashBlock, CBlockIndex::pprev, REJECT_INVALID, SCRIPT_VERIFY_NOCACHE, SCRIPT_VERIFY_NONE, SCRIPT_VERIFY_P2SH, scriptcheckqueue, SER_DISK, CCoinsViewCache::SetBestBlock(), UpdateCoins(), CTransaction::vin, CBlock::vtx, CBlockUndo::vtxundo, CCheckQueueControl< T >::Wait(), CBlockTreeDB::WriteBlockIndex(), and CBlockTreeDB::WriteTxIndex().

Referenced by ConnectTip(), CreateNewBlock(), and VerifyDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool ConnectTip ( CValidationState state,
CBlockIndex pindexNew 
)
static

Definition at line 2027 of file main.cpp.

References _(), CValidationState::Abort(), CTxMemPool::check(), ConnectBlock(), error(), fBenchmark, CCoinsViewCache::Flush(), CBlockIndex::GetBlockHash(), CTransaction::GetHash(), mastercore::GetHeight(), GetTimeMicros(), InvalidBlockFound(), CValidationState::IsInvalid(), LogPrintf, mastercore_handler_block_begin(), mastercore_handler_block_end(), mastercore_handler_tx(), MSG_BLOCK, CBlockIndex::pprev, ReadBlockFromDisk(), CTxMemPool::remove(), CTxMemPool::removeConflicts(), SyncWithWallets(), CChain::Tip(), base_uint< BITS >::ToString(), UpdateTip(), CBlock::vtx, and WriteChainState().

Referenced by ActivateBestChain().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool DisconnectBlock ( CBlock block,
CValidationState state,
CBlockIndex pindex,
CCoinsViewCache coins,
bool *  pfClean = NULL 
)

Functions for validating blocks and updating the block tree.

Undo the effects of this block (with given index) on the UTXO set represented by coins. In case pfClean is provided, operation will try to be tolerant about errors, and *pfClean will be true if no problems were found. Otherwise, the return value will be false in case of problems. Note that in any case, coins may be modified.

Definition at line 1638 of file main.cpp.

References CCoins::ClearUnspendable(), error(), CCoins::fCoinBase, CTxInUndo::fCoinBase, CCoinsViewCache::GetBestBlock(), CBlockIndex::GetBlockHash(), CCoinsViewCache::GetCoins(), CTransaction::GetHash(), CBlockIndex::GetUndoPos(), COutPoint::hash, CCoinsViewCache::HaveCoins(), CCoins::IsAvailable(), CDiskBlockPos::IsNull(), CCoins::IsPruned(), COutPoint::n, CCoins::nHeight, CTxInUndo::nHeight, CBlockIndex::nHeight, CCoins::nVersion, CTxInUndo::nVersion, CBlockIndex::pprev, CCoinsViewCache::SetBestBlock(), CCoinsViewCache::SetCoins(), CTxInUndo::txout, CTransaction::vin, CCoins::vout, CTxUndo::vprevout, CBlock::vtx, and CBlockUndo::vtxundo.

Referenced by DisconnectTip(), and VerifyDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool DisconnectTip ( CValidationState state)
static

Definition at line 1977 of file main.cpp.

References _(), CValidationState::Abort(), AcceptToMemoryPool(), CTxMemPool::check(), DisconnectBlock(), error(), fBenchmark, CCoinsViewCache::Flush(), fReindex, CBlockIndex::GetBlockHash(), CTransaction::GetHash(), mastercore::GetHeight(), GetTimeMicros(), CTransaction::IsCoinBase(), LogPrintf, mastercore_handler_disc_begin(), mastercore_handler_disc_end(), CBlockIndex::pprev, ReadBlockFromDisk(), CTxMemPool::remove(), SyncWithWallets(), CChain::Tip(), base_uint< BITS >::ToString(), UpdateTip(), CBlock::vtx, and WriteChainState().

Referenced by ActivateBestChain().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void EraseOrphansFor ( NodeId  peer)

Definition at line 468 of file main.cpp.

References EraseOrphanTx(), and LogPrint().

+ Here is the call graph for this function:

static void EraseOrphanTx ( uint256  hash)
static

Definition at line 451 of file main.cpp.

References COutPoint::hash, and CTxIn::prevout.

Referenced by EraseOrphansFor(), LimitOrphanTxSize(), and ProcessMessage().

+ Here is the caller graph for this function:

bool FindBlockPos ( CValidationState state,
CDiskBlockPos pos,
unsigned int  nAddSize,
unsigned int  nHeight,
uint64_t  nTime,
bool  fKnown = false 
)

Definition at line 2244 of file main.cpp.

References _(), CValidationState::Abort(), AllocateFileRange(), BLOCKFILE_CHUNK_SIZE, CheckDiskSpace(), CValidationState::Error(), FlushBlockFile(), LOCK, LogPrintf, MAX_BLOCKFILE_SIZE, CDiskBlockPos::nFile, CDiskBlockPos::nPos, OpenBlockFile(), CBlockTreeDB::ReadBlockFileInfo(), CBlockTreeDB::WriteBlockFileInfo(), and CBlockTreeDB::WriteLastBlockFile().

Referenced by AcceptBlock(), and InitBlockIndex().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void FindMostWorkChain ( )
static

Definition at line 2086 of file main.cpp.

References BLOCK_FAILED_CHILD, BLOCK_FAILED_MASK, CChain::Contains(), CBlockIndex::nChainWork, CBlockIndex::nStatus, CBlockIndex::pprev, CChain::SetTip(), and CChain::Tip().

Referenced by ActivateBestChain().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool FindUndoPos ( CValidationState state,
int  nFile,
CDiskBlockPos pos,
unsigned int  nAddSize 
)

Definition at line 2298 of file main.cpp.

References _(), CValidationState::Abort(), AllocateFileRange(), CheckDiskSpace(), CValidationState::Error(), LOCK, LogPrintf, CDiskBlockPos::nFile, CDiskBlockPos::nPos, CBlockFileInfo::nUndoSize, OpenUndoFile(), CBlockTreeDB::ReadBlockFileInfo(), UNDOFILE_CHUNK_SIZE, and CBlockTreeDB::WriteBlockFileInfo().

Referenced by ConnectBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void FlushBlockFile ( bool  fFinalize = false)
static

Definition at line 1726 of file main.cpp.

References FileCommit(), LOCK, OpenBlockFile(), OpenUndoFile(), and TruncateFile().

Referenced by FindBlockPos(), and WriteChainState().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t GetBlockValue ( int  nHeight,
int64_t  nFees 
)

Definition at line 1218 of file main.cpp.

References COIN, Params(), and CChainParams::SubsidyHalvingInterval().

Referenced by ConnectBlock(), and CreateNewBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int GetLegacySigOpCount ( const CTransaction tx)

Count ECDSA signature operations the old-fashioned (pre-0.6) way.

Returns
number of sigops this transaction's outputs will produce when spent
See also
CTransaction::FetchInputs

Definition at line 677 of file main.cpp.

References CScript::GetSigOpCount(), CTxOut::scriptPubKey, CTxIn::scriptSig, CTransaction::vin, and CTransaction::vout.

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

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int64_t GetMinFee ( const CTransaction tx,
unsigned int  nBytes,
bool  fAllowFree,
GetMinFee_mode  mode 
)

Definition at line 817 of file main.cpp.

References CENT, DEFAULT_BLOCK_PRIORITY_SIZE, GMF_RELAY, GMF_SEND, MAX_MONEY, MoneyRange(), CTransaction::nMinRelayTxFee, CTransaction::nMinTxFee, CTxOut::nValue, and CTransaction::vout.

Referenced by AcceptToMemoryPool(), and CoinControlDialog::updateLabels().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int GetNextWorkRequired ( const CBlockIndex pindexLast,
const CBlockHeader pblock 
)

debug print

Definition at line 1263 of file main.cpp.

References CBlockIndex::GetBlockTime(), CBigNum::GetCompact(), CBigNum::getuint256(), LogPrintf, CBlockIndex::nBits, CBlockIndex::nHeight, nTargetTimespan, CBlockHeader::nTime, CBlockIndex::nTime, Params(), CBlockIndex::pprev, CChainParams::ProofOfWorkLimit(), CBigNum::SetCompact(), TestNet(), and base_uint< BITS >::ToString().

Referenced by AcceptBlock(), CreateNewBlock(), and UpdateTime().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GetNodeStateStats ( NodeId  nodeid,
CNodeStateStats stats 
)

Get statistics from node state.

Definition at line 327 of file main.cpp.

References LOCK, and CNodeStateStats::nMisbehavior.

Referenced by getpeerinfo().

+ Here is the caller graph for this function:

static uint256 GetOrphanRoot ( const uint256 hash)
static

Definition at line 1178 of file main.cpp.

Referenced by ProcessBlock(), and ProcessMessage().

+ Here is the caller graph for this function:

unsigned int GetP2SHSigOpCount ( const CTransaction tx,
CCoinsViewCache mapInputs 
)

Count ECDSA signature operations in pay-to-script-hash inputs.

Parameters
[in]mapInputsMap of previous transactions that have outputs we're spending
Returns
maximum number of sigops required to validate this transaction's inputs
See also
CTransaction::FetchInputs

Definition at line 691 of file main.cpp.

References CCoinsViewCache::GetOutputFor(), CScript::GetSigOpCount(), CTransaction::IsCoinBase(), CScript::IsPayToScriptHash(), CTxOut::scriptPubKey, and CTransaction::vin.

Referenced by ConnectBlock(), and CreateNewBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool GetTransaction ( const uint256 hash,
CTransaction txOut,
uint256 hashBlock,
bool  fAllowSlow 
)

Retrieve a transaction (from memory pool, or from disk, if possible)

Definition at line 1049 of file main.cpp.

References CLIENT_VERSION, error(), fTxIndex, CBlockIndex::GetBlockHash(), CCoinsViewCache::GetCoins(), CTransaction::GetHash(), CBlockHeader::GetHash(), LOCK, CTxMemPool::lookup(), CCoins::nHeight, CDiskTxPos::nTxOffset, OpenBlockFile(), pcoinsTip, ReadBlockFromDisk(), CBlockTreeDB::ReadTxIndex(), SER_DISK, and CBlock::vtx.

Referenced by getactivecrowdsales_MP(), getcrowdsale_MP(), getrawtransaction(), getsto_MP(), gettrade_MP(), parseTransaction(), populateRPCTransactionObject(), and CMPTxList::setLastAlert().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

string GetWarnings ( string  strFor)

Format a string that describes several potential problems detected by the core.

Definition at line 3204 of file main.cpp.

References _(), CAlert::AppliesToMe(), CLIENT_VERSION_IS_RELEASE, cs_mapAlerts, GetBoolArg(), LOCK, mapAlerts, CUnsignedAlert::nPriority, PAIRTYPE, strMiscWarning, and CUnsignedAlert::strStatusBar.

Referenced by CRPCTable::execute(), getinfo(), getmininginfo(), and ClientModel::getStatusBarWarnings().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool InitBlockIndex ( )

Initialize a new block tree database + block data on disk.

Definition at line 3014 of file main.cpp.

References AddToBlockIndex(), CLIENT_VERSION, error(), FindBlockPos(), fReindex, fTxIndex, CChain::Genesis(), CChainParams::GenesisBlock(), GetBoolArg(), GetSerializeSize(), LOCK, LogPrintf, CBlockHeader::nTime, Params(), SER_DISK, WriteBlockToDisk(), and CBlockTreeDB::WriteFlag().

Referenced by AppInit2(), and ThreadImport().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

CBlockIndex* InsertBlockIndex ( uint256  hash)

Create a new block index entry for a given block hash.

Definition at line 2848 of file main.cpp.

Referenced by CBlockTreeDB::LoadBlockIndexGuts().

+ Here is the caller graph for this function:

static void InvalidBlockFound ( CBlockIndex pindex,
const CValidationState state 
)
static

Definition at line 1480 of file main.cpp.

References BLOCK_FAILED_VALID, CValidationState::CorruptionPossible(), CBlockIndex::GetBlockHash(), CValidationState::GetRejectCode(), CValidationState::GetRejectReason(), InvalidChainFound(), CValidationState::IsInvalid(), Misbehaving(), CBlockIndex::nStatus, and CBlockTreeDB::WriteBlockIndex().

Referenced by ConnectTip().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void InvalidChainFound ( CBlockIndex pindexNew)
static

Definition at line 1459 of file main.cpp.

References CheckForkWarningConditions(), DateTimeStrFormat(), CBlockIndex::GetBlockHash(), CBlockIndex::GetBlockTime(), base_uint< BITS >::getdouble(), CChain::Height(), LogPrintf, CBlockIndex::nChainWork, CBlockIndex::nHeight, CClientUIInterface::NotifyBlocksChanged, CChain::Tip(), base_uint< BITS >::ToString(), uiInterface, and CBlockTreeDB::WriteBestInvalidWork().

Referenced by ActivateBestChain(), and InvalidBlockFound().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool IsFinalTx ( const CTransaction tx,
int  nBlockHeight,
int64_t  nBlockTime 
)

Definition at line 594 of file main.cpp.

References AssertLockHeld, GetAdjustedTime(), CChain::Height(), LOCKTIME_THRESHOLD, CTransaction::nLockTime, and CTransaction::vin.

Referenced by AcceptBlock(), CWallet::AvailableCoins(), CreateNewBlock(), TransactionDesc::FormatTxStatus(), GetAccountBalance(), CWallet::GetAddressBalances(), getreceivedbyaccount(), getreceivedbyaddress(), CWallet::GetUnconfirmedBalance(), IsStandardTx(), CWalletTx::IsTrusted(), ListReceived(), and TransactionRecord::updateStatus().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool IsInitialBlockDownload ( )

Check whether we are doing an initial block download (synchronizing from disk or network)

Definition at line 1341 of file main.cpp.

References fImporting, fReindex, CBlockIndex::GetBlockTime(), GetTime(), Checkpoints::GetTotalBlocksEstimate(), CChain::Height(), LOCK, and CChain::Tip().

Referenced by ActivateBestChain(), CheckForkWarningConditions(), getblocktemplate(), ClientModel::inInitialBlockDownload(), ProcessMessage(), SendMessages(), UpdateTip(), WriteBlockToDisk(), and WriteChainState().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool IsStandardTx ( const CTransaction tx,
std::string &  reason 
)

Check for standard transaction types.

Returns
True if all outputs (scriptPubKeys) use only standard transaction forms

Definition at line 507 of file main.cpp.

References AssertLockHeld, CTransaction::CURRENT_VERSION, CScript::HasCanonicalPushes(), CChain::Height(), CTxOut::IsDust(), IsFinalTx(), CScript::IsPushOnly(), IsStandard(), MAX_STANDARD_TX_SIZE, CTransaction::nMinRelayTxFee, CTransaction::nVersion, CTxOut::scriptPubKey, CTxIn::scriptSig, SER_NETWORK, TX_NULL_DATA, CTransaction::vin, and CTransaction::vout.

Referenced by AcceptToMemoryPool().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

unsigned int LimitOrphanTxSize ( unsigned int  nMaxOrphans)

Definition at line 485 of file main.cpp.

References EraseOrphanTx(), and GetRandHash().

Referenced by ProcessMessage().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool LoadBlockIndex ( )

Load the block tree and coins database from disk.

Definition at line 3005 of file main.cpp.

References fReindex, and LoadBlockIndexDB().

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool LoadBlockIndexDB ( )
static
bool LoadExternalBlockFile ( FILE *  fileIn,
CDiskBlockPos dbp 
)

Import blocks from an external file.

Definition at line 3118 of file main.cpp.

References _(), AbortNode(), CLIENT_VERSION, CBufferedFile::eof(), CBufferedFile::FindByte(), FLATDATA, CBufferedFile::GetPos(), GetTimeMillis(), CBufferedFile::good(), CValidationState::IsError(), LOCK, LogPrintf, MAX_BLOCK_SIZE, MESSAGE_START_SIZE, CDiskBlockPos::nFile, CDiskBlockPos::nPos, CBlockFileInfo::nSize, Params(), ProcessBlock(), CBlockTreeDB::ReadBlockFileInfo(), CBufferedFile::Seek(), SER_DISK, CBufferedFile::SetLimit(), and CBufferedFile::SetPos().

Referenced by ThreadImport().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int mastercore_handler_block_begin ( int  nBlockNow,
CBlockIndex const *  pBlockIndex 
)

Definition at line 3989 of file mastercore.cpp.

Referenced by ConnectTip().

+ Here is the caller graph for this function:

int mastercore_handler_block_end ( int  nBlockNow,
CBlockIndex const *  pBlockIndex,
unsigned  int 
)

Definition at line 4034 of file mastercore.cpp.

Referenced by ConnectTip().

+ Here is the caller graph for this function:

int mastercore_handler_disc_begin ( int  nBlockNow,
CBlockIndex const *  pBlockIndex 
)

Definition at line 4074 of file mastercore.cpp.

Referenced by DisconnectTip().

+ Here is the caller graph for this function:

int mastercore_handler_disc_end ( int  nBlockNow,
CBlockIndex const *  pBlockIndex 
)

Definition at line 4081 of file mastercore.cpp.

Referenced by DisconnectTip().

+ Here is the caller graph for this function:

int mastercore_handler_tx ( const CTransaction tx,
int  nBlock,
unsigned int  idx,
CBlockIndex const *  pBlockIndex 
)

Definition at line 2567 of file mastercore.cpp.

Referenced by ConnectTip().

+ Here is the caller graph for this function:

void Misbehaving ( NodeId  nodeid,
int  howmuch 
)

Increase a node's misbehavior score.

Definition at line 1441 of file main.cpp.

References GetArg(), and LogPrintf.

Referenced by InvalidBlockFound(), and ProcessMessage().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FILE* OpenBlockFile ( const CDiskBlockPos pos,
bool  fReadOnly 
)

Open a block file (blk?????.dat)

Definition at line 2840 of file main.cpp.

References OpenDiskFile().

Referenced by FindBlockPos(), FlushBlockFile(), GetTransaction(), ReadBlockFromDisk(), ThreadImport(), and WriteBlockToDisk().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FILE* OpenDiskFile ( const CDiskBlockPos pos,
const char *  prefix,
bool  fReadOnly 
)

Definition at line 2817 of file main.cpp.

References GetDataDir(), CDiskBlockPos::IsNull(), LogPrintf, CDiskBlockPos::nFile, CDiskBlockPos::nPos, and strprintf.

Referenced by OpenBlockFile(), and OpenUndoFile().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

FILE* OpenUndoFile ( const CDiskBlockPos pos,
bool  fReadOnly 
)

Open an undo file (rev?????.dat)

Definition at line 2844 of file main.cpp.

References OpenDiskFile().

Referenced by FindUndoPos(), and FlushBlockFile().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void PrintBlockTree ( )

Print the loaded block tree.

Definition at line 3049 of file main.cpp.

References AssertLockHeld, DateTimeStrFormat(), CChain::Genesis(), CBlockIndex::GetBlockPos(), CBlockHeader::GetBlockTime(), LogPrintf, CChain::Next(), CDiskBlockPos::nFile, CBlockIndex::nHeight, CDiskBlockPos::nPos, CBlockIndex::pprev, ReadBlockFromDisk(), and CBlock::vtx.

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ProcessBlock ( CValidationState state,
CNode pfrom,
CBlock pblock,
CDiskBlockPos dbp 
)
static void ProcessGetData ( CNode pfrom)
static

Definition at line 3289 of file main.cpp.

References CChain::Contains(), mruset< T >::count(), CNode::cs_filter, cs_mapRelay, g_signals, CBlockIndex::GetBlockHash(), CInv::GetCommand(), Checkpoints::GetLastCheckpoint(), CInv::hash, CNode::hashContinue, CInv::IsKnownType(), LOCK, LogPrintf, CTxMemPool::lookup(), mapRelay, MSG_BLOCK, MSG_FILTERED_BLOCK, MSG_TX, CNode::nSendSize, CNode::pfilter, PROTOCOL_VERSION, CNode::PushMessage(), ReadBlockFromDisk(), CDataStream::reserve(), SendBufferSize(), SER_NETWORK, CNode::setInventoryKnown, CChain::Tip(), CInv::type, CMerkleBlock::vMatchedTxn, CNode::vRecvGetData, and CBlock::vtx.

Referenced by ProcessMessage(), and ProcessMessages().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool ProcessMessage ( CNode pfrom,
string  strCommand,
CDataStream vRecv 
)
static

Definition at line 3419 of file main.cpp.

References AcceptToMemoryPool(), CAddrMan::Add(), CNode::AddAddressKnown(), CNode::AddInventoryKnown(), AddOrphanTx(), CNode::addr, AddressCurrentlyConnected(), CNode::addrLocal, addrman, AddTimeData(), AlreadyHave(), CNode::AskFor(), atoi(), BEGIN, BIP0031_VERSION, CADDR_TIME_VERSION, CTxMemPool::check(), CNode::cleanSubVer, CNode::cs_filter, cs_mapAlerts, cs_vNodes, DEFAULT_MAX_ORPHAN_TRANSACTIONS, CDataStream::empty(), END, EraseOrphanTx(), error(), CNode::fClient, fDebug, CNode::fDisconnect, CNode::fGetAddr, fImporting, CNode::fInbound, CChain::FindFork(), CNode::fNetworkNode, fNoListen, CNode::fOneShot, fReindex, CNode::fRelayTxes, CNode::fSuccessfullyConnected, g_signals, CAddrMan::GetAddr(), GetAdjustedTime(), GetArg(), CBlockIndex::GetBlockHash(), CBlockIndex::GetBlockHeader(), CNetAddr::GetHash(), CNode::GetId(), GetLocalAddress(), GetOrphanRoot(), GetRand(), GetRandHash(), CValidationState::GetRejectCode(), CValidationState::GetRejectReason(), GetTime(), GetTimeMicros(), CAddrMan::Good(), Hash(), CInv::hash, CNode::hashContinue, CDataStream::in_avail(), CBloomFilter::insert(), IsInitialBlockDownload(), CValidationState::IsInvalid(), CBlockLocator::IsNull(), IsReachable(), CBloomFilter::IsRelevantAndUpdate(), CNetAddr::IsRoutable(), itostr(), LIMITED_STRING, LimitOrphanTxSize(), LOCK, LOCK2, LogPrint(), LogPrintf, CTxMemPool::lookup(), mapAlerts, mapAlreadyAskedFor, mapArgs, CTxMemPool::mapTx, MAX_INV_SZ, MAX_SCRIPT_ELEMENT_SIZE, memcpy(), MIN_PEER_PROTO_VERSION, Misbehaving(), MSG_BLOCK, MSG_TX, CChain::Next(), CBlockIndex::nHeight, nLocalHostNonce, NODE_NETWORK, CNode::nPingNonceSent, CNode::nPingUsecStart, CNode::nPingUsecTime, CNode::nSendSize, CNode::nServices, CNode::nStartingHeight, CAddress::nTime, CNode::nVersion, PAIRTYPE, CNode::pfilter, ProcessBlock(), ProcessGetData(), PROTOCOL_VERSION, CNode::PushAddress(), PushGetBlocks(), CNode::PushInventory(), CNode::PushMessage(), CNode::PushVersion(), CTxMemPool::queryHashes(), RandAddSeedPerfmon(), REJECT_DUPLICATE, REJECT_OBSOLETE, CAlert::RelayTo(), RelayTransaction(), SanitizeString(), SeenLocal(), SendBufferSize(), CNode::setKnown, CNode::SetRecvVersion(), CDataStream::SetVersion(), CAddrMan::size(), CDataStream::size(), CNode::ssSend, strprintf, CNode::strSubVer, CChain::Tip(), CService::ToString(), CInv::ToString(), base_uint< BITS >::ToString(), CInv::type, CBloomFilter::UpdateEmptyFull(), CNode::vAddrToSend, vNodes, and CNode::vRecvGetData.

Referenced by ProcessMessages().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ProcessMessages ( CNode pfrom)

Process protocol messages received from a given node.

Definition at line 4114 of file main.cpp.

References CDataStream::begin(), CNetMessage::complete(), CNode::fDisconnect, CMessageHeader::GetCommand(), Hash(), CNetMessage::hdr, CMessageHeader::IsValid(), LogPrintf, memcpy(), MESSAGE_START_SIZE, CMessageHeader::nChecksum, CMessageHeader::nMessageSize, CNode::nSendSize, Params(), CMessageHeader::pchMessageStart, PrintExceptionContinue(), ProcessGetData(), ProcessMessage(), CNode::PushMessage(), REJECT_MALFORMED, SendBufferSize(), CNetMessage::vRecv, CNode::vRecvGetData, and CNode::vRecvMsg.

Referenced by RegisterNodeSignals(), and UnregisterNodeSignals().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void PruneOrphanBlocks ( )
static

Definition at line 1194 of file main.cpp.

References DEFAULT_MAX_ORPHAN_BLOCKS, GetArg(), and insecure_rand().

Referenced by ProcessBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void PushGetBlocks ( CNode pnode,
CBlockIndex pindexBegin,
uint256  hashEnd 
)

Definition at line 2530 of file main.cpp.

References AssertLockHeld, CChain::GetLocator(), CNode::hashLastGetBlocksEnd, CNode::pindexLastGetBlocksBegin, and CNode::PushMessage().

Referenced by ProcessBlock(), ProcessMessage(), and SendMessages().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ReadBlockFromDisk ( CBlock block,
const CDiskBlockPos pos 
)

Definition at line 1145 of file main.cpp.

References CheckProofOfWork(), CLIENT_VERSION, error(), CBlockHeader::GetHash(), CBlockHeader::nBits, OpenBlockFile(), and SER_DISK.

Referenced by AppInit2(), ConnectTip(), DisconnectTip(), getblock(), GetTransaction(), listblocktransactions_MP(), msc_initial_scan(), PrintBlockTree(), ProcessGetData(), ReadBlockFromDisk(), CWallet::ScanForWalletTransactions(), and VerifyDB().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ReadBlockFromDisk ( CBlock block,
const CBlockIndex pindex 
)

Definition at line 1169 of file main.cpp.

References error(), CBlockIndex::GetBlockHash(), CBlockIndex::GetBlockPos(), CBlockHeader::GetHash(), and ReadBlockFromDisk().

+ Here is the call graph for this function:

void RegisterNodeSignals ( CNodeSignals nodeSignals)

Register with a network node to receive its signals.

Definition at line 336 of file main.cpp.

References CNodeSignals::FinalizeNode, CNodeSignals::GetHeight, mastercore::GetHeight(), CNodeSignals::InitializeNode, CNodeSignals::ProcessMessages, ProcessMessages(), CNodeSignals::SendMessages, and SendMessages().

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RegisterWallet ( CWalletInterface pwalletIn)

Register a wallet to receive updates from core.

Definition at line 160 of file main.cpp.

References CWalletInterface::EraseFromWallet(), g_signals, CWalletInterface::Inventory(), CWalletInterface::ResendWalletTransactions(), CWalletInterface::SetBestChain(), CWalletInterface::SyncTransaction(), and CWalletInterface::UpdatedTransaction().

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool SendMessages ( CNode pto,
bool  fSendTrickle 
)
void SyncWithWallets ( const uint256 hash,
const CTransaction tx,
const CBlock pblock 
)

Push an updated transaction to all registered wallets.

Definition at line 187 of file main.cpp.

References g_signals.

Referenced by ConnectTip(), DisconnectTip(), and sendrawtransaction().

+ Here is the caller graph for this function:

void ThreadScriptCheck ( )

Run an instance of the script checking thread.

Definition at line 1753 of file main.cpp.

References RenameThread(), and scriptcheckqueue.

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UnloadBlockIndex ( )

Unload database information.

Definition at line 2997 of file main.cpp.

References CChain::SetTip().

Referenced by AppInit2().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UnregisterAllWallets ( )

Unregister all wallets from core.

Definition at line 178 of file main.cpp.

References g_signals.

Referenced by Shutdown().

+ Here is the caller graph for this function:

void UnregisterNodeSignals ( CNodeSignals nodeSignals)

Unregister a network node.

Definition at line 345 of file main.cpp.

References CNodeSignals::FinalizeNode, CNodeSignals::GetHeight, mastercore::GetHeight(), CNodeSignals::InitializeNode, CNodeSignals::ProcessMessages, ProcessMessages(), CNodeSignals::SendMessages, and SendMessages().

Referenced by Shutdown().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UnregisterWallet ( CWalletInterface pwalletIn)

Unregister a wallet from core.

Definition at line 169 of file main.cpp.

References CWalletInterface::EraseFromWallet(), g_signals, CWalletInterface::Inventory(), CWalletInterface::ResendWalletTransactions(), CWalletInterface::SetBestChain(), CWalletInterface::SyncTransaction(), and CWalletInterface::UpdatedTransaction().

+ Here is the call graph for this function:

void UpdateCoins ( const CTransaction tx,
CValidationState state,
CCoinsViewCache inputs,
CTxUndo txundo,
int  nHeight,
const uint256 txhash 
)

Definition at line 1518 of file main.cpp.

References CCoinsViewCache::GetCoins(), COutPoint::hash, CTransaction::IsCoinBase(), CTxIn::prevout, CCoinsViewCache::SetCoins(), CCoins::Spend(), CTransaction::vin, and CTxUndo::vprevout.

Referenced by ConnectBlock(), and CreateNewBlock().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void UpdateTime ( CBlockHeader block,
const CBlockIndex pindexPrev 
)

Definition at line 1499 of file main.cpp.

References GetAdjustedTime(), CBlockIndex::GetMedianTimePast(), GetNextWorkRequired(), CBlockHeader::nBits, CBlockHeader::nTime, and TestNet().

Referenced by CreateNewBlock(), and getblocktemplate().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static void UpdateTip ( CBlockIndex pindexNew)
static

Definition at line 1941 of file main.cpp.

References _(), CTxMemPool::AddTransactionsUpdated(), CBlockHeader::CURRENT_VERSION, DateTimeStrFormat(), g_signals, CBlockIndex::GetBlockHash(), CBlockIndex::GetBlockTime(), base_uint< BITS >::getdouble(), CChain::GetLocator(), GetTime(), Checkpoints::GuessVerificationProgress(), CChain::Height(), IsInitialBlockDownload(), LogPrintf, CBlockIndex::nChainTx, CBlockIndex::nChainWork, nTimeBestReceived, CBlockIndex::nVersion, CBlockIndex::pprev, CChain::SetTip(), strMiscWarning, CChain::Tip(), and base_uint< BITS >::ToString().

Referenced by ConnectTip(), and DisconnectTip().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool VerifyDB ( int  nCheckLevel,
int  nCheckDepth 
)

Verify consistency of the block and coin databases.

Definition at line 2923 of file main.cpp.

References CheckBlock(), ConnectBlock(), DisconnectBlock(), error(), CBlockIndex::GetBlockHash(), CCoinsViewCache::GetCacheSize(), CBlockIndex::GetUndoPos(), CChain::Height(), CDiskBlockPos::IsNull(), LOCK, LogPrintf, nCoinCacheSize, CChain::Next(), CBlockIndex::nHeight, CBlockIndex::pprev, ReadBlockFromDisk(), CChain::Tip(), base_uint< BITS >::ToString(), and CBlock::vtx.

Referenced by AppInit2(), and verifychain().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool VerifySignature ( const CCoins txFrom,
const CTransaction txTo,
unsigned int  nIn,
unsigned int  flags,
int  nHashType 
)

Verify a signature.

Definition at line 1544 of file main.cpp.

bool WriteBlockToDisk ( CBlock block,
CDiskBlockPos pos 
)

Functions for disk access for blocks.

Definition at line 1119 of file main.cpp.

References CLIENT_VERSION, error(), FileCommit(), fileout, FLATDATA, CAutoFile::GetSerializeSize(), IsInitialBlockDownload(), CDiskBlockPos::nPos, OpenBlockFile(), Params(), and SER_DISK.

Referenced by AcceptBlock(), and InitBlockIndex().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static bool WriteChainState ( CValidationState state)
static

Definition at line 1921 of file main.cpp.

References _(), CValidationState::Abort(), CheckDiskSpace(), CValidationState::Error(), CCoinsViewCache::Flush(), FlushBlockFile(), CCoinsViewCache::GetCacheSize(), GetTimeMicros(), IsInitialBlockDownload(), nCoinCacheSize, and CLevelDBWrapper::Sync().

Referenced by ConnectTip(), and DisconnectTip().

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

CChain chainActive
CChain chainMostWork

The currently best known chain of headers (some of which may be invalid).

Definition at line 49 of file main.cpp.

CScript COINBASE_FLAGS

Definition at line 80 of file main.cpp.

Referenced by getblocktemplate(), and IncrementExtraNonce().

bool fBenchmark = false

Definition at line 54 of file main.cpp.

Referenced by AppInit2(), ConnectBlock(), ConnectTip(), and DisconnectTip().

bool fImporting = false
bool fLargeWorkForkFound = false

Definition at line 1357 of file main.cpp.

bool fLargeWorkInvalidChainFound = false

Definition at line 1358 of file main.cpp.

bool fReindex = false
bool fTxIndex = false

Definition at line 55 of file main.cpp.

Referenced by AppInit2(), ConnectBlock(), GetTransaction(), InitBlockIndex(), and LoadBlockIndexDB().

class CMainCleanup instance_of_cmaincleanup
map<uint256, CBlockIndex*> mapBlockIndex
map<uint256, COrphanBlock*> mapOrphanBlocks

Definition at line 68 of file main.cpp.

multimap<uint256, COrphanBlock*> mapOrphanBlocksByPrev

Definition at line 69 of file main.cpp.

map<uint256, COrphanTx> mapOrphanTransactions

Definition at line 75 of file main.cpp.

map<uint256, set<uint256> > mapOrphanTransactionsByPrev

Definition at line 76 of file main.cpp.

CTxMemPool mempool
unsigned int nCoinCacheSize = 5000

Definition at line 56 of file main.cpp.

Referenced by AppInit2(), VerifyDB(), and WriteChainState().

const int64_t nInterval = nTargetTimespan / nTargetSpacing
static

Definition at line 1235 of file main.cpp.

int nScriptCheckThreads = 0

Definition at line 51 of file main.cpp.

Referenced by AppInit2().

const int64_t nTargetSpacing = 10 * 60
static

Definition at line 1234 of file main.cpp.

const int64_t nTargetTimespan = 14 * 24 * 60 * 60
static

Definition at line 1233 of file main.cpp.

Referenced by GetNextWorkRequired().

int64_t nTimeBestReceived = 0

Definition at line 50 of file main.cpp.

Referenced by CWallet::ResendWalletTransactions(), and UpdateTip().

CBlockTreeDB* pblocktree = NULL

Global variable that points to the active block tree (protected by cs_main)

Definition at line 414 of file main.cpp.

Referenced by AppInit2(), Shutdown(), and ThreadImport().

CCoinsViewCache* pcoinsTip = NULL

Global variable that points to the active CCoinsView (protected by cs_main)

Definition at line 413 of file main.cpp.

Referenced by AppInit2(), CreateNewBlock(), GetTransaction(), gettxout(), gettxoutsetinfo(), sendrawtransaction(), Shutdown(), signrawtransaction(), and TransactionDesc::toHTML().

CBlockIndex * pindexBestForkBase = NULL

Definition at line 1359 of file main.cpp.

CBlockIndex* pindexBestForkTip = NULL

Definition at line 1359 of file main.cpp.

CCheckQueue<CScriptCheck> scriptcheckqueue(128)
static

Referenced by ConnectBlock(), and ThreadScriptCheck().

const string strMessageMagic = "Bitcoin Signed Message:\n"