PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Classes | Enumerations | Functions | Variables
main.cpp File Reference
#include "main.h"
#include "addrman.h"
#include "amount.h"
#include "blocksignature.h"
#include "chainparams.h"
#include "checkpoints.h"
#include "checkqueue.h"
#include "consensus/merkle.h"
#include "consensus/tx_verify.h"
#include "consensus/validation.h"
#include "fs.h"
#include "init.h"
#include "invalid.h"
#include "kernel.h"
#include "masternode-budget.h"
#include "masternode-payments.h"
#include "masternode-sync.h"
#include "masternodeman.h"
#include "merkleblock.h"
#include "net.h"
#include "poa.h"
#include "swifttx.h"
#include "txdb.h"
#include "txmempool.h"
#include "guiinterface.h"
#include "util.h"
#include "utilmoneystr.h"
#include "validationinterface.h"
#include <sstream>
#include <boost/algorithm/string/replace.hpp>
#include <boost/foreach.hpp>
#include <boost/thread.hpp>
Include dependency graph for main.cpp:

Go to the source code of this file.

Classes

struct  COrphanTx
 
class  CMainCleanup
 

Enumerations

enum  FlushStateMode { FLUSH_STATE_IF_NEEDED, FLUSH_STATE_PERIODIC, FLUSH_STATE_ALWAYS }
 

Functions

void EraseOrphansFor (NodeId peer)
 
CAmount GetValueIn (CCoinsViewCache view, const CTransaction &tx)
 
double GetPriority (const CTransaction &tx, int nHeight)
 Return priority of tx at height nHeight. More...
 
bool IsSpentKeyImage (const std::string &kiHex, const uint256 &againsHash)
 
bool CheckKeyImageSpendInMainChain (const std::string &kiHex, int &confirmations)
 
secp256k1_context2GetContext ()
 
secp256k1_scratch_space2GetScratch ()
 
secp256k1_bulletproof_generatorsGetGenerator ()
 
void DestroyContext ()
 
bool VerifyBulletProofAggregate (const CTransaction &tx)
 
bool VerifyRingSignatureWithTxFee (const CTransaction &tx, CBlockIndex *pindex)
 
bool ReVerifyPoSBlock (CBlockIndex *pindex)
 
uint256 GetTxSignatureHash (const CTransaction &tx)
 
uint256 GetTxInSignatureHash (const CTxIn &txin)
 
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...
 
CBlockIndexFindForkInGlobalIndex (const CChain &chain, const CBlockLocator &locator)
 Find the last common block between the parameter chain and a locator. More...
 
bool AddOrphanTx (const CTransaction &tx, NodeId peer)
 
unsigned int LimitOrphanTxSize (unsigned int nMaxOrphans)
 
bool IsStandardTx (const CTransaction &tx, std::string &reason)
 Check for standard transaction types. More...
 
bool AreInputsStandard (const CTransaction &tx, const CCoinsViewCache &mapInputs)
 Check transaction inputs to mitigate two potential denial-of-service attacks: More...
 
int GetInputAge (CTxIn &vin)
 
int GetIXConfirmations (uint256 nTXHash)
 
bool VerifyShnorrKeyImageTxIn (const CTxIn &txin, uint256 ctsHash)
 
bool VerifyShnorrKeyImageTx (const CTransaction &tx)
 
bool CheckFinalTx (const CTransaction &tx, int flags)
 Check if transaction will be final in the next block to be created. More...
 
CAmount GetMinRelayFee (const CTransaction &tx, unsigned int nBytes, bool fAllowFree)
 
bool CheckHaveInputs (const CCoinsViewCache &view, const CTransaction &tx)
 Find the best known block, and make it the tip of the block chain. More...
 
bool AcceptToMemoryPool (CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee, bool ignoreFees)
 (try to) add transaction to memory pool More...
 
bool AcceptableInputs (CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee, bool isDSTX)
 
bool GetTransaction (const uint256 &hash, CTransaction &txOut, uint256 &hashBlock, bool fAllowSlow, CBlockIndex *blockIndex)
 Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock. 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)
 
double ConvertBitsToDouble (unsigned int nBits)
 
CAmount GetBlockValue (int nHeight)
 
CAmount GetSeeSaw (const CAmount &blockValue, int nMasternodeCount, int nHeight)
 
int64_t GetMasternodePayment (int nHeight, int64_t blockValue, int nMasternodeCount)
 
void SetRingSize (int nHeight)
 
bool IsInitialBlockDownload ()
 Check whether we are doing an initial block download (synchronizing from disk or network) More...
 
