Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

blockchain.cpp File Reference
#include <rpc/blockchain.h>
#include <amount.h>
#include <chain.h>
#include <chainparams.h>
#include <checkpoints.h>
#include <coins.h>
#include <core_io.h>
#include <consensus/validation.h>
#include <validation.h>
#include <policy/feerate.h>
#include <policy/policy.h>
#include <primitives/transaction.h>
#include <rpc/server.h>
#include <streams.h>
#include <sync.h>
#include <txdb.h>
#include <txmempool.h>
#include <util.h>
#include <utilstrencodings.h>
#include <hash.h>
#include <warnings.h>
#include <evo/specialtx.h>
#include <evo/cbtx.h>
#include <llmq/quorums_chainlocks.h>
#include <llmq/quorums_instantsend.h>
#include <stdint.h>
#include <univalue.h>
#include <boost/algorithm/string.hpp>
#include <boost/thread/thread.hpp>
#include <memory>
#include <mutex>
#include <condition_variable>
+ Include dependency graph for blockchain.cpp:

Go to the source code of this file.

Classes

struct  CUpdatedBlock
 
struct  CCoinsStats
 
struct  CompareBlocksByHeight
 Comparison function for sorting the getchaintips heads. More...
 

Functions

void TxToJSON (const CTransaction &tx, const uint256 hashBlock, UniValue &entry)
 
double GetDifficulty (const CChain &chain, const CBlockIndex *blockindex)
 
double GetDifficulty (const CBlockIndex *blockindex)
 Get the difficulty of the net wrt to the given block index, or the chain tip if not provided. More...
 
UniValue blockheaderToJSON (const CBlockIndex *blockindex)
 Block header to JSON. More...
 
UniValue blockToJSON (const CBlock &block, const CBlockIndex *blockindex, bool txDetails)
 Block description to JSON. More...
 
UniValue getblockcount (const JSONRPCRequest &request)
 
UniValue getbestblockhash (const JSONRPCRequest &request)
 
UniValue getbestchainlock (const JSONRPCRequest &request)
 
void RPCNotifyBlockChange (bool ibd, const CBlockIndex *pindex)
 Callback for when block tip changed. More...
 
UniValue waitfornewblock (const JSONRPCRequest &request)
 
UniValue waitforblock (const JSONRPCRequest &request)
 
UniValue waitforblockheight (const JSONRPCRequest &request)
 
UniValue getdifficulty (const JSONRPCRequest &request)
 
std::string EntryDescriptionString ()
 
void entryToJSON (UniValue &info, const CTxMemPoolEntry &e)
 
UniValue mempoolToJSON (bool fVerbose)
 Mempool to JSON. More...
 
UniValue getrawmempool (const JSONRPCRequest &request)
 
UniValue getmempoolancestors (const JSONRPCRequest &request)
 
UniValue getmempooldescendants (const JSONRPCRequest &request)
 
UniValue getmempoolentry (const JSONRPCRequest &request)
 
UniValue getblockhashes (const JSONRPCRequest &request)
 
UniValue getblockhash (const JSONRPCRequest &request)
 
UniValue getblockheader (const JSONRPCRequest &request)
 
UniValue getblockheaders (const JSONRPCRequest &request)
 
static CBlock GetBlockChecked (const CBlockIndex *pblockindex)
 
UniValue getmerkleblocks (const JSONRPCRequest &request)
 
UniValue getblock (const JSONRPCRequest &request)
 
static void ApplyStats (CCoinsStats &stats, CHashWriter &ss, const uint256 &hash, const std::map< uint32_t, Coin > &outputs)
 
static bool GetUTXOStats (CCoinsView *view, CCoinsStats &stats)
 Calculate statistics about the unspent transaction output set. More...
 
UniValue pruneblockchain (const JSONRPCRequest &request)
 
UniValue gettxoutsetinfo (const JSONRPCRequest &request)
 
UniValue gettxout (const JSONRPCRequest &request)
 
UniValue verifychain (const JSONRPCRequest &request)
 
static UniValue SoftForkMajorityDesc (int version, CBlockIndex *pindex, const Consensus::Params &consensusParams)
 Implementation of IsSuperMajority with better feedback. More...
 
static UniValue SoftForkDesc (const std::string &name, int version, CBlockIndex *pindex, const Consensus::Params &consensusParams)
 
static UniValue BIP9SoftForkDesc (const Consensus::Params &consensusParams, Consensus::DeploymentPos id)
 
void BIP9SoftForkDescPushBack (UniValue &bip9_softforks, const Consensus::Params &consensusParams, Consensus::DeploymentPos id)
 
UniValue getblockchaininfo (const JSONRPCRequest &request)
 
UniValue getchaintips (const JSONRPCRequest &request)
 
UniValue mempoolInfoToJSON ()
 Mempool information to JSON. More...
 
UniValue getmempoolinfo (const JSONRPCRequest &request)
 
UniValue preciousblock (const JSONRPCRequest &request)
 
UniValue invalidateblock (const JSONRPCRequest &request)
 
UniValue reconsiderblock (const JSONRPCRequest &request)
 
UniValue getchaintxstats (const JSONRPCRequest &request)
 
template<typename T >
static T CalculateTruncatedMedian (std::vector< T > &scores)
 
template<typename T >
static bool SetHasKeys (const std::set< T > &set)
 
template<typename T , typename Tk , typename... Args>
static bool SetHasKeys (const std::set< T > &set, const Tk &key, const Args &... args)
 
static UniValue getblockstats (const JSONRPCRequest &request)
 
UniValue getspecialtxes (const JSONRPCRequest &request)
 
UniValue savemempool (const JSONRPCRequest &request)
 
