Feathercoin  0.5.0
P2P Digital Currency
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Classes | Enumerations | Functions | Variables
main.h File Reference
#include "bignum.h"
#include "sync.h"
#include "net.h"
#include "script.h"
#include "scrypt.h"
#include <list>
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  CDiskBlockPos
 
struct  CDiskTxPos
 
class  CInPoint
 An inpoint - a combination of a transaction and an index n into its vin. More...
 
class  COutPoint
 An outpoint - a combination of a transaction hash and an index n into its vout. More...
 
class  CTxIn
 An input of a transaction. More...
 
class  CTxOut
 An output of a transaction. More...
 
class  CTransaction
 The basic transaction that is broadcasted on the network and contained in blocks. More...
 
class  CTxOutCompressor
 wrapper for CTxOut that provides a more compact serialization More...
 
class  CTxInUndo
 Undo information for a CTxIn. More...
 
class  CTxUndo
 Undo information for a CTransaction. More...
 
class  CBlockUndo
 Undo information for a CBlock. More...
 
class  CCoins
 pruned version of CTransaction: only retains metadata and unspent transaction outputs 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  CBlockHeader
 Nodes collect new transactions into a block, hash them into a hash tree, and scan through nonce values to make the block's hash satisfy proof-of-work requirements. More...
 
class  CBlock
 
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...
 
struct  CBlockIndexWorkComparator
 
class  CDiskBlockIndex
 Used to marshal pointers into hashes for db storage. More...
 
class  CValidationState
 Capture information about block/transaction validation. More...
 
class  CBlockLocator
 Describes a place in the block chain to another node such that if the other node doesn't have the same branch, it can find a recent common trunk. More...
 
class  CTxMemPool
 
struct  CCoinsStats
 
class  CCoinsView
 Abstract view on the open txout dataset. More...
 
class  CCoinsViewBacked
 CCoinsView backed by another CCoinsView. More...
 
class  CCoinsViewCache
 CCoinsView that adds a memory cache for transactions to another CCoinsView. More...
 
class  CCoinsViewMemPool
 CCoinsView that brings transactions from a memorypool into view. More...
 
struct  CBlockTemplate
 
class  CMerkleBlock
 Used to relay blocks as header + vector<merkle branch> to filtered nodes. More...
 

Enumerations

