aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPieter Wuille <pieter@wuille.net>2020-07-22 17:19:43 -0700
committerPieter Wuille <pieter@wuille.net>2020-07-30 13:45:02 -0700
commit900d7f6c075fd78e63503f31d267dbc16b3983d9 (patch)
tree0849a87e896cada9964bee70f0f8be236a391225 /src
parent9efd86a908cf09d9ddbadd3195f202635117d505 (diff)
downloadbitcoin-900d7f6c075fd78e63503f31d267dbc16b3983d9.tar.xz
p2p: enable fetching of orphans from wtxid peers
Based on a commit by Anthony Towns.
Diffstat (limited to 'src')
-rw-r--r--src/net_processing.cpp32
1 files changed, 17 insertions, 15 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 5f8a73cece..36508aa099 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -2647,7 +2647,9 @@ void ProcessMessage(
if (interruptMsgProc)
return;
- // ignore INVs that don't match wtxidrelay setting
+ // Ignore INVs that don't match wtxidrelay setting.
+ // Note that orphan parent fetching always uses MSG_TX GETDATAs regardless of the wtxidrelay setting.
+ // This is fine as no INV messages are involved in that process.
if (State(pfrom.GetId())->m_wtxid_relay) {
if (inv.IsMsgTx()) continue;
} else {
@@ -2931,9 +2933,11 @@ void ProcessMessage(
TxValidationState state;
- nodestate->m_tx_download.m_tx_announced.erase(hash);
- nodestate->m_tx_download.m_tx_in_flight.erase(hash);
- EraseTxRequest(hash);
+ for (uint256 hash : {txid, wtxid}) {
+ nodestate->m_tx_download.m_tx_announced.erase(hash);
+ nodestate->m_tx_download.m_tx_in_flight.erase(hash);
+ EraseTxRequest(hash);
+ }
std::list<CTransactionRef> lRemovedTxn;
@@ -2985,17 +2989,15 @@ void ProcessMessage(
uint32_t nFetchFlags = GetFetchFlags(pfrom);
const auto current_time = GetTime<std::chrono::microseconds>();
- if (!State(pfrom.GetId())->m_wtxid_relay) {
- for (const CTxIn& txin : tx.vin) {
- // Here, we only have the txid (and not wtxid) of the
- // inputs, so we only request parents from
- // non-wtxid-relay peers.
- // Eventually we should replace this with an improved
- // protocol for getting all unconfirmed parents.
- CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash);
- pfrom.AddKnownTx(txin.prevout.hash);
- if (!AlreadyHave(_inv, mempool)) RequestTx(State(pfrom.GetId()), ToGenTxid(_inv), current_time);
- }
+ for (const CTxIn& txin : tx.vin) {
+ // Here, we only have the txid (and not wtxid) of the
+ // inputs, so we only request in txid mode, even for
+ // wtxidrelay peers.
+ // Eventually we should replace this with an improved
+ // protocol for getting all unconfirmed parents.
+ CInv _inv(MSG_TX | nFetchFlags, txin.prevout.hash);
+ pfrom.AddKnownTx(txin.prevout.hash);
+ if (!AlreadyHave(_inv, mempool)) RequestTx(State(pfrom.GetId()), ToGenTxid(_inv), current_time);
}
AddOrphanTx(ptx, pfrom.GetId());