void RegisterBlockchainRPCCommands (CRPCTable &t)
 Register block chain RPC commands. More...
 

Variables

static std::mutex cs_blockchange
 
static std::condition_variable cond_blockchange
 
static CUpdatedBlock latestblock
 
static constexpr size_t PER_UTXO_OVERHEAD = sizeof(COutPoint) + sizeof(uint32_t) + sizeof(bool)
 
static const CRPCCommand commands []
 

Function Documentation

◆ ApplyStats()

static void ApplyStats ( CCoinsStats stats,
CHashWriter ss,
const uint256 hash,
const std::map< uint32_t, Coin > &  outputs 
)
static

◆ BIP9SoftForkDesc()

◆ BIP9SoftForkDescPushBack()

void BIP9SoftForkDescPushBack ( UniValue bip9_softforks,
const Consensus::Params consensusParams,
Consensus::DeploymentPos  id 
)

◆ blockheaderToJSON()

◆ blockToJSON()

◆ CalculateTruncatedMedian()

template<typename T >
static T CalculateTruncatedMedian ( std::vector< T > &  scores)
static

Definition at line 1882 of file blockchain.cpp.

Referenced by getblockstats().

◆ EntryDescriptionString()

std::string EntryDescriptionString ( )

◆ entryToJSON()

◆ getbestblockhash()

◆ getbestchainlock()

◆ getblock()

◆ getblockchaininfo()

◆ GetBlockChecked()

static CBlock GetBlockChecked ( const CBlockIndex pblockindex)
static

◆ getblockcount()

◆ getblockhash()

◆ getblockhashes()

◆ getblockheader()

◆ getblockheaders()

◆ getblockstats()

◆ getchaintips()

◆ getchaintxstats()

◆ GetDifficulty() [1/2]

double GetDifficulty ( const CChain chain,
const CBlockIndex blockindex 
)

◆ GetDifficulty() [2/2]

double GetDifficulty ( const CBlockIndex blockindex = nullptr)

Get the difficulty of the net wrt to the given block index, or the chain tip if not provided.

Returns
A floating point number that is a multiple of the main net minimum difficulty (4295032833 hashes).

Definition at line 92 of file blockchain.cpp.

References chainActive, and GetDifficulty().

◆ getdifficulty()

◆ getmempoolancestors()

◆ getmempooldescendants()

◆ getmempoolentry()

◆ getmempoolinfo()

◆ getmerkleblocks()

◆ getrawmempool()

◆ getspecialtxes()

◆ gettxout()

◆ gettxoutsetinfo()

◆ GetUTXOStats()

static bool GetUTXOStats ( CCoinsView view,
CCoinsStats stats 
)
static

◆ invalidateblock()

◆ mempoolInfoToJSON()

◆ mempoolToJSON()

◆ preciousblock()

◆ pruneblockchain()

◆ reconsiderblock()

◆ RegisterBlockchainRPCCommands()

void RegisterBlockchainRPCCommands ( CRPCTable t)

Register block chain RPC commands.

Definition at line 2293 of file blockchain.cpp.

References CRPCTable::appendCommand(), ARRAYLEN, commands, and CRPCCommand::name.

Referenced by RegisterAllCoreRPCCommands().

◆ RPCNotifyBlockChange()

void RPCNotifyBlockChange ( bool  ibd,
const CBlockIndex  
)

◆ savemempool()

◆ SetHasKeys() [1/2]

template<typename T >
static bool SetHasKeys ( const std::set< T > &  set)
inlinestatic

Definition at line 1898 of file blockchain.cpp.

Referenced by getblockstats(), and SetHasKeys().

◆ SetHasKeys() [2/2]

template<typename T , typename Tk , typename... Args>
static bool SetHasKeys ( const std::set< T > &  set,
const Tk &  key,
const Args &...  args 
)
inlinestatic

Definition at line 1900 of file blockchain.cpp.

References count, and SetHasKeys().

◆ SoftForkDesc()

static UniValue SoftForkDesc ( const std::string &  name,
int  version,
CBlockIndex pindex,
const Consensus::Params consensusParams 
)
static

Definition at line 1354 of file blockchain.cpp.

References name, Pair(), UniValue::push_back(), SoftForkMajorityDesc(), and UniValue::VOBJ.

Referenced by getblockchaininfo().

◆ SoftForkMajorityDesc()

static UniValue SoftForkMajorityDesc ( int  version,
CBlockIndex pindex,
const Consensus::Params consensusParams 
)
static

Implementation of IsSuperMajority with better feedback.

Definition at line 1334 of file blockchain.cpp.

References Consensus::Params::BIP34Height, Consensus::Params::BIP65Height, Consensus::Params::BIP66Height, CBlockIndex::nHeight, Pair(), UniValue::push_back(), and UniValue::VOBJ.

Referenced by SoftForkDesc().

◆ TxToJSON()

◆ verifychain()

◆ waitforblock()

◆ waitforblockheight()

◆ waitfornewblock()

Variable Documentation

◆ commands

const CRPCCommand commands[]
static

Definition at line 2254 of file blockchain.cpp.

Referenced by RegisterBlockchainRPCCommands().

◆ cond_blockchange

std::condition_variable cond_blockchange
static

◆ cs_blockchange

std::mutex cs_blockchange
static

◆ latestblock

CUpdatedBlock latestblock
static

◆ PER_UTXO_OVERHEAD

constexpr size_t PER_UTXO_OVERHEAD = sizeof(COutPoint) + sizeof(uint32_t) + sizeof(bool)
static

Definition at line 1906 of file blockchain.cpp.

Referenced by getblockstats().

Released under the MIT license