Replace calls to GetHash() with GetTxid() for transaction objects.

Where the caller intends to receive a transaction id and not a double
SHA256 hash.
This commit is contained in:
Simon
2016-07-25 12:23:37 -07:00
parent 1e84d84d3a
commit 10d2c57c0d
32 changed files with 134 additions and 134 deletions

View File

@@ -553,7 +553,7 @@ CBlockTreeDB *pblocktree = NULL;
bool AddOrphanTx(const CTransaction& tx, NodeId peer)
{
uint256 hash = tx.GetHash();
uint256 hash = tx.GetTxid();
if (mapOrphanTransactions.count(hash))
return false;
@@ -607,7 +607,7 @@ void EraseOrphansFor(NodeId peer)
map<uint256, COrphanTx>::iterator maybeErase = iter++; // increment to avoid iterator becoming invalid
if (maybeErase->second.fromPeer == peer)
{
EraseOrphanTx(maybeErase->second.tx.GetHash());
EraseOrphanTx(maybeErase->second.tx.GetTxid());
++nErased;
}
}
@@ -1033,7 +1033,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
{
{
LOCK(mempool.cs);
uint256 hash = tx.GetHash();
uint256 hash = tx.GetTxid();
double dPriorityDelta = 0;
CAmount nFeeDelta = 0;
mempool.ApplyDeltas(hash, dPriorityDelta, nFeeDelta);
@@ -1088,7 +1088,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
return state.DoS(0, false, REJECT_NONSTANDARD, "non-final");
// is it already in the memory pool?
uint256 hash = tx.GetHash();
uint256 hash = tx.GetTxid();
if (pool.exists(hash))
return false;
@@ -1280,7 +1280,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
return error("%s: Deserialize or I/O error - %s", __func__, e.what());
}
hashBlock = header.GetHash();
if (txOut.GetHash() != hash)
if (txOut.GetTxid() != hash)
return error("%s: txid mismatch", __func__);
return true;
}
@@ -1302,7 +1302,7 @@ bool GetTransaction(const uint256 &hash, CTransaction &txOut, uint256 &hashBlock
CBlock block;
if (ReadBlockFromDisk(block, pindexSlow)) {
BOOST_FOREACH(const CTransaction &tx, block.vtx) {
if (tx.GetHash() == hash) {
if (tx.GetTxid() == hash) {
txOut = tx;
hashBlock = pindexSlow->GetBlockHash();
return true;
@@ -1593,7 +1593,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
}
// add outputs
inputs.ModifyCoins(tx.GetHash())->FromTx(tx, nHeight);
inputs.ModifyCoins(tx.GetTxid())->FromTx(tx, nHeight);
}
void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCache &inputs, int nHeight)
@@ -1605,7 +1605,7 @@ void UpdateCoins(const CTransaction& tx, CValidationState &state, CCoinsViewCach
bool CScriptCheck::operator()() {
const CScript &scriptSig = ptxTo->vin[nIn].scriptSig;
if (!VerifyScript(scriptSig, scriptPubKey, nFlags, CachingTransactionSignatureChecker(ptxTo, nIn, cacheStore), &error)) {
return ::error("CScriptCheck(): %s:%d VerifySignature failed: %s", ptxTo->GetHash().ToString(), nIn, ScriptErrorString(error));
return ::error("CScriptCheck(): %s:%d VerifySignature failed: %s", ptxTo->GetTxid().ToString(), nIn, ScriptErrorString(error));
}
return true;
}
@@ -1620,11 +1620,11 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c
// This doesn't trigger the DoS code on purpose; if it did, it would make it easier
// for an attacker to attempt to split the network.
if (!inputs.HaveInputs(tx))
return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetHash().ToString()));
return state.Invalid(error("CheckInputs(): %s inputs unavailable", tx.GetTxid().ToString()));
// are the JoinSplit's requirements met?
if (!inputs.HaveJoinSplitRequirements(tx))
return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetHash().ToString()));
return state.Invalid(error("CheckInputs(): %s JoinSplit requirements not met", tx.GetTxid().ToString()));
CAmount nValueIn = 0;
CAmount nFees = 0;
@@ -1661,13 +1661,13 @@ bool NonContextualCheckInputs(const CTransaction& tx, CValidationState &state, c
if (nValueIn < tx.GetValueOut())
return state.DoS(100, error("CheckInputs(): %s value in (%s) < value out (%s)",
tx.GetHash().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())),
tx.GetTxid().ToString(), FormatMoney(nValueIn), FormatMoney(tx.GetValueOut())),
REJECT_INVALID, "bad-txns-in-belowout");
// Tally transaction fees
CAmount nTxFee = nValueIn - tx.GetValueOut();
if (nTxFee < 0)
return state.DoS(100, error("CheckInputs(): %s nTxFee < 0", tx.GetHash().ToString()),
return state.DoS(100, error("CheckInputs(): %s nTxFee < 0", tx.GetTxid().ToString()),
REJECT_INVALID, "bad-txns-fee-negative");
nFees += nTxFee;
if (!MoneyRange(nFees))
@@ -1886,7 +1886,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
// undo transactions in reverse order
for (int i = block.vtx.size() - 1; i >= 0; i--) {
const CTransaction &tx = block.vtx[i];
uint256 hash = tx.GetHash();
uint256 hash = tx.GetTxid();
// Check that all outputs are available and match the outputs in the block itself
// exactly.
@@ -2067,7 +2067,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// Do not allow blocks that contain transactions which 'overwrite' older transactions,
// unless those are already completely spent.
BOOST_FOREACH(const CTransaction& tx, block.vtx) {
const CCoins* coins = view.AccessCoins(tx.GetHash());
const CCoins* coins = view.AccessCoins(tx.GetTxid());
if (coins && !coins->IsPruned())
return state.DoS(100, error("ConnectBlock(): tried to overwrite transaction"),
REJECT_INVALID, "bad-txns-BIP30");
@@ -2165,7 +2165,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
}
}
vPos.push_back(std::make_pair(tx.GetHash(), pos));
vPos.push_back(std::make_pair(tx.GetTxid(), pos));
pos.nTxOffset += ::GetSerializeSize(tx, SER_DISK, CLIENT_VERSION);
}
@@ -2222,7 +2222,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// Watch for changes to the previous coinbase transaction.
static uint256 hashPrevBestCoinBase;
GetMainSignals().UpdatedTransaction(hashPrevBestCoinBase);
hashPrevBestCoinBase = block.vtx[0].GetHash();
hashPrevBestCoinBase = block.vtx[0].GetTxid();
int64_t nTime4 = GetTimeMicros(); nTimeCallbacks += nTime4 - nTime3;
LogPrint("bench", " - Callbacks: %.2fms [%.2fs]\n", 0.001 * (nTime4 - nTime3), nTimeCallbacks * 0.000001);
@@ -4654,7 +4654,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
CTransaction tx;
vRecv >> tx;
CInv inv(MSG_TX, tx.GetHash());
CInv inv(MSG_TX, tx.GetTxid());
pfrom->AddInventoryKnown(inv);
LOCK(cs_main);
@@ -4676,7 +4676,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
LogPrint("mempool", "AcceptToMemoryPool: peer=%d %s: accepted %s (poolsz %u)\n",
pfrom->id, pfrom->cleanSubVer,
tx.GetHash().ToString(),
tx.GetTxid().ToString(),
mempool.mapTx.size());
// Recursively process any orphan transactions that depended on this one
@@ -4745,7 +4745,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
LogPrint("mempool", "mapOrphan overflow, removed %u tx\n", nEvicted);
} else {
assert(recentRejects);
recentRejects->insert(tx.GetHash());
recentRejects->insert(tx.GetTxid());
if (pfrom->fWhitelisted) {
// Always relay transactions received from whitelisted peers, even
@@ -4761,7 +4761,7 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
int nDoS = 0;
if (state.IsInvalid(nDoS))
{
LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetHash().ToString(),
LogPrint("mempool", "%s from peer=%d %s was not accepted into the memory pool: %s\n", tx.GetTxid().ToString(),
pfrom->id, pfrom->cleanSubVer,
state.GetRejectReason());
pfrom->PushMessage("reject", strCommand, state.GetRejectCode(),