aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2020-08-08 14:36:26 +0200
committerJon Atack <jon@atack.com>2020-08-26 11:57:23 +0200
commit24ee4f01eadb870435712950a1364cf0def06e9f (patch)
tree6eb4d248c7a872b52b11d5fc0a82edd7043b1905 /src/net_processing.cpp
parentb1c855453bf2634e7fd9b53c4a76a8536fc9865d (diff)
downloadbitcoin-24ee4f01eadb870435712950a1364cf0def06e9f.tar.xz
p2p: make gtxid(.hash) and fAlreadyHave localvars const
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp21
1 files changed, 11 insertions, 10 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 290853e0a6..b9f0e1f98e 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -1434,21 +1434,23 @@ bool static AlreadyHaveTx(const GenTxid& gtxid, const CTxMemPool& mempool) EXCLU
recentRejects->reset();
}
+ const uint256& hash = gtxid.GetHash();
+
{
LOCK(g_cs_orphans);
- if (!gtxid.IsWtxid() && mapOrphanTransactions.count(gtxid.GetHash())) {
+ if (!gtxid.IsWtxid() && mapOrphanTransactions.count(hash)) {
return true;
- } else if (gtxid.IsWtxid() && g_orphans_by_wtxid.count(gtxid.GetHash())) {
+ } else if (gtxid.IsWtxid() && g_orphans_by_wtxid.count(hash)) {
return true;
}
}
{
LOCK(g_cs_recent_confirmed_transactions);
- if (g_recent_confirmed_transactions->contains(gtxid.GetHash())) return true;
+ if (g_recent_confirmed_transactions->contains(hash)) return true;
}
- return recentRejects->contains(gtxid.GetHash()) || mempool.exists(gtxid);
+ return recentRejects->contains(hash) || mempool.exists(gtxid);
}
bool static AlreadyHaveBlock(const uint256& block_hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main)
@@ -2645,8 +2647,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
const auto current_time = GetTime<std::chrono::microseconds>();
uint256* best_block{nullptr};
- for (CInv &inv : vInv)
- {
+ for (CInv& inv : vInv) {
if (interruptMsgProc) return;
// Ignore INVs that don't match wtxidrelay setting.
@@ -2659,7 +2660,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
}
if (inv.IsMsgBlk()) {
- bool fAlreadyHave = AlreadyHaveBlock(inv.hash);
+ const bool fAlreadyHave = AlreadyHaveBlock(inv.hash);
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
UpdateBlockAvailability(pfrom.GetId(), inv.hash);
@@ -2672,8 +2673,8 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
best_block = &inv.hash;
}
} else {
- GenTxid gtxid = ToGenTxid(inv);
- bool fAlreadyHave = AlreadyHaveTx(gtxid, mempool);
+ const GenTxid gtxid = ToGenTxid(inv);
+ const bool fAlreadyHave = AlreadyHaveTx(gtxid, mempool);
LogPrint(BCLog::NET, "got inv: %s %s peer=%d\n", inv.ToString(), fAlreadyHave ? "have" : "new", pfrom.GetId());
pfrom.AddKnownTx(inv.hash);
@@ -3007,7 +3008,7 @@ void PeerLogicValidation::ProcessMessage(CNode& pfrom, const std::string& msg_ty
// wtxidrelay peers.
// Eventually we should replace this with an improved
// protocol for getting all unconfirmed parents.
- GenTxid gtxid{/* is_wtxid=*/false, parent_txid};
+ const GenTxid gtxid{/* is_wtxid=*/false, parent_txid};
pfrom.AddKnownTx(parent_txid);
if (!AlreadyHaveTx(gtxid, m_mempool)) RequestTx(State(pfrom.GetId()), gtxid, current_time);
}