bool VerifyZeroBlindCommitment (const CTxOut &out)
 
bool VerifyDerivedAddress (const CTxOut &out, std::string stealth)
 
void CheckForkWarningConditions ()
 
void CheckForkWarningConditionsOnNewFork (CBlockIndex *pindexNewForkTip)
 
void Misbehaving (NodeId pnode, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
 Increase a node's misbehavior score. More...
 
void UpdateCoins (const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
 Apply the effects of this transaction on the UTXO set represented by view. More...
 
bool ValidOutPoint (const COutPoint out, int nHeight)
 
CAmount GetInvalidUTXOValue ()
 
bool CheckInputs (const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, bool fScriptChecks, unsigned int flags, bool cacheStore, std::vector< CScriptCheck > *pvChecks)
 Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) This does not modify the UTXO set. More...
 
bool DisconnectBlock (CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool *pfClean)
 Functions for validating blocks and updating the block tree. More...
 
bool FindUndoPos (CValidationState &state, int nFile, CDiskBlockPos &pos, unsigned int nAddSize)
 
void ThreadScriptCheck ()
 Run an instance of the script checking thread. More...
 
bool RecalculatePRCYSupply (int nHeightStart)
 
bool ConnectBlock (const CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &view, bool fJustCheck, bool fAlreadyChecked)
 Apply the effects of this block (with given index) on the UTXO set represented by coins. More...
 
void FlushStateToDisk ()
 Flush all state, indexes and buffers to disk. More...
 
bool DisconnectBlocks (int nBlocks)
 Reprocess a number of blocks to try and get on the correct chain again. More...
 
void ReprocessBlocks (int nBlocks)
 
void RemoveInvalidTransactionsFromMempool ()
 
bool ActivateBestChain (CValidationState &state, CBlock *pblock, bool fAlreadyChecked)
 Make the best chain active, in multiple steps. More...
 
bool InvalidateBlock (CValidationState &state, CBlockIndex *pindex)
 Mark a block as invalid. More...
 
bool ReconsiderBlock (CValidationState &state, CBlockIndex *pindex)
 Remove invalidity status from a block and its descendants. More...
 
CBlockIndexAddToBlockIndex (const CBlock &block)
 
bool ReceivedBlockTransactions (const CBlock &block, CValidationState &state, CBlockIndex *pindexNew, const CDiskBlockPos &pos)
 Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS). More...
 
bool FindBlockPos (CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown=false)
 
bool CheckBlockHeader (const CBlockHeader &block, CValidationState &state, bool fCheckPOW)
 Context-independent validity checks. More...
 
bool CheckBlock (const CBlock &block, CValidationState &state, bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig)
 
bool CheckWork (const CBlock block, CBlockIndex *const pindexPrev)
 
bool ContextualCheckBlockHeader (const CBlockHeader &block, CValidationState &state, CBlockIndex *const pindexPrev)
 Context-dependent validity checks. More...
 
bool IsBlockHashInChain (const uint256 &hashBlock)
 
bool IsTransactionInChain (const uint256 &txId, int &nHeightTx, CTransaction &tx)
 Context-independent validity checks. More...
 
bool IsTransactionInChain (const uint256 &txId, int &nHeightTx)
 
bool ContextualCheckBlock (const CBlock &block, CValidationState &state, CBlockIndex *const pindexPrev)
 
bool AcceptBlockHeader (const CBlock &block, CValidationState &state, CBlockIndex **ppindex)
 
bool AcceptBlock (CBlock &block, CValidationState &state, CBlockIndex **ppindex, CDiskBlockPos *dbp, bool fAlreadyCheckedBlock)
 Store block on disk. More...
 
bool ProcessNewBlock (CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp)
 Process an incoming block. More...
 
bool TestBlockValidity (CValidationState &state, const CBlock &block, CBlockIndex *const pindexPrev, bool fCheckPOW, bool fCheckMerkleRoot)
 Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held) 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...
 
fs::path GetBlockPosFilename (const CDiskBlockPos &pos, const char *prefix)
 Translation to a filesystem path. More...
 
CBlockIndexInsertBlockIndex (uint256 hash)
 Create a new block index entry for a given block hash. More...
 
void UnloadBlockIndex ()
 Unload database information. More...
 
bool LoadBlockIndex (std::string &strError)
 Load the block tree and coins database from disk. More...
 
bool InitBlockIndex ()
 Initialize a new block tree database + block data on disk. More...
 
bool LoadExternalBlockFile (FILE *fileIn, CDiskBlockPos *dbp)
 Import blocks from an external file. More...
 