enum  GetMinFee_mode { GMF_BLOCK, 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

bool MoneyRange (int64 nValue)
 
void RegisterWallet (CWallet *pwalletIn)
 Register a wallet to receive updates from core. More...
 
void UnregisterWallet (CWallet *pwalletIn)
 Unregister a wallet from core. More...
 
void SyncWithWallets (const uint256 &hash, const CTransaction &tx, const CBlock *pblock=NULL, bool fUpdate=false)
 Push an updated transaction to all registered wallets. More...
 
bool ProcessBlock (CValidationState &state, CNode *pfrom, CBlock *pblock, CDiskBlockPos *dbp=NULL)
 Process an incoming block. More...
 
bool CheckDiskSpace (uint64 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...
 
CBlockIndexFindBlockByHeight (int nHeight)
 Find a block by height in the currently-connected chain. 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...
 
void GenerateBitcoins (bool fGenerate, CWallet *pwallet)
 Run the miner threads. More...
 
CBlockTemplateCreateNewBlock (const CScript &scriptPubKeyIn)
 Generate a new block, without valid proof-of-work. More...
 
CBlockTemplateCreateNewBlockWithKey (CReserveKey &reservekey)
 
void IncrementExtraNonce (CBlock *pblock, CBlockIndex *pindexPrev, unsigned int &nExtraNonce)
 Modify the extranonce in a block. More...
 
void FormatHashBuffers (CBlock *pblock, char *pmidstate, char *pdata, char *phash1)
 Do mining precalculation. More...
 
bool CheckWork (CBlock *pblock, CWallet &wallet, CReserveKey &reservekey)
 Check mined block. 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 nTime)
 Calculate the minimum amount of work a received block needs, without knowing its direct parent. More...
 
int GetNumBlocksOfPeers ()
 Get the number of active peers. 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 SetBestChain (CValidationState &state, CBlockIndex *pindexNew)
 Connect/disconnect blocks until pindexNew is the new tip of the active block chain. More...
 
bool ConnectBestBlock (CValidationState &state)
 Find the best known block, and make it the tip of the block chain. More...
 
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 GetWalletFile (CWallet *pwallet, std::string &strWalletFileOut)
 

Variables

CScript COINBASE_FLAGS
 
CCriticalSection cs_main
 
std::map< uint256, CBlockIndex * > mapBlockIndex
 
std::set< CBlockIndex
*, CBlockIndexWorkComparator
setBlockIndexValid
 
uint256 hashGenesisBlock
 
CBlockIndexpindexGenesisBlock
 
int nBestHeight
 
uint256 nBestChainWork
 
uint256 nBestInvalidWork
 
uint256 hashBestChain
 
CBlockIndexpindexBest
 
unsigned int nTransactionsUpdated
 
uint64 nLastBlockTx
 
uint64 nLastBlockSize
 
const std::string strMessageMagic
 
double dHashesPerSec
 
int64 nHPSTimerStart
 
int64 nTimeBestReceived
 
CCriticalSection cs_setpwalletRegistered
 
std::set< CWallet * > setpwalletRegistered
 
std::map< uint256, CBlock * > mapOrphanBlocks
 
unsigned char pchMessageStart [4]
 
bool fImporting
 
bool fReindex
 
bool fBenchmark
 
int nScriptCheckThreads
 
bool fTxIndex
 
unsigned int nCoinCacheSize
 
int64 nTransactionFee
 
int64 nMinimumInputValue
 
CCriticalSection cs_LastBlockFile
 
CBlockFileInfo infoLastBlockFile
 
int nLastBlockFile
 
CTxMemPool mempool
 
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 1601 of file main.h.

Enumerator
GMF_BLOCK 
GMF_RELAY 
GMF_SEND 

Definition at line 467 of file main.h.

Function Documentation

bool AbortNode ( const std::string &  msg)

Abort with a message.

Definition at line 2583 of file main.cpp.

bool CheckDiskSpace ( uint64  nAdditionalBytes = 0)

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

Definition at line 2591 of file main.cpp.

bool CheckProofOfWork ( uint256  hash,
unsigned int  nBits 
)

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

Definition at line 1254 of file main.cpp.

bool CheckWork ( CBlock pblock,
CWallet wallet,
CReserveKey reservekey 
)

Check mined block.

Definition at line 4632 of file main.cpp.

unsigned int ComputeMinWork ( unsigned int  nBase,
int64  nTime 
)

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

bool ConnectBestBlock ( CValidationState state)

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

Definition at line 1321 of file main.cpp.

CBlockTemplate* CreateNewBlock ( const CScript scriptPubKeyIn)

Generate a new block, without valid proof-of-work.

Definition at line 4319 of file main.cpp.

CBlockTemplate* CreateNewBlockWithKey ( CReserveKey reservekey)

Definition at line 4558 of file main.cpp.

CBlockIndex* FindBlockByHeight ( int  nHeight)

Find a block by height in the currently-connected chain.

Definition at line 1041 of file main.cpp.

void FormatHashBuffers ( CBlock pblock,
char *  pmidstate,
char *  pdata,
char *  phash1 
)

Do mining precalculation.

Definition at line 4586 of file main.cpp.

void GenerateBitcoins ( bool  fGenerate,
CWallet pwallet 
)

Run the miner threads.

Definition at line 4800 of file main.cpp.

int GetNumBlocksOfPeers ( )

Get the number of active peers.

Definition at line 1271 of file main.cpp.

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

bool GetWalletFile ( CWallet pwallet,
std::string &  strWalletFileOut 
)
std::string GetWarnings ( std::string  strFor)

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

void IncrementExtraNonce ( CBlock pblock,
CBlockIndex pindexPrev,
unsigned int &  nExtraNonce 
)

Modify the extranonce in a block.

Definition at line 4568 of file main.cpp.

bool InitBlockIndex ( )

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

Definition at line 2836 of file main.cpp.

CBlockIndex* InsertBlockIndex ( uint256  hash)

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

Definition at line 2637 of file main.cpp.

bool IsInitialBlockDownload ( )

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

Definition at line 1276 of file main.cpp.

bool LoadBlockIndex ( )

Load the block tree and coins database from disk.

Definition at line 2815 of file main.cpp.

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

Import blocks from an external file.

Definition at line 2986 of file main.cpp.

bool MoneyRange ( int64  nValue)
inline

Definition at line 58 of file main.h.

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

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

Definition at line 2629 of file main.cpp.

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

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

Definition at line 2633 of file main.cpp.

void PrintBlockTree ( )

Print the loaded block tree.

Definition at line 2916 of file main.cpp.

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

Process an incoming block.

Definition at line 2339 of file main.cpp.

bool ProcessMessages ( CNode pfrom)

Process protocol messages received from a given node.

Definition at line 3921 of file main.cpp.

void RegisterWallet ( CWallet pwalletIn)

Register a wallet to receive updates from core.

Definition at line 96 of file main.cpp.

bool SendMessages ( CNode pto,
bool  fSendTrickle 
)

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

Definition at line 4044 of file main.cpp.

bool SetBestChain ( CValidationState state,
CBlockIndex pindexNew 
)

Connect/disconnect blocks until pindexNew is the new tip of the active block chain.

Definition at line 1832 of file main.cpp.

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

Push an updated transaction to all registered wallets.

Definition at line 129 of file main.cpp.

void ThreadScriptCheck ( )

Run an instance of the script checking thread.

Definition at line 1672 of file main.cpp.

void UnloadBlockIndex ( )

Unload database information.

Definition at line 2803 of file main.cpp.

void UnregisterWallet ( CWallet pwalletIn)

Unregister a wallet from core.

Definition at line 104 of file main.cpp.

bool VerifyDB ( int  nCheckLevel,
int  nCheckDepth 
)

Verify consistency of the block and coin databases.

Definition at line 2730 of file main.cpp.

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

Verify a signature.

Definition at line 1470 of file main.cpp.

Variable Documentation

CScript COINBASE_FLAGS

Definition at line 76 of file main.cpp.

CCriticalSection cs_LastBlockFile

Definition at line 2602 of file main.cpp.

Definition at line 32 of file main.cpp.

CCriticalSection cs_setpwalletRegistered

Definition at line 29 of file main.cpp.

double dHashesPerSec

Definition at line 80 of file main.cpp.

bool fBenchmark

Definition at line 51 of file main.cpp.

bool fImporting

Definition at line 49 of file main.cpp.

bool fReindex

Definition at line 50 of file main.cpp.

bool fTxIndex

Definition at line 52 of file main.cpp.

uint256 hashBestChain

Definition at line 44 of file main.cpp.

uint256 hashGenesisBlock
CBlockFileInfo infoLastBlockFile

Definition at line 2603 of file main.cpp.

std::map<uint256, CBlockIndex*> mapBlockIndex

Definition at line 37 of file main.cpp.

std::map<uint256, CBlock*> mapOrphanBlocks

Definition at line 69 of file main.cpp.

CTxMemPool mempool

Definition at line 34 of file main.cpp.

uint256 nBestChainWork

Definition at line 42 of file main.cpp.

int nBestHeight

Definition at line 41 of file main.cpp.

uint256 nBestInvalidWork

Definition at line 43 of file main.cpp.

unsigned int nCoinCacheSize

Definition at line 53 of file main.cpp.

int64 nHPSTimerStart

Definition at line 81 of file main.cpp.

int nLastBlockFile

Definition at line 2604 of file main.cpp.

uint64 nLastBlockSize

Definition at line 4293 of file main.cpp.

uint64 nLastBlockTx

Definition at line 4292 of file main.cpp.

int64 nMinimumInputValue

Definition at line 85 of file main.cpp.

int nScriptCheckThreads

Definition at line 48 of file main.cpp.

int64 nTimeBestReceived

Definition at line 47 of file main.cpp.

int64 nTransactionFee

Definition at line 84 of file main.cpp.

unsigned int nTransactionsUpdated

Definition at line 35 of file main.cpp.

CBlockTreeDB* pblocktree

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

Definition at line 290 of file main.cpp.

unsigned char pchMessageStart[4]

Definition at line 3178 of file main.cpp.

CCoinsViewCache* pcoinsTip

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

Definition at line 289 of file main.cpp.

CBlockIndex* pindexBest

Definition at line 45 of file main.cpp.

CBlockIndex* pindexGenesisBlock

Definition at line 40 of file main.cpp.

std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid

Definition at line 46 of file main.cpp.

std::set<CWallet*> setpwalletRegistered

Definition at line 30 of file main.cpp.

const std::string strMessageMagic

Definition at line 78 of file main.cpp.