Skip to content
Browse files

use fee/sigop data in BlockTemplate struct instead of (not always cor…

…rectly) calculating it ourselves
  • Loading branch information...
1 parent 03cac0b commit 0f927ceb5b90ec02be36ddb20b2f4cff82589265 @forrestv committed Dec 19, 2012
Showing with 2 additions and 8 deletions.
  1. +2 −8 src/rpcmining.cpp
View
10 src/rpcmining.cpp
@@ -283,7 +283,6 @@ Value getblocktemplate(const Array& params, bool fHelp)
Array transactions;
map<uint256, int64_t> setTxIndex;
int i = 0;
- CCoinsViewCache &view = *pcoinsTip;
BOOST_FOREACH (CTransaction& tx, pblock->vtx)
{
uint256 txHash = tx.GetHash();
@@ -308,13 +307,8 @@ Value getblocktemplate(const Array& params, bool fHelp)
}
entry.push_back(Pair("depends", deps));
- int64_t nSigOps = tx.GetLegacySigOpCount();
- if (tx.HaveInputs(view))
- {
- entry.push_back(Pair("fee", (int64_t)(tx.GetValueIn(view) - tx.GetValueOut())));
- nSigOps += tx.GetP2SHSigOpCount(view);
- }
- entry.push_back(Pair("sigops", nSigOps));
+ entry.push_back(Pair("fee", pblocktemplate->vTxFees[&tx - pblock->vtx.data()]));
+ entry.push_back(Pair("sigops", pblocktemplate->vTxSigOps[&tx - pblock->vtx.data()]));
@jgarzik
jgarzik added a note Jan 4, 2013

No objection (see 'ACK' in overall commit), but this construction "&tx - pblock->vtx.data()" seems quite unusual. Perhaps separate it into its own code line, perhaps with a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
transactions.push_back(entry);
}

0 comments on commit 0f927ce

Please sign in to comment.
Something went wrong with that request. Please try again.