std::string GetWarnings (std::string strFor)
 Format a string that describes several potential problems detected by the core. More...
 
int ActiveProtocol ()
 See whether the protocol update is enforced for connected nodes. More...
 
bool ProcessMessages (CNode *pfrom)
 Process protocol messages received from a given node. More...
 
bool SendMessages (CNode *pto)
 Send queued protocol messages to be sent to a give node. More...
 

Variables

RecursiveMutex cs_main
 Global state. More...
 
BlockMap mapBlockIndex
 
std::map< uint256, uint256mapProofOfStake
 
std::map< unsigned int, unsigned int > mapHashedBlocks
 
CChain chainActive
 The currently-connected chain of blocks. More...
 
CBlockIndexpindexBestHeader = NULL
 Best header we've seen so far (used for getheaders queries' starting points). More...
 
int64_t nTimeBestReceived = 0
 
Mutex g_best_block_mutex
 
std::condition_variable g_best_block_cv
 
uint256 g_best_block
 
int nScriptCheckThreads = 0
 
std::atomic< bool > fImporting {false}
 
std::atomic< bool > fReindex {false}
 
bool fTxIndex = true
 
bool fIsBareMultisigStd = true
 
bool fCheckBlockIndex = false
 
bool fVerifyingBlocks = false
 
size_t nCoinCacheUsage = 5000 * 300
 
int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE
 
int MIN_RING_SIZE
 
int MAX_RING_SIZE
 
const int MAX_TX_INPUTS = 50
 
const int MIN_TX_INPUTS_FOR_SWEEPING = 25
 
CFeeRate minRelayTxFee = CFeeRate(10000)
 Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times smaller then bitcoin now (2015-06-23), set minRelayTxFee only 10 times higher so it's still 10 times lower comparing to bitcoin. More...
 
CTxMemPool mempool (::minRelayTxFee)
 
std::map< uint256, COrphanTxmapOrphanTransactions
 
std::map< uint256, std::set< uint256 > > mapOrphanTransactionsByPrev
 
std::map< uint256, int64_t > mapRejectedBlocks
 
CScript COINBASE_FLAGS
 Constant stuff for coinbase transactions we create: More...
 
const std::string strMessageMagic = "DarkNet 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...
 
bool fLargeWorkForkFound = false
 
bool fLargeWorkInvalidChainFound = false
 
CBlockIndexpindexBestForkTip = NULL
 
CBlockIndexpindexBestForkBase = NULL
 
std::map< COutPoint, COutPointmapInvalidOutPoints
 
CAmount nFilteredThroughBittrex = 0
 
bool fListPopulatedAfterLock = false
 

Enumeration Type Documentation

◆ FlushStateMode

Enumerator
FLUSH_STATE_IF_NEEDED 
FLUSH_STATE_PERIODIC 
FLUSH_STATE_ALWAYS 

Definition at line 3372 of file main.cpp.

Function Documentation

◆ AcceptableInputs()

bool AcceptableInputs ( CTxMemPool pool,
CValidationState state,
const CTransaction tx,
bool  fLimitFree,
bool *  pfMissingInputs,
bool  fRejectInsaneFee,
bool  isDSTX 
)
Todo:
: @campv need to recompute the fee

Definition at line 1803 of file main.cpp.

Here is the call graph for this function:

◆ AcceptBlock()

bool AcceptBlock ( CBlock block,
CValidationState state,
CBlockIndex **  pindex,
CDiskBlockPos dbp = NULL,
bool  fAlreadyCheckedBlock = false 
)

Store block on disk.

If dbp is provided, the file is known to already reside on disk

Todo:
: deal better with duplicate blocks.
Todo:
: Remove this chain from disk.

Definition at line 4639 of file main.cpp.

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

◆ AcceptBlockHeader()

bool AcceptBlockHeader ( const CBlock block,
CValidationState state,
CBlockIndex **  ppindex 
)
Todo:
: ENABLE BLOCK CACHE IN SPECIFIC CASES

Definition at line 4571 of file main.cpp.

Here is the call graph for this function:

◆ AcceptToMemoryPool()

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

(try to) add transaction to memory pool

Definition at line 1579 of file main.cpp.

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

◆ ActivateBestChain()

bool ActivateBestChain ( CValidationState state,
CBlock pblock,
bool  fAlreadyChecked 
)

Make the best chain active, in multiple steps.

The result is either failure or an activated best chain. pblock is either NULL or a pointer to a block that is already loaded (to avoid loading it again from disk).

