 |
PRCYCoin
2.0.0.7rc1
P2P Digital Currency
|
Go to the documentation of this file.
10 #define BITCOIN_MAIN_H
12 #if defined(HAVE_CONFIG_H)
44 #include <boost/unordered_map.hpp>
64 static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
65 static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
67 static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
69 static const unsigned int MAX_STANDARD_TX_SIZE = 150000;
71 static const unsigned int MAX_P2SH_SIGOPS = 15;
73 static const unsigned int DEFAULT_MAX_ORPHAN_TRANSACTIONS = 100;
75 static const unsigned int MAX_BLOCKFILE_SIZE = 0x8000000;
77 static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000;
79 static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000;
81 static const int COINBASE_MATURITY = 100;
83 static const int MAX_SCRIPTCHECK_THREADS = 16;
85 static const int DEFAULT_SCRIPTCHECK_THREADS = 0;
87 static const int MAX_BLOCKS_IN_TRANSIT_PER_PEER = 16;
89 static const unsigned int BLOCK_STALLING_TIMEOUT = 2;
92 static const unsigned int MAX_HEADERS_RESULTS = 2000;
97 static const unsigned int BLOCK_DOWNLOAD_WINDOW = 1024;
99 static const unsigned int DATABASE_WRITE_INTERVAL = 60 * 60;
101 static const unsigned int DATABASE_FLUSH_INTERVAL = 24 * 60 * 60;
103 static const unsigned int MAX_REJECT_MESSAGE_LENGTH = 111;
105 static const unsigned int AVG_LOCAL_ADDRESS_BROADCAST_INTERVAL = 24 * 24 * 60;
107 static const unsigned int AVG_ADDRESS_BROADCAST_INTERVAL = 30;
110 static const unsigned int AVG_INVENTORY_BROADCAST_INTERVAL = 5;
113 static const bool DEFAULT_PEERBLOOMFILTERS =
true;
116 static const bool DEFAULT_BLOCK_SPAM_FILTER =
true;
118 static const unsigned int DEFAULT_BLOCK_SPAM_FILTER_MAX_SIZE = COINBASE_MATURITY;
120 static const unsigned int DEFAULT_BLOCK_SPAM_FILTER_MAX_AVG = 10;
123 static const int64_t DEFAULT_MAX_TIP_AGE = 24 * 60 * 60;
134 typedef boost::unordered_map<uint256, CBlockIndex*, BlockHasher>
BlockMap;
178 static const uint64_t nMinDiskSpace = 52428800;
372 std::swap(
nIn, check.
nIn);
447 #endif // BITCOIN_MAIN_H
bool CheckBlockHeader(const CBlockHeader &block, CValidationState &state, bool fCheckPOW=true)
Context-independent validity checks.
An input of a transaction.
std::atomic< bool > fImporting
bool WriteBlockToDisk(CBlock &block, CDiskBlockPos &pos)
Functions for disk access for blocks.
bool ConnectBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool fJustCheck, bool fAlreadyChecked=false)
Apply the effects of this block (with given index) on the UTXO set represented by coins.
std::vector< int > vHeightInFlight
bool VerifyRingSignatureWithTxFee(const CTransaction &tx, CBlockIndex *pindex)
int GetInputAge(CTxIn &vin)
bool fLargeWorkInvalidChainFound
void FlushStateToDisk()
Flush all state, indexes and buffers to disk.
bool AcceptBlock(CBlock &block, CValidationState &state, CBlockIndex **pindex, CDiskBlockPos *dbp=NULL, bool fAlreadyCheckedBlock=false)
Store block on disk.
bool CheckBlock(const CBlock &block, CValidationState &state, bool fCheckPOW=true, bool fCheckMerkleRoot=true, bool fCheckSig=true)
void UpdateCoins(const CTransaction &tx, CCoinsViewCache &inputs, CTxUndo &txundo, int nHeight)
Apply the effects of this transaction on the UTXO set represented by view.
bool TestBlockValidity(CValidationState &state, const CBlock &block, CBlockIndex *pindexPrev, bool fCheckPOW=true, bool fCheckMerkleRoot=true)
Check a block is completely valid from start to finish (only works on top of our current best block,...
Undo information for a CTransaction.
BloomFilter is a probabilistic filter which SPV clients provide so that we can filter the transaction...
const std::string strMessageMagic
int64_t nTimeBestReceived
FILE * OpenUndoFile(const CDiskBlockPos &pos, bool fReadOnly=false)
Open an undo file (rev?????.dat)
bool VerifyDerivedAddress(const CTxOut &out, std::string stealth)
CScriptCheck(const CCoins &txFromIn, const CTransaction &txToIn, unsigned int nInIn, unsigned int nFlagsIn, bool cacheIn)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
CBlockTreeDB * pblocktree
Global variable that points to the active block tree (protected by cs_main)
std::map< unsigned int, unsigned int > mapHashedBlocks
CBlockIndex * InsertBlockIndex(uint256 hash)
Create a new block index entry for a given block hash.
Information about a peer.
const CTransaction * ptxTo
bool CheckDiskSpace(uint64_t nAdditionalBytes=0)
Check whether enough disk space is available for an incoming block.
double GetPriority(const CTransaction &tx, int nHeight)
Return priority of tx at height nHeight.
bool ActivateBestChain(CValidationState &state, CBlock *pblock=NULL, bool fAlreadyChecked=false)
Make the best chain active, in multiple steps.
bool VerifyBulletProofAggregate(const CTransaction &tx)
bool ReVerifyPoSBlock(CBlockIndex *pindex)
bool IsTransactionInChain(const uint256 &txId, int &nHeightTx, CTransaction &tx)
Context-independent validity checks.
int64_t GetMasternodePayment(int nHeight, int64_t blockValue, int nMasternodeCount=0)
RecursiveMutex cs_main
Global state.
bool ContextualCheckBlockHeader(const CBlockHeader &block, CValidationState &state, CBlockIndex *pindexPrev)
Context-dependent validity checks.
int64_t nLastCoinStakeSearchTime
bool ReadBlockFromDisk(CBlock &block, const CDiskBlockPos &pos)
unsigned int GetNextWorkRequired(const CBlockIndex *pindexLast, const CBlockHeader *pblock, bool fProofOfStake)
void Misbehaving(NodeId nodeid, int howmuch) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
Increase a node's misbehavior score.
Fee rate in PRCY per kilobyte: CAmount / kB.
bool ProcessNewBlock(CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp=NULL)
Process an incoming block.
bool DisconnectBlocks(int nBlocks)
Reprocess a number of blocks to try and get on the correct chain again.
The basic transaction that is broadcasted on the network and contained in blocks.
enum ScriptError_t ScriptError
CFeeRate minRelayTxFee
Fees smaller than this (in duffs) are considered zero fee (for relaying and mining) We are ~100 times...
CChain chainActive
The currently-connected chain of blocks.
Abstract view on the open txout dataset.
bool VerifyZeroBlindCommitment(const CTxOut &out)
std::map< uint256, int64_t > mapRejectedBlocks
uint64_t GetCheapHash() const
void UnregisterNodeSignals(CNodeSignals &nodeSignals)
Unregister a network node.
void swap(CScriptCheck &check)
void RemoveInvalidTransactionsFromMempool()
CScript COINBASE_FLAGS
Constant stuff for coinbase transactions we create:
ScriptError GetScriptError() const
An output of a transaction.
bool VerifyShnorrKeyImageTx(const CTransaction &tx)
void RegisterNodeSignals(CNodeSignals &nodeSignals)
Register with a network node to receive its signals.
bool ProcessMessages(CNode *pfrom)
Process protocol messages received from a given node.
bool CheckHaveInputs(const CCoinsViewCache &view, const CTransaction &tx)
Find the best known block, and make it the tip of the block chain.
bool GetTransaction(const uint256 &hash, CTransaction &tx, uint256 &hashBlock, bool fAllowSlow=false, CBlockIndex *blockIndex=nullptr)
Retrieve a transaction (from memory pool, or from disk, if possible)
bool ContextualCheckBlock(const CBlock &block, CValidationState &state, CBlockIndex *pindexPrev)
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs)
Check transaction inputs, and make sure any pay-to-script-hash transactions are evaluating IsStandard...
CAmount GetMinRelayFee(const CTransaction &tx, unsigned int nBytes, bool fAllowFree)
void UnloadBlockIndex()
Unload database information.
bool VerifyShnorrKeyImageTxIn(const CTxIn &txin, uint256 sigHash)
bool LoadBlockIndex(std::string &strError)
Load the block tree and coins database from disk.
void swap(prevector< N, T, Size, Diff > &other)
bool AcceptableInputs(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee=false, bool isDSTX=false)
bool LoadExternalBlockFile(FILE *fileIn, CDiskBlockPos *dbp=NULL)
Import blocks from an external file.
Access to the block database (blocks/index/)
int64_t CAmount
Amount in PRCY (Can be negative)
size_t operator()(const uint256 &hash) const
bool SendMessages(CNode *pto)
Send queued protocol messages to be sent to a give node.
bool DisconnectBlock(CBlock &block, CValidationState &state, CBlockIndex *pindex, CCoinsViewCache &coins, bool *pfClean=NULL)
Functions for validating blocks and updating the block tree.
bool AcceptBlockHeader(const CBlockHeader &block, CValidationState &state, CBlockIndex **ppindex=NULL)
void ReprocessBlocks(int nBlocks)
std::atomic< bool > fReindex
256-bit unsigned big integer.
secp256k1_context2 * GetContext()
bool ReconsiderBlock(CValidationState &state, CBlockIndex *pindex)
Remove invalidity status from a block and its descendants.
Serialized script, used inside transaction inputs and outputs.
FILE * OpenBlockFile(const CDiskBlockPos &pos, bool fReadOnly=false)
Open a block file (blk?????.dat)
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.
RAII wrapper for VerifyDB: Verify consistency of the block and coin databases.
fs::path GetBlockPosFilename(const CDiskBlockPos &pos, const char *prefix)
Translation to a filesystem path.
int64_t nLastCoinStakeSearchInterval
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,...
bool CheckWork(const CBlock block, CBlockIndex *const pindexPrev)
bool AcceptToMemoryPool(CTxMemPool &pool, CValidationState &state, const CTransaction &tx, bool fLimitFree, bool *pfMissingInputs, bool fRejectInsaneFee=false, bool ignoreFees=false)
(try to) add transaction to memory pool
CBlockIndex * pindexBestHeader
Best header we've seen so far (used for getheaders queries' starting points).
bool VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth)
An in-memory indexed chain of blocks.
int GetIXConfirmations(uint256 nTXHash)
bool InvalidateBlock(CValidationState &state, CBlockIndex *pindex)
Mark a block as invalid.
CCoinsView that adds a memory cache for transactions to another CCoinsView.
bool CheckKeyImageSpendInMainChain(const std::string &kiHex, int &confirmations)
CAmount GetBlockValue(int nHeight)
bool ValidOutPoint(const COutPoint out, int nHeight=1)
#define EXCLUSIVE_LOCKS_REQUIRED(...)
bool IsSpentKeyImage(const std::string &kiHex, const uint256 &againsHash)
secp256k1_scratch_space2 * GetScratch()
bool IsBlockHashInChain(const uint256 &hashBlock)
uint256 GetTxSignatureHash(const CTransaction &tx)
int ActiveProtocol()
See whether the protocol update is enforced for connected nodes.
bool CheckFinalTx(const CTransaction &tx, int flags=-1)
Check if transaction will be final in the next block to be created.
Closure representing one script verification Note that this stores references to the spending transac...
const int MIN_TX_INPUTS_FOR_SWEEPING
bool IsStandardTx(const CTransaction &tx, std::string &reason)
Check for standard transaction types.
boost::unordered_map< uint256, CBlockIndex *, BlockHasher > BlockMap
An outpoint - a combination of a transaction hash and an index n into its vout.
secp256k1_bulletproof_generators * GetGenerator()
void ThreadScriptCheck()
Run an instance of the script checking thread.
Describes a place in the block chain to another node such that if the other node doesn't have the sam...
uint256 GetTxInSignatureHash(const CTxIn &txin)
The block chain is a tree shaped structure starting with the genesis block at the root,...
@ SCRIPT_ERR_UNKNOWN_ERROR
CCoinsViewCache * pcoinsTip
Global variable that points to the active CCoinsView (protected by cs_main)
bool IsInitialBlockDownload()
Check whether we are doing an initial block download (synchronizing from disk or network)
std::condition_variable g_best_block_cv
Capture information about block/transaction validation.
std::map< COutPoint, COutPoint > mapInvalidOutPoints
bool GetNodeStateStats(NodeId nodeid, CNodeStateStats &stats)
Get statistics from node state.
double ConvertBitsToDouble(unsigned int nBits)
CAmount GetValueIn(CCoinsViewCache view, const CTransaction &tx)
CBlockIndex * FindForkInGlobalIndex(const CChain &chain, const CBlockLocator &locator)
Find the last common block between the parameter chain and a locator.
void SetRingSize(int nHeight)
bool RecalculatePRCYSupply(int nHeightStart)