Anoncoin  0.9.4
P2P Digital Currency
Classes | Enumerations | Functions | Variables
main.h File Reference
#include "bignum.h"
#include "clientversion.h"
#include "chainparams.h"
#include "coins.h"
#include "core.h"
#include "net.h"
#include "script.h"
#include "sync.h"
#include "txmempool.h"
#include "uint256.h"
#include <algorithm>
#include <exception>
#include <map>
#include <set>
#include <stdint.h>
#include <string>
#include <utility>
#include <vector>
Include dependency graph for main.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  CNodeStateStats
 
struct  CDiskBlockPos
 
struct  CDiskTxPos
 
class  CBlockUndo
 Undo information for a CBlock. More...
 
class  CScriptCheck
 Closure representing one script verification Note that this stores references to the spending transaction. More...
 
class  CMerkleTx
 A transaction with a merkle branch linking it to the block chain. More...
 
class  CPartialMerkleTree
 Data structure that represents a partial merkle tree. More...
 
class  CBlockFileInfo
 
class  CBlockIndex
 The block chain is a tree shaped structure starting with the genesis block at the root, with each block potentially having multiple candidates to be the next block. More...
 
class  CDiskBlockIndex
 Used to marshal pointers into hashes for db storage. More...
 
class  CValidationState
 Capture information about block/transaction validation. More...
 
class  CChain
 An in-memory indexed chain of blocks. More...
 
struct  CBlockTemplate
 
class  CMerkleBlock
 Used to relay blocks as header + vector<merkle branch> to filtered nodes. More...
 
class  CWalletInterface
 

Enumerations

enum  GetMinFee_mode { GMF_RELAY, GMF_SEND }
 
enum  BlockStatus {
  BLOCK_VALID_UNKNOWN = 0, BLOCK_VALID_HEADER = 1, BLOCK_VALID_TREE = 2, BLOCK_VALID_TRANSACTIONS = 3,
  BLOCK_VALID_CHAIN = 4, BLOCK_VALID_SCRIPTS = 5, BLOCK_VALID_MASK = 7, BLOCK_HAVE_DATA = 8,
  BLOCK_HAVE_UNDO = 16, BLOCK_HAVE_MASK = 24, BLOCK_FAILED_VALID = 32, BLOCK_FAILED_CHILD = 64,
  BLOCK_FAILED_MASK = 96
}
 

Functions

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=NULL)
 Push an updated transaction to all registered wallets. More...
 
void RegisterNodeSignals (CNodeSignals &nodeSignals)
 Register with a network node to receive its signals. More...
 
void UnregisterNodeSignals (CNodeSignals &nodeSignals)
 Unregister a network node. More...
 
void PushGetBlocks (CNode *pnode, CBlockIndex *pindexBegin, uint256 hashEnd)
 
bool ProcessBlock (CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp=NULL)
 Process an incoming block. More...
 
bool CheckDiskSpace (uint64_t nAdditionalBytes=0)
 Check whether enough disk space is available for an incoming block. More...
 
FILE * OpenBlockFile (const CDiskBlockPos &pos, bool fReadOnly=false)
 Open a block file (blk?????.dat) More...
 
FILE * OpenUndoFile (const CDiskBlockPos &pos, bool fReadOnly=false)
 Open an undo file (rev?????.dat) More...
 
bool LoadExternalBlockFile (FILE *fileIn, CDiskBlockPos *dbp=NULL)
 Import blocks from an external file. More...
 
bool InitBlockIndex ()
 Initialize a new block tree database + block data on disk. More...
 
bool LoadBlockIndex ()
 Load the block tree and coins database from disk. More...
 
void UnloadBlockIndex ()
 Unload database information. More...
 
bool VerifyDB (int nCheckLevel, int nCheckDepth)
 Verify consistency of the block and coin databases. More...
 
void PrintBlockTree ()
 Print the loaded block tree. More...
 
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...
 
void ThreadScriptCheck ()
 Run an instance of the script checking thread. More...
 
bool CheckProofOfWork (uint256 hash, unsigned int nBits)
 Check whether a block hash satisfies the proof-of-work requirement specified by nBits. More...
 
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...
 
bool IsInitialBlockDownload ()
 Check whether we are doing an initial block download (synchronizing from disk or network) More...
 
std::string GetWarnings (std::string strFor)
 Format a string that describes several potential problems detected by the core. More...
 
bool GetTransaction (const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow=false)
 Retrieve a transaction (from memory pool, or from disk, if possible) More...
 
bool ActivateBestChain (CValidationState &state)
 Find the best known block, and make it the tip of the block chain. More...
 
int64_t GetBlockValue (int nHeight, int64_t nFees)
 
unsigned int GetNextWorkRequired (const CBlockIndex *pindexLast, const CBlockHeader *pblock)
 
void UpdateTime (CBlockHeader &block, const CBlockIndex *pindexPrev)
 
