diff options
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 39 |
1 files changed, 20 insertions, 19 deletions
diff --git a/src/main.h b/src/main.h index 24b2cb2aa6..679ae75a47 100644 --- a/src/main.h +++ b/src/main.h @@ -44,10 +44,6 @@ static const unsigned int BLOCKFILE_CHUNK_SIZE = 0x1000000; // 16 MiB static const unsigned int UNDOFILE_CHUNK_SIZE = 0x100000; // 1 MiB /** Fake height value used in CCoins to signify they are only in the memory pool (since 0.8) */ static const unsigned int MEMPOOL_HEIGHT = 0x7FFFFFFF; -/** Fees smaller than this (in satoshi) are considered zero fee (for transaction creation) */ -static const int64 MIN_TX_FEE = 10000; -/** Fees smaller than this (in satoshi) are considered zero fee (for relaying) */ -static const int64 MIN_RELAY_TX_FEE = 10000; /** No amount larger than this (in satoshi) is valid */ static const int64 MAX_MONEY = 21000000 * COIN; inline bool MoneyRange(int64 nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } @@ -73,6 +69,7 @@ extern CScript COINBASE_FLAGS; extern CCriticalSection cs_main; extern std::map<uint256, CBlockIndex*> mapBlockIndex; +extern std::vector<CBlockIndex*> vBlockIndexByHeight; extern std::set<CBlockIndex*, CBlockIndexWorkComparator> setBlockIndexValid; extern uint256 hashGenesisBlock; extern CBlockIndex* pindexGenesisBlock; @@ -439,6 +436,8 @@ public: return !(a == b); } + bool IsDust() const; + std::string ToString() const { if (scriptPubKey.size() < 6) @@ -467,6 +466,8 @@ enum GetMinFee_mode class CTransaction { public: + static int64 nMinTxFee; + static int64 nMinRelayTxFee; static const int CURRENT_VERSION=1; int nVersion; std::vector<CTxIn> vin; @@ -659,7 +660,7 @@ public: std::vector<CScriptCheck> *pvChecks = NULL) const; // Apply the effects of this transaction on the UTXO set represented by view - bool UpdateCoins(CValidationState &state, CCoinsViewCache &view, CTxUndo &txundo, int nHeight, const uint256 &txhash) const; + void UpdateCoins(CValidationState &state, CCoinsViewCache &view, CTxUndo &txundo, int nHeight, const uint256 &txhash) const; // Context-independent validity checks bool CheckTransaction(CValidationState &state) const; @@ -1589,10 +1590,8 @@ enum BlockStatus { /** 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. pprev and pnext link a path through the - * main/longest chain. A blockindex may have multiple pprev pointing back - * to it, but pnext will only point forward to the longest branch, or will - * be null if the block is not part of the longest chain. + * candidates to be the next block. A blockindex may have multiple pprev pointing + * to it, but at most one of them can be part of the currently active branch. */ class CBlockIndex { @@ -1603,9 +1602,6 @@ public: // pointer to the index of the predecessor of this block CBlockIndex* pprev; - // (memory only) pointer to the index of the *active* successor of this block - CBlockIndex* pnext; - // height of the entry in the chain. The genesis block has height 0 int nHeight; @@ -1643,7 +1639,6 @@ public: { phashBlock = NULL; pprev = NULL; - pnext = NULL; nHeight = 0; nFile = 0; nDataPos = 0; @@ -1664,7 +1659,6 @@ public: { phashBlock = NULL; pprev = NULL; - pnext = NULL; nHeight = 0; nFile = 0; nDataPos = 0; @@ -1733,7 +1727,11 @@ public: bool IsInMainChain() const { - return (pnext || this == pindexBest); + return nHeight < (int)vBlockIndexByHeight.size() && vBlockIndexByHeight[nHeight] == this; + } + + CBlockIndex *GetNextInMainChain() const { + return nHeight+1 >= (int)vBlockIndexByHeight.size() ? NULL : vBlockIndexByHeight[nHeight+1]; } bool CheckIndex() const @@ -1762,9 +1760,9 @@ public: const CBlockIndex* pindex = this; for (int i = 0; i < nMedianTimeSpan/2; i++) { - if (!pindex->pnext) + if (!pindex->GetNextInMainChain()) return GetBlockTime(); - pindex = pindex->pnext; + pindex = pindex->GetNextInMainChain(); } return pindex->GetMedianTimePast(); } @@ -1779,7 +1777,7 @@ public: std::string ToString() const { return strprintf("CBlockIndex(pprev=%p, pnext=%p, nHeight=%d, merkle=%s, hashBlock=%s)", - pprev, pnext, nHeight, + pprev, GetNextInMainChain(), nHeight, hashMerkleRoot.ToString().c_str(), GetBlockHash().ToString().c_str()); } @@ -2096,11 +2094,14 @@ extern CTxMemPool mempool; struct CCoinsStats { int nHeight; + uint256 hashBlock; uint64 nTransactions; uint64 nTransactionOutputs; uint64 nSerializedSize; + uint256 hashSerialized; + int64 nTotalAmount; - CCoinsStats() : nHeight(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0) {} + CCoinsStats() : nHeight(0), hashBlock(0), nTransactions(0), nTransactionOutputs(0), nSerializedSize(0), hashSerialized(0), nTotalAmount(0) {} }; /** Abstract view on the open txout dataset. */ |