Use RPC to get txs instead of P2P
MODIFY
WalletWasabi/BitcoinCore/Mempool/MempoolMirror.cs
WalletWasabi/BitcoinCore/Mempool/MempoolMirror.cs
@@ -115,7 +115,7 @@ namespace WalletWasabi.BitcoinCore.Mempool
}
}
- var added = AddTransactions(Node.GetMempoolTransactions(missing, cancel));
+ var added = AddTransactions(await Rpc.GetRawTransactionsAsync(missing, cancel).ConfigureAwait(false));
return added;
}

MODIFY
WalletWasabi/BitcoinCore/P2pNode.cs
WalletWasabi/BitcoinCore/P2pNode.cs
@@ -88,35 +88,6 @@ namespace WalletWasabi.BitcoinCore
}
}
- public IEnumerable<Transaction> GetMempoolTransactions(IEnumerable<uint256> txids, CancellationToken cancel)
- {
- var node = Guard.NotNull(nameof(Node), Node);
- var p2pBehavior = Guard.NotNull(nameof(TrustedP2pBehavior), TrustedP2pBehavior);
-
- try
- {
- // Skip processing if txid is disabled.
- // This feature is necessary because NBitcoin's Node.GetMempoolTransactions doesn't return anything
- // if we're processing the arriving txs.
- p2pBehavior.DisableProcess(txids);
-
- // Chunk it because it doesn't work properly for more.
- foreach (var chunk in txids.Distinct().ChunkBy(100))
- {
- var txs = node.GetMempoolTransactions(chunk.ToArray(), cancel);
- foreach (var tx in txs)
- {
- tx.PrecomputeHash(invalidateExisting: false, lazily: true);
- yield return tx;
- }
- }
- }
- finally
- {
- p2pBehavior.EnableProcess(txids);
- }
- }
-
private void Node_UncaughtException(Node sender, Exception ex)
{
Logger.LogInfo($"Node {sender.Peer.Endpoint} failed with exception: {ex}");

MODIFY
WalletWasabi/BitcoinP2p/TrustedP2pBehavior.cs
WalletWasabi/BitcoinP2p/TrustedP2pBehavior.cs
@@ -16,9 +16,6 @@ namespace WalletWasabi.BitcoinP2p
public event EventHandler<uint256>? BlockInv;
- private HashSet<uint256> DisabledFromProcessing { get; } = new();
- private object DisabledFromProcessingLock { get; } = new();
-
protected override bool ProcessInventoryVector(InventoryVector inv, EndPoint remoteSocketEndpoint)
{
if (inv.Type.HasFlag(InventoryType.MSG_TX))
@@ -51,43 +48,10 @@ namespace WalletWasabi.BitcoinP2p
}
protected override void ProcessTx(TxPayload payload)
- {
- var txid = payload.Object.GetHash();
-
- // Skip processing if txid is disabled.
- bool toProcess;
- lock (DisabledFromProcessingLock)
- {
- toProcess = !DisabledFromProcessing.Contains(txid);
- }
- if (toProcess)
{
base.ProcessTx(payload);
}
- }
public override object Clone() => new TrustedP2pBehavior(MempoolService);
-
- public void DisableProcess(IEnumerable<uint256> txids)
- {
- lock (DisabledFromProcessingLock)
- {
- foreach (var txid in txids)
- {
- DisabledFromProcessing.Add(txid);
- }
- }
- }
-
- public void EnableProcess(IEnumerable<uint256> txids)
- {
- lock (DisabledFromProcessingLock)
- {
- foreach (var txid in txids)
- {
- DisabledFromProcessing.Remove(txid);
- }
- }
- }
}
}

Use RPC to get txs instead of P2P