CBlockIndexInsertBlockIndex (uint256 hash)
 Create a new block index entry for a given block hash. More...
 
bool VerifySignature (const CCoins &txFrom, const CTransaction &txTo, unsigned int nIn, unsigned int flags, int nHashType)
 Verify a signature. More...
 
bool AbortNode (const std::string &msg)
 Abort with a message. More...
 
bool GetNodeStateStats (NodeId nodeid, CNodeStateStats &stats)
 Get statistics from node state. More...
 
void Misbehaving (NodeId nodeid, int howmuch)
 Increase a node's misbehavior score. More...
 
bool AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee=false)
 (try to) add transaction to memory pool More...
 
int64_t GetMinFee (const CTransaction &tx, unsigned int nBytes, bool fAllowFree, enum GetMinFee_mode mode)
 
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 &mapInputs)
 Count ECDSA signature operations in pay-to-script-hash inputs. More...
 
bool AllowFree (double dPriority)
 
bool CheckInputs (const CTransaction &tx, CValidationState &state, CCoinsViewCache &view, bool fScriptChecks=true, unsigned int flags=SCRIPT_VERIFY_P2SH|SCRIPT_VERIFY_STRICTENC, std::vector< CScriptCheck > *pvChecks=NULL)
 
void UpdateCoins (const CTransaction &tx, CValidationState &state, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight, const uint256 &txhash)
 
bool CheckTransaction (const CTransaction &tx, CValidationState &state)
 
bool IsStandardTx (const CTransaction &tx, std::string &reason)
 Check for standard transaction types. More...
 
bool IsFinalTx (const CTransaction &tx, int nBlockHeight=0, int64_t nBlockTime=0)
 
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)
 
bool DisconnectBlock (CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool *pfClean=NULL)
 Functions for validating blocks and updating the block tree. More...
 
bool ConnectBlock (CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool fJustCheck=false)
 
bool AddToBlockIndex (CBlock &block, CValidationState &state, const CDiskBlockPos &pos)
 
bool CheckBlock (const CBlock &block, CValidationState &state, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
 
bool AcceptBlock (CBlock &block, CValidationState &state, CDiskBlockPos *dbp=NULL)
 

Variables

CScript COINBASE_FLAGS
 
CCriticalSection cs_main
 
CTxMemPool mempool
 
std::map< uint256, CBlockIndex * > mapBlockIndex
 
uint64_t nLastBlockTx
 
uint64_t nLastBlockSize
 
const std::string strMessageMagic
 
int64_t nTimeBestReceived
 
bool fImporting
 
bool fReindex
 
bool fBenchmark
 
int nScriptCheckThreads
 
bool fTxIndex
 
unsigned int nCoinCacheSize
 
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...
 
CCoinsViewCachepcoinsTip
 Global variable that points to the active CCoinsView (protected by cs_main) More...
 
CBlockTreeDBpblocktree
 Global variable that points to the active block tree (protected by cs_main) More...
 

Enumeration Type Documentation

Enumerator
BLOCK_VALID_UNKNOWN 
BLOCK_VALID_HEADER 
BLOCK_VALID_TREE 
BLOCK_VALID_TRANSACTIONS 
BLOCK_VALID_CHAIN 
BLOCK_VALID_SCRIPTS 
BLOCK_VALID_MASK 
BLOCK_HAVE_DATA 
BLOCK_HAVE_UNDO 
BLOCK_HAVE_MASK 
BLOCK_FAILED_VALID 
BLOCK_FAILED_CHILD 
BLOCK_FAILED_MASK 

Definition at line 675 of file main.h.

Enumerator
GMF_RELAY 
GMF_SEND 

Definition at line 268 of file main.h.

Function Documentation

bool AbortNode ( const std::string &  msg)

Abort with a message.

Definition at line 2687 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool AcceptBlock ( CBlock block,
CValidationState state,
CDiskBlockPos dbp = NULL 
)

Definition at line 2295 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool AcceptToMemoryPool ( CTxMemPool pool,
CValidationState state,
const CTransaction tx,
bool  fLimitFree,
bool *  pfMissingInputs,
bool  fRejectInsaneFee = false 
)

(try to) add transaction to memory pool

Definition at line 878 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool ActivateBestChain ( CValidationState state)

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

Definition at line 2028 of file main.cpp.

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 
)

Definition at line 2076 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool AllowFree ( double  dPriority)
inline

Definition at line 309 of file main.h.

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 646 of file main.cpp.

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 = true,
bool  fCheckMerkleRoot = true 
)

Definition at line 2229 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CheckDiskSpace ( uint64_t  nAdditionalBytes = 0)

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

Definition at line 2695 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool CheckInputs ( const CTransaction tx,
CValidationState state,
CCoinsViewCache view,
bool  fScriptChecks = true,
unsigned int  flags = SCRIPT_VERIFY_P2SH|SCRIPT_VERIFY_STRICTENC,
std::vector< CScriptCheck > *  pvChecks = NULL 
)

