use fee/sigop data in BlockTemplate struct instead of (not always correctly) calculating it ourselves

This commit is contained in:
Forrest Voight 2012-12-19 15:44:25 -05:00
parent 03cac0bb8e
commit 0f927ceb5b

View File

@ -283,7 +283,6 @@ Value getblocktemplate(const Array& params, bool fHelp)
Array transactions; Array transactions;
map<uint256, int64_t> setTxIndex; map<uint256, int64_t> setTxIndex;
int i = 0; int i = 0;
CCoinsViewCache &view = *pcoinsTip;
BOOST_FOREACH (CTransaction& tx, pblock->vtx) BOOST_FOREACH (CTransaction& tx, pblock->vtx)
{ {
uint256 txHash = tx.GetHash(); uint256 txHash = tx.GetHash();
@ -308,13 +307,8 @@ Value getblocktemplate(const Array& params, bool fHelp)
} }
entry.push_back(Pair("depends", deps)); entry.push_back(Pair("depends", deps));
int64_t nSigOps = tx.GetLegacySigOpCount(); entry.push_back(Pair("fee", pblocktemplate->vTxFees[&tx - pblock->vtx.data()]));
if (tx.HaveInputs(view)) entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[&tx - pblock->vtx.data()]));
{
entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(view) - tx.GetValueOut())));
nSigOps += tx.GetP2SHSigOpCount(view);
}
entry.push_back(Pair("sigops", nSigOps));
transactions.push_back(entry); transactions.push_back(entry);
} }