From 359a3bb655e7cd82e3d68a7f2d0ee1b4cda68d2b Mon Sep 17 00:00:00 2001 From: Shargon Date: Sat, 18 Apr 2020 21:42:09 +0200 Subject: [PATCH] Only accept one mempool message per remote node --- src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs b/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs index 91b3921326..4df1b56b80 100644 --- a/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs +++ b/src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs @@ -30,6 +30,7 @@ protected override UInt256 GetKeyForItem((UInt256, DateTime) item) private readonly HashSetCache knownHashes = new HashSetCache(Blockchain.Singleton.MemPool.Capacity * 2 / 5); private readonly HashSetCache sentHashes = new HashSetCache(Blockchain.Singleton.MemPool.Capacity * 2 / 5); private bool verack = false; + private bool memPoolWasSent = false; private BloomFilter bloom_filter; private static readonly TimeSpan TimerInterval = TimeSpan.FromSeconds(30); @@ -314,6 +315,14 @@ private void OnInvMessageReceived(InvPayload payload) private void OnMemPoolMessageReceived() { + if (memPoolWasSent) + { + Disconnect(true); + return; + } + + memPoolWasSent = true; + foreach (InvPayload payload in InvPayload.CreateGroup(InventoryType.TX, Blockchain.Singleton.MemPool.GetVerifiedTransactions().Select(p => p.Hash).ToArray())) EnqueueMessage(Message.Create(MessageCommand.Inv, payload)); }