Simplify counting of P2SH sigops to match BIP 16 (thanks to Matt Corallo for prompting this).

This also removes an un-needed sigops-per-byte check when accepting transactions to the memory pool (un-needed assuming only standard transactions are being accepted). And it only counts P2SH sigops after the switchover date.
This commit is contained in:
Gavin Andresen
2012-01-20 17:07:40 -05:00
parent 1240a1b0a8
commit 137d0685a4
4 changed files with 53 additions and 52 deletions

View File

@@ -528,14 +528,13 @@ public:
*/
int GetLegacySigOpCount() const;
/** Count ECDSA signature operations the new (0.6-and-later) way
This is a better measure of how expensive it is to process this transaction.
/** Count ECDSA signature operations in pay-to-script-hash inputs.
@param[in] mapInputs Map 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 GetSigOpCount(const MapPrevTx& mapInputs) const;
int GetP2SHSigOpCount(const MapPrevTx& mapInputs) const;
/** Amount of bitcoins spent by this transaction.
@return sum of all outputs (note: does not include fees)
@@ -698,11 +697,12 @@ public:
@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);
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);