Definition at line 3892 of file main.cpp.

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

◆ ActiveProtocol()

int ActiveProtocol ( )

See whether the protocol update is enforced for connected nodes.

Definition at line 6844 of file main.cpp.

Here is the caller graph for this function:

◆ AddOrphanTx()

bool AddOrphanTx ( const CTransaction tx,
NodeId  peer 
)

Definition at line 1138 of file main.cpp.

Here is the call graph for this function:

◆ AddToBlockIndex()

CBlockIndex* AddToBlockIndex ( const CBlock block)

Definition at line 4043 of file main.cpp.

Here is the call graph for this function:

◆ AreInputsStandard()

bool AreInputsStandard ( const CTransaction tx,
const CCoinsViewCache mapInputs 
)

Check transaction inputs to mitigate two potential denial-of-service attacks:

Check transaction inputs, and make sure any pay-to-script-hash transactions are evaluating IsStandard scripts.

  1. scriptSigs with extra data stuffed into them, not consumed by scriptPubKey (or P2SH script)
  2. P2SH scripts with a crazy number of expensive CHECKSIG/CHECKMULTISIG operations

Definition at line 1309 of file main.cpp.

Here is the call graph for this function:

◆ CheckBlock()

bool CheckBlock ( const CBlock block,
CValidationState state,
bool  fCheckPOW,
bool  fCheckMerkleRoot,
bool  fCheckSig 
)
Todo:
Audit checkblock

Definition at line 4263 of file main.cpp.

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

◆ CheckBlockHeader()

bool CheckBlockHeader ( const CBlockHeader block,
CValidationState state,
bool  fCheckPOW 
)

Context-independent validity checks.

Definition at line 4237 of file main.cpp.

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

◆ CheckDiskSpace()

bool CheckDiskSpace ( uint64_t  nAdditionalBytes)

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

Definition at line 5116 of file main.cpp.

Here is the call graph for this function:

◆ CheckFinalTx()

bool CheckFinalTx ( const CTransaction tx,
int  flags = -1 
)

Check if transaction will be final in the next block to be created.

Calls IsFinalTx() with current block height and appropriate block time.

See consensus/consensus.h for flag definitions.

Definition at line 1465 of file main.cpp.

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

◆ CheckForkWarningConditions()

void CheckForkWarningConditions ( )

Definition at line 2570 of file main.cpp.

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

◆ CheckForkWarningConditionsOnNewFork()

void CheckForkWarningConditionsOnNewFork ( CBlockIndex pindexNewForkTip)

Definition at line 2612 of file main.cpp.

Here is the call graph for this function:

◆ CheckHaveInputs()

bool CheckHaveInputs ( const CCoinsViewCache view,
const CTransaction tx 
)

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

Definition at line 1521 of file main.cpp.

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

◆ CheckInputs()

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

Check whether all inputs of this transaction are valid (no double spends, scripts & sigs, amounts) This does not modify the UTXO set.

If pvChecks is not NULL, script checks are pushed onto it instead of being performed inline.

Definition at line 2766 of file main.cpp.

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

◆ CheckKeyImageSpendInMainChain()

bool CheckKeyImageSpendInMainChain ( const std::string &  kiHex,
int &  confirmations 
)

Definition at line 320 of file main.cpp.

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

◆ CheckWork()

bool CheckWork ( const CBlock  block,
CBlockIndex *const  pindexPrev 
)

Definition at line 4437 of file main.cpp.

Here is the call graph for this function:

◆ ConnectBlock()

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

Apply the effects of this block (with given index) on the UTXO set represented by coins.

@Audit ConnectBlock

Definition at line 3085 of file main.cpp.

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

◆ ContextualCheckBlock()

bool ContextualCheckBlock ( const CBlock block,
CValidationState state,
CBlockIndex *const  pindexPrev 
)

Definition at line 4545 of file main.cpp.

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

◆ ContextualCheckBlockHeader()

bool ContextualCheckBlockHeader ( const CBlockHeader block,
CValidationState state,
CBlockIndex *const  pindexPrev 
)

Context-dependent validity checks.

Definition at line 4458 of file main.cpp.

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

◆ ConvertBitsToDouble()

double ConvertBitsToDouble ( unsigned int  nBits)
Todo:
***

Definition at line 2139 of file main.cpp.

Here is the caller graph for this function:

◆ DestroyContext()

void DestroyContext ( )

Definition at line 369 of file main.cpp.

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

◆ DisconnectBlock()

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

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

◆ DisconnectBlocks()

bool DisconnectBlocks ( int  nBlocks)

