diff options
author | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-21 13:30:56 -0400 |
---|---|---|
committer | Luke Dashjr <luke-jr+git@utopios.org> | 2012-03-21 13:30:56 -0400 |
commit | cdc6b8d6a6ee4f0bfa721561c340cf8f6b81bc6a (patch) | |
tree | 9599899491f5f6e7d06a85931a5dd85231d25605 /src/main.h | |
parent | 0e6c6e3fd1ab971c652e48fa04bac097e44e76fe (diff) | |
parent | 2f2ac3fece6c7f576c5957f05f342f2830301b54 (diff) | |
download | bitcoin-cdc6b8d6a6ee4f0bfa721561c340cf8f6b81bc6a.tar.xz |
Merge branch 'bip16_0.4.x' into 0.4.x
Diffstat (limited to 'src/main.h')
-rw-r--r-- | src/main.h | 53 |
1 files changed, 50 insertions, 3 deletions
diff --git a/src/main.h b/src/main.h index 278f4f01c0..e6f60a6a8d 100644 --- a/src/main.h +++ b/src/main.h @@ -386,6 +386,7 @@ public: }; +typedef std::map<uint256, std::pair<CTxIndex, CTransaction> > MapPrevTx; // @@ -494,6 +495,15 @@ public: return n; } + /** Count ECDSA signature operations in pay-to-script-hash inputs. + This is a better measure of how expensive it is to process this transaction. + + @param[in] mapInputsMap of previous transactions that have outputs we're spending + @return maximum number of sigops required to validate this transaction's inputs + @see CTransaction::FetchInputs + */ + int GetP2SHSigOpCount(const MapPrevTx& mapInputs) const; + bool IsStandard() const { BOOST_FOREACH(const CTxIn& txin, vin) @@ -517,6 +527,16 @@ public: return nValueOut; } + /** Amount of bitcoins coming in to this transaction + Note that lightweight clients may not know anything besides the hash of previous transactions, + so may not be able to calculate this. + + @param[in] mapInputsMap of previous transactions that have outputs we're spending + @returnSum of value of all inputs (scriptSigs) + @see CTransaction::FetchInputs + */ + int64 GetValueIn(const MapPrevTx& mapInputs) const; + static bool AllowFree(double dPriority) { // Large (in bytes) low-priority (new, small-coin) transactions @@ -631,14 +651,41 @@ public: bool ReadFromDisk(CTxDB& txdb, COutPoint prevout); bool ReadFromDisk(COutPoint prevout); bool DisconnectInputs(CTxDB& txdb); - bool ConnectInputs(CTxDB& txdb, std::map<uint256, CTxIndex>& mapTestPool, CDiskTxPos posThisTx, - CBlockIndex* pindexBlock, int64& nFees, bool fBlock, bool fMiner, int64 nMinFee, - bool& fInvalid); + + /** Fetch from memory and/or disk. inputsRet keys are transaction hashes. + + @param[in] txdb Transaction database + @param[in] mapTestPool List of pending changes to the transaction index database + @param[in] fBlock True if being called to add a new best-block to the chain + @param[in] fMiner True if being called by CreateNewBlock + @param[out] inputsRet Pointers to this transaction's inputs + @param[out] fInvalid returns true if transaction is invalid + @return Returns true if all inputs are in txdb or mapTestPool + */ + bool FetchInputs(CTxDB& txdb, const std::map<uint256, CTxIndex>& mapTestPool, + bool fBlock, bool fMiner, MapPrevTx& inputsRet, bool& fInvalid); + + /** Sanity check previous transactions, then, if all checks succeed, + mark them as spent by this transaction. + + @param[in] inputsPrevious transactions (from FetchInputs) + @param[out] mapTestPoolKeeps track of inputs that need to be updated on disk + @param[in] posThisTxPosition of this transaction on disk + @param[in] pindexBlock + @param[in] fBlock true if called from ConnectBlock + @param[in] fMiner true if called from CreateNewBlock + @param[in] fStrictPayToScriptHash true if fully validating p2sh transactions + @return Returns true if all checks succeed + */ + bool ConnectInputs(MapPrevTx inputs, + std::map<uint256, CTxIndex>& mapTestPool, const CDiskTxPos& posThisTx, + const CBlockIndex* pindexBlock, bool fBlock, bool fMiner, bool fStrictPayToScriptHash=true); bool ClientConnectInputs(); bool CheckTransaction() const; bool AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs=true, bool* pfMissingInputs=NULL); bool AcceptToMemoryPool(bool fCheckInputs=true, bool* pfMissingInputs=NULL); protected: + const CTxOut& GetOutputFor(const CTxIn& input, const MapPrevTx& inputs) const; bool AddToMemoryPoolUnchecked(); public: bool RemoveFromMemoryPool(); |