Definition at line 1454 of file main.cpp.

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 243 of file main2.cpp.

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 783 of file main.cpp.

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 35 of file main2.cpp.

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 coins,
bool  fJustCheck = false 
)

Definition at line 1669 of file main.cpp.

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 1543 of file main.cpp.

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 14 of file main2.cpp.

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 700 of file main.cpp.

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,
enum GetMinFee_mode  mode 
)

Definition at line 847 of file main.cpp.

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 
)

Definition at line 232 of file main2.cpp.

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 344 of file main.cpp.

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 714 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool GetTransaction ( const uint256 hash,
CTransaction tx,
uint256 hashBlock,
bool  fAllowSlow = false 
)

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

Definition at line 1075 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

std::string GetWarnings ( std::string  strFor)

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

bool InitBlockIndex ( )

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

Definition at line 2903 of file main.cpp.

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 2737 of file main.cpp.

Here is the caller graph for this function:

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

Definition at line 617 of file main.cpp.

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 1246 of file main.cpp.

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
bool LoadBlockIndex ( )

Load the block tree and coins database from disk.

Definition at line 2894 of file main.cpp.

Here is the caller graph for this function:

bool LoadExternalBlockFile ( FILE *  fileIn,
CDiskBlockPos dbp = NULL 
)

Import blocks from an external file.

Definition at line 3007 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void Misbehaving ( NodeId  nodeid,
int  howmuch 
)

Increase a node's misbehavior score.

Definition at line 1346 of file main.cpp.

Here is the call graph for this function:

FILE* OpenBlockFile ( const CDiskBlockPos pos,
bool  fReadOnly = false 
)

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

Definition at line 2729 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

FILE* OpenUndoFile ( const CDiskBlockPos pos,
bool  fReadOnly = false 
)

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

Definition at line 2733 of file main.cpp.

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 2938 of file main.cpp.

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 = NULL 
)

Process an incoming block.

Definition at line 2431 of file main.cpp.

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 4042 of file main.cpp.

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 2419 of file main.cpp.

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 1171 of file main.cpp.

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 1195 of file main.cpp.

Here is the call graph for this function:

void RegisterNodeSignals ( CNodeSignals nodeSignals)

Register with a network node to receive its signals.

Definition at line 359 of file main.cpp.

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 156 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

bool SendMessages ( CNode pto,
bool  fSendTrickle 
)

Send queued protocol messages to be sent to a give node.

Definition at line 4163 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void SyncWithWallets ( const uint256 hash,
const CTransaction tx,
const CBlock pblock = NULL 
)

Push an updated transaction to all registered wallets.

Definition at line 183 of file main.cpp.

Here is the caller graph for this function:

void ThreadScriptCheck ( )

Run an instance of the script checking thread.

Definition at line 1664 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

void UnloadBlockIndex ( )

Unload database information.

Definition at line 2886 of file main.cpp.

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 174 of file main.cpp.

Here is the caller graph for this function:

void UnregisterNodeSignals ( CNodeSignals nodeSignals)

Unregister a network node.

Definition at line 368 of file main.cpp.

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 165 of file main.cpp.

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 1423 of file main.cpp.

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 1404 of file main.cpp.

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 2812 of file main.cpp.

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 1449 of file main.cpp.

bool WriteBlockToDisk ( CBlock block,
CDiskBlockPos pos 
)

Functions for disk access for blocks.

Definition at line 1145 of file main.cpp.

Here is the call graph for this function:

Here is the caller graph for this function:

Variable Documentation

CChain chainActive

The currently-connected chain of blocks.

Definition at line 43 of file main.cpp.

CChain chainMostWork

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

Definition at line 44 of file main.cpp.

CScript COINBASE_FLAGS

Definition at line 75 of file main.cpp.

Definition at line 38 of file main.cpp.

bool fBenchmark

Definition at line 49 of file main.cpp.

bool fImporting

Definition at line 47 of file main.cpp.

bool fReindex

Definition at line 48 of file main.cpp.

bool fTxIndex

Definition at line 50 of file main.cpp.

std::map<uint256, CBlockIndex*> mapBlockIndex

Definition at line 42 of file main.cpp.

CTxMemPool mempool

Definition at line 40 of file main.cpp.

unsigned int nCoinCacheSize

Definition at line 51 of file main.cpp.

uint64_t nLastBlockSize

Definition at line 87 of file miner.cpp.

uint64_t nLastBlockTx

Definition at line 86 of file miner.cpp.

int nScriptCheckThreads

Definition at line 46 of file main.cpp.

int64_t nTimeBestReceived

Definition at line 45 of file main.cpp.

CBlockTreeDB* pblocktree

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

Definition at line 437 of file main.cpp.

CCoinsViewCache* pcoinsTip

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

Definition at line 436 of file main.cpp.

const std::string strMessageMagic

Definition at line 77 of file main.cpp.