Reprocess a number of blocks to try and get on the correct chain again.

Definition at line 3647 of file main.cpp.

Here is the caller graph for this function:

◆ EraseOrphansFor()

void EraseOrphansFor ( NodeId  peer)

Definition at line 1183 of file main.cpp.

◆ FindBlockPos()

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

Definition at line 4158 of file main.cpp.

◆ FindForkInGlobalIndex()

CBlockIndex* FindForkInGlobalIndex ( const CChain chain,
const CBlockLocator locator 
)

Find the last common block between the parameter chain and a locator.

Definition at line 1115 of file main.cpp.

Here is the call graph for this function:

◆ FindUndoPos()

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

Definition at line 4208 of file main.cpp.

◆ FlushStateToDisk()

void FlushStateToDisk ( )

Flush all state, indexes and buffers to disk.

Definition at line 3467 of file main.cpp.

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

◆ GetBlockPosFilename()

fs::path GetBlockPosFilename ( const CDiskBlockPos pos,
const char *  prefix 
)

Translation to a filesystem path.

Definition at line 5160 of file main.cpp.

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

◆ GetBlockValue()

CAmount GetBlockValue ( int  nHeight)

Definition at line 2158 of file main.cpp.

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

◆ GetContext()

secp256k1_context2* GetContext ( )

Definition at line 348 of file main.cpp.

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

◆ GetGenerator()

Definition at line 362 of file main.cpp.

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

◆ GetInputAge()

int GetInputAge ( CTxIn vin)

Definition at line 1373 of file main.cpp.

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

◆ GetInvalidUTXOValue()

CAmount GetInvalidUTXOValue ( )

Definition at line 2748 of file main.cpp.

Here is the call graph for this function:

◆ GetIXConfirmations()

int GetIXConfirmations ( uint256  nTXHash)

Definition at line 1392 of file main.cpp.

Here is the caller graph for this function:

◆ GetMasternodePayment()

int64_t GetMasternodePayment ( int  nHeight,
int64_t  blockValue,
int  nMasternodeCount 
)

Definition at line 2454 of file main.cpp.

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

◆ GetMinRelayFee()

CAmount GetMinRelayFee ( const CTransaction tx,
unsigned int  nBytes,
bool  fAllowFree 
)

Definition at line 1495 of file main.cpp.

Here is the call graph for this function:

◆ GetNodeStateStats()

bool GetNodeStateStats ( NodeId  nodeid,
CNodeStateStats stats 
)

Get statistics from node state.

Definition at line 1081 of file main.cpp.

Here is the caller graph for this function:

◆ GetPriority()

double GetPriority ( const CTransaction tx,
int  nHeight 
)

Return priority of tx at height nHeight.

Definition at line 259 of file main.cpp.

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

◆ GetScratch()

secp256k1_scratch_space2* GetScratch ( )

Definition at line 355 of file main.cpp.

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

◆ GetSeeSaw()

CAmount GetSeeSaw ( const CAmount blockValue,
int  nMasternodeCount,
int  nHeight 
)

Definition at line 2187 of file main.cpp.

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

◆ GetTransaction()

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

Return transaction in tx, and if it was found inside a block, its hash is placed in hashBlock.

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

Definition at line 2010 of file main.cpp.

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

◆ GetTxInSignatureHash()

uint256 GetTxInSignatureHash ( const CTxIn txin)

Definition at line 687 of file main.cpp.

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

◆ GetTxSignatureHash()

uint256 GetTxSignatureHash ( const CTransaction tx)

Definition at line 681 of file main.cpp.

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

◆ GetValueIn()

CAmount GetValueIn ( CCoinsViewCache  view,
const CTransaction tx 
)

Definition at line 221 of file main.cpp.

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

◆ GetWarnings()

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

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

Definition at line 5739 of file main.cpp.

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

◆ InitBlockIndex()

bool InitBlockIndex ( )

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

Definition at line 5425 of file main.cpp.

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

◆ InsertBlockIndex()

CBlockIndex* InsertBlockIndex ( uint256  hash)

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

Definition at line 5165 of file main.cpp.

Here is the call graph for this function:

◆ InvalidateBlock()

bool InvalidateBlock ( CValidationState state,
CBlockIndex pindex 
)

Mark a block as invalid.

Definition at line 3972 of file main.cpp.

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

◆ IsBlockHashInChain()

bool IsBlockHashInChain ( const uint256 hashBlock)

Definition at line 4519 of file main.cpp.

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

◆ IsInitialBlockDownload()

bool IsInitialBlockDownload ( )

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

