diff options
Diffstat (limited to 'src/core.h')
-rw-r--r-- | src/core.h | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/core.h b/src/core.h index 9a2ac47487..a024dad740 100644 --- a/src/core.h +++ b/src/core.h @@ -6,6 +6,7 @@ #ifndef BITCOIN_CORE_H #define BITCOIN_CORE_H +#include "amount.h" #include "script/compressor.h" #include "script/script.h" #include "serialize.h" @@ -19,8 +20,8 @@ static const int64_t COIN = 100000000; static const int64_t CENT = 1000000; /** No amount larger than this (in satoshi) is valid */ -static const int64_t MAX_MONEY = 21000000 * COIN; -inline bool MoneyRange(int64_t nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } +static const CAmount MAX_MONEY = 21000000 * COIN; +inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); } /** An outpoint - a combination of a transaction hash and an index n into its vout */ class COutPoint @@ -60,19 +61,6 @@ public: std::string ToString() const; }; -/** An inpoint - a combination of a transaction and an index n into its vin */ -class CInPoint -{ -public: - const CTransaction* ptx; - uint32_t n; - - CInPoint() { SetNull(); } - CInPoint(const CTransaction* ptxIn, uint32_t nIn) { ptx = ptxIn; n = nIn; } - void SetNull() { ptx = NULL; n = (uint32_t) -1; } - bool IsNull() const { return (ptx == NULL && n == (uint32_t) -1); } -}; - /** An input of a transaction. It contains the location of the previous * transaction's output that it claims and a signature that matches the * output's public key. @@ -129,15 +117,15 @@ public: class CFeeRate { private: - int64_t nSatoshisPerK; // unit is satoshis-per-1,000-bytes + CAmount nSatoshisPerK; // unit is satoshis-per-1,000-bytes public: CFeeRate() : nSatoshisPerK(0) { } - explicit CFeeRate(int64_t _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { } - CFeeRate(int64_t nFeePaid, size_t nSize); + explicit CFeeRate(const CAmount& _nSatoshisPerK): nSatoshisPerK(_nSatoshisPerK) { } + CFeeRate(const CAmount& nFeePaid, size_t nSize); CFeeRate(const CFeeRate& other) { nSatoshisPerK = other.nSatoshisPerK; } - int64_t GetFee(size_t size) const; // unit returned is satoshis - int64_t GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes + CAmount GetFee(size_t size) const; // unit returned is satoshis + CAmount GetFeePerK() const { return GetFee(1000); } // satoshis-per-1000-bytes friend bool operator<(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK < b.nSatoshisPerK; } friend bool operator>(const CFeeRate& a, const CFeeRate& b) { return a.nSatoshisPerK > b.nSatoshisPerK; } @@ -161,7 +149,7 @@ public: class CTxOut { public: - int64_t nValue; + CAmount nValue; CScript scriptPubKey; CTxOut() @@ -169,7 +157,7 @@ public: SetNull(); } - CTxOut(int64_t nValueIn, CScript scriptPubKeyIn); + CTxOut(const CAmount& nValueIn, CScript scriptPubKeyIn); ADD_SERIALIZE_METHODS; @@ -276,7 +264,7 @@ public: } // Return sum of txouts. - int64_t GetValueOut() const; + CAmount GetValueOut() const; // GetValueIn() is a method on CCoinsViewCache, because // inputs must be known to compute value in. @@ -528,7 +516,11 @@ public: return block; } - uint256 BuildMerkleTree() const; + // Build the in-memory merkle tree for this block and return the merkle root. + // If non-NULL, *mutated is set to whether mutation was detected in the merkle + // tree (a duplication of transactions in the block leading to an identical + // merkle root). + uint256 BuildMerkleTree(bool* mutated = NULL) const; std::vector<uint256> GetMerkleBranch(int nIndex) const; static uint256 CheckMerkleBranch(uint256 hash, const std::vector<uint256>& vMerkleBranch, int nIndex); |