Definition at line 2500 of file main.cpp.

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

◆ IsSpentKeyImage()

bool IsSpentKeyImage ( const std::string &  kiHex,
const uint256 againsHash 
)

Definition at line 283 of file main.cpp.

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

◆ IsStandardTx()

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

Here is the call graph for this function:

◆ IsTransactionInChain() [1/2]

bool IsTransactionInChain ( const uint256 txId,
int &  nHeightTx 
)

Definition at line 4539 of file main.cpp.

Here is the call graph for this function:

◆ IsTransactionInChain() [2/2]

bool IsTransactionInChain ( const uint256 txId,
int &  nHeightTx,
CTransaction tx 
)

Context-independent validity checks.

Definition at line 4527 of file main.cpp.

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

◆ LimitOrphanTxSize()

unsigned int LimitOrphanTxSize ( unsigned int  nMaxOrphans)

Definition at line 1198 of file main.cpp.

Here is the call graph for this function:

◆ LoadBlockIndex()

bool LoadBlockIndex ( std::string &  strError)

Load the block tree and coins database from disk.

Definition at line 5416 of file main.cpp.

◆ LoadExternalBlockFile()

bool LoadExternalBlockFile ( FILE *  fileIn,
CDiskBlockPos dbp 
)

Import blocks from an external file.

Definition at line 5467 of file main.cpp.

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

◆ Misbehaving()

void Misbehaving ( NodeId  pnode,
int  howmuch 
)

Increase a node's misbehavior score.

Definition at line 2645 of file main.cpp.

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

◆ OpenBlockFile()

FILE* OpenBlockFile ( const CDiskBlockPos pos,
bool  fReadOnly 
)

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

Definition at line 5150 of file main.cpp.

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

◆ OpenDiskFile()

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

Definition at line 5127 of file main.cpp.

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

◆ OpenUndoFile()

FILE* OpenUndoFile ( const CDiskBlockPos pos,
bool  fReadOnly 
)

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

Definition at line 5155 of file main.cpp.

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

◆ ProcessMessages()

bool ProcessMessages ( CNode pfrom)

Process protocol messages received from a given node.

Definition at line 6849 of file main.cpp.

Here is the caller graph for this function:

◆ ProcessNewBlock()

bool ProcessNewBlock ( CValidationState state,
CNode pfrom,
CBlock pblock,
CDiskBlockPos dbp = NULL 
)

Process an incoming block.

This only returns after the best known valid block is made active. Note that it does not, however, guarantee that the specific block passed to it has been checked for validity!

Parameters
[out]stateThis may be set to an Error state if any error occurred processing it, including during validation/connection/etc of otherwise unrelated blocks during reorganisation; or it may be set to an Invalid state if pblock is itself invalid (but this is not guaranteed even when the block is checked). If you want to possibly get feedback on whether pblock is valid, you must also install a CValidationInterface - this will have its BlockChecked method called whenever any block completes validation.
[in]pfromThe node which we are receiving the block from; it is added to mapBlockSource and may be penalised if the block is invalid.
[in]pblockThe block we want to process.
[out]dbpIf pblock is stored to disk (or already there), this will be set to its location.
Returns
True if state.IsValid()

Definition at line 4890 of file main.cpp.

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

◆ ReadBlockFromDisk() [1/2]

bool ReadBlockFromDisk ( CBlock block,
const CBlockIndex pindex 
)

Definition at line 2126 of file main.cpp.

Here is the call graph for this function:

◆ ReadBlockFromDisk() [2/2]

bool ReadBlockFromDisk ( CBlock block,
const CDiskBlockPos pos 
)

Definition at line 2101 of file main.cpp.

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

◆ RecalculatePRCYSupply()

bool RecalculatePRCYSupply ( int  nHeightStart)

Definition at line 3002 of file main.cpp.

Here is the call graph for this function:

◆ ReceivedBlockTransactions()

bool ReceivedBlockTransactions ( const CBlock block,
CValidationState state,
CBlockIndex pindexNew,
const CDiskBlockPos pos 
)

Mark a block as having its data received and checked (up to BLOCK_VALID_TRANSACTIONS).

Definition at line 4110 of file main.cpp.

Here is the call graph for this function:

◆ ReconsiderBlock()

bool ReconsiderBlock ( CValidationState state,
CBlockIndex pindex 
)

Remove invalidity status from a block and its descendants.

Definition at line 4008 of file main.cpp.

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

◆ RegisterNodeSignals()

void RegisterNodeSignals ( CNodeSignals nodeSignals)

Register with a network node to receive its signals.

Definition at line 1097 of file main.cpp.

Here is the call graph for this function:

◆ RemoveInvalidTransactionsFromMempool()

void RemoveInvalidTransactionsFromMempool ( )

Definition at line 3691 of file main.cpp.

Here is the call graph for this function:

◆ ReprocessBlocks()

void ReprocessBlocks ( int  nBlocks)

Definition at line 3660 of file main.cpp.

Here is the call graph for this function:

◆ ReVerifyPoSBlock()

bool ReVerifyPoSBlock ( CBlockIndex pindex)

Definition at line 621 of file main.cpp.

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

◆ SendMessages()

bool SendMessages ( CNode pto)

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

Parameters
[in]ptoThe node which we are sending messages to.

Definition at line 6948 of file main.cpp.

Here is the caller graph for this function:

◆ SetRingSize()

void SetRingSize ( int  nHeight)

Definition at line 2466 of file main.cpp.

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

◆ TestBlockValidity()

bool TestBlockValidity ( CValidationState state,
const CBlock block,
CBlockIndex *const  pindexPrev,
bool  fCheckPOW,
bool  fCheckMerkleRoot 
)

Check a block is completely valid from start to finish (only works on top of our current best block, with cs_main held)

Definition at line 5088 of file main.cpp.

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

◆ ThreadScriptCheck()

void ThreadScriptCheck ( )

Run an instance of the script checking thread.

Definition at line 2996 of file main.cpp.

Here is the call graph for this function:

◆ UnloadBlockIndex()

void UnloadBlockIndex ( )

Unload database information.

Definition at line 5386 of file main.cpp.

Here is the call graph for this function:

◆ UnregisterNodeSignals()

void UnregisterNodeSignals ( CNodeSignals nodeSignals)

Unregister a network node.

Definition at line 1106 of file main.cpp.

Here is the call graph for this function:

◆ UpdateCoins()

void UpdateCoins ( const CTransaction tx,
CCoinsViewCache inputs,
CTxUndo txundo,
int  nHeight 
)

Apply the effects of this transaction on the UTXO set represented by view.

Definition at line 2706 of file main.cpp.

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

◆ ValidOutPoint()

bool ValidOutPoint ( const COutPoint  out,
int  nHeight 
)

Definition at line 2741 of file main.cpp.

Here is the call graph for this function:

◆ VerifyBulletProofAggregate()

bool VerifyBulletProofAggregate ( const CTransaction tx)

Definition at line 376 of file main.cpp.

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

◆ VerifyDerivedAddress()

bool VerifyDerivedAddress ( const CTxOut out,
std::string  stealth 
)

Definition at line 2549 of file main.cpp.

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

◆ VerifyRingSignatureWithTxFee()

bool VerifyRingSignatureWithTxFee ( const CTransaction tx,
CBlockIndex pindex 
)

Definition at line 393 of file main.cpp.

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

◆ VerifyShnorrKeyImageTx()

bool VerifyShnorrKeyImageTx ( const CTransaction tx)

Definition at line 1454 of file main.cpp.

Here is the call graph for this function:

◆ VerifyShnorrKeyImageTxIn()

bool VerifyShnorrKeyImageTxIn ( const CTxIn txin,
uint256  ctsHash 
)

Definition at line 1407 of file main.cpp.

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

◆ VerifyZeroBlindCommitment()

bool VerifyZeroBlindCommitment ( const CTxOut out)

Definition at line 2540 of file main.cpp.

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

◆ WriteBlockToDisk()

bool WriteBlockToDisk ( CBlock block,
CDiskBlockPos pos 
)

Functions for disk access for blocks.

Definition at line 2080 of file main.cpp.

Here is the call graph for this function:

Variable Documentation

◆ chainActive

CChain chainActive

The currently-connected chain of blocks.

Definition at line 70 of file main.cpp.

◆ COINBASE_FLAGS

CScript COINBASE_FLAGS

Constant stuff for coinbase transactions we create:

Definition at line 117 of file main.cpp.

◆ cs_main

RecursiveMutex cs_main

Global state.

Mutex to guard access to validation specific variables, such as reading or changing the chainstate.

This may also need to be locked when updating the transaction pool, e.g. on AcceptToMemoryPool. See CTxMemPool::cs comment for details.

The transaction pool has a separate lock to allow reading from it and the chainstate at the same time.

Definition at line 65 of file main.cpp.

◆ fCheckBlockIndex

bool fCheckBlockIndex = false

Definition at line 84 of file main.cpp.

◆ fImporting

std::atomic<bool> fImporting {false}

Definition at line 80 of file main.cpp.

◆ fIsBareMultisigStd

bool fIsBareMultisigStd = true

Definition at line 83 of file main.cpp.

◆ fLargeWorkForkFound

bool fLargeWorkForkFound = false

Definition at line 2516 of file main.cpp.

◆ fLargeWorkInvalidChainFound

bool fLargeWorkInvalidChainFound = false

Definition at line 2517 of file main.cpp.

◆ fListPopulatedAfterLock

bool fListPopulatedAfterLock = false

Definition at line 2739 of file main.cpp.

◆ fReindex

std::atomic<bool> fReindex {false}

Definition at line 81 of file main.cpp.

◆ fTxIndex

bool fTxIndex = true

Definition at line 82 of file main.cpp.

◆ fVerifyingBlocks

bool fVerifyingBlocks = false

Definition at line 85 of file main.cpp.

◆ g_best_block

uint256 g_best_block

Definition at line 77 of file main.cpp.

◆ g_best_block_cv

std::condition_variable g_best_block_cv

Definition at line 76 of file main.cpp.

◆ g_best_block_mutex

Mutex g_best_block_mutex

Definition at line 75 of file main.cpp.

◆ mapBlockIndex

BlockMap mapBlockIndex

Definition at line 67 of file main.cpp.

◆ mapHashedBlocks

std::map<unsigned int, unsigned int> mapHashedBlocks

Definition at line 69 of file main.cpp.

◆ mapInvalidOutPoints

std::map<COutPoint, COutPoint> mapInvalidOutPoints

Definition at line 2735 of file main.cpp.

◆ mapOrphanTransactions

std::map<uint256, COrphanTx> mapOrphanTransactions

Definition at line 108 of file main.cpp.

◆ mapOrphanTransactionsByPrev

std::map<uint256, std::set<uint256> > mapOrphanTransactionsByPrev

Definition at line 109 of file main.cpp.

◆ mapProofOfStake

std::map<uint256, uint256> mapProofOfStake

Definition at line 68 of file main.cpp.

◆ mapRejectedBlocks

std::map<uint256, int64_t> mapRejectedBlocks

Definition at line 110 of file main.cpp.

◆ MAX_RING_SIZE

int MAX_RING_SIZE

Definition at line 92 of file main.cpp.

◆ MAX_TX_INPUTS

const int MAX_TX_INPUTS = 50

Definition at line 93 of file main.cpp.

◆ mempool

◆ MIN_RING_SIZE

int MIN_RING_SIZE

Definition at line 91 of file main.cpp.

◆ MIN_TX_INPUTS_FOR_SWEEPING

const int MIN_TX_INPUTS_FOR_SWEEPING = 25

Definition at line 94 of file main.cpp.

◆ minRelayTxFee

CFeeRate minRelayTxFee = CFeeRate(10000)

Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times smaller then bitcoin now (2015-06-23), set minRelayTxFee only 10 times higher so it's still 10 times lower comparing to bitcoin.

Definition at line 100 of file main.cpp.

◆ nCoinCacheUsage

size_t nCoinCacheUsage = 5000 * 300

Definition at line 86 of file main.cpp.

◆ nFilteredThroughBittrex

CAmount nFilteredThroughBittrex = 0

Definition at line 2738 of file main.cpp.

◆ nMaxTipAge

int64_t nMaxTipAge = DEFAULT_MAX_TIP_AGE

Definition at line 89 of file main.cpp.

◆ nScriptCheckThreads

int nScriptCheckThreads = 0

Definition at line 79 of file main.cpp.

◆ nTimeBestReceived

int64_t nTimeBestReceived = 0

Definition at line 72 of file main.cpp.

◆ pblocktree

CBlockTreeDB* pblocktree = NULL

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

Definition at line 1131 of file main.cpp.

◆ pcoinsTip

CCoinsViewCache* pcoinsTip = NULL

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

Definition at line 1130 of file main.cpp.

◆ pindexBestForkBase

CBlockIndex * pindexBestForkBase = NULL

Definition at line 2518 of file main.cpp.

◆ pindexBestForkTip

CBlockIndex* pindexBestForkTip = NULL

Definition at line 2518 of file main.cpp.

◆ pindexBestHeader

CBlockIndex* pindexBestHeader = NULL

Best header we've seen so far (used for getheaders queries' starting points).

Definition at line 71 of file main.cpp.

◆ strMessageMagic

const std::string strMessageMagic = "DarkNet Signed Message:\n"

Definition at line 119 of file main.cpp.