Skip to content

Commit

Permalink
Only accept one mempool message per remote node
Browse files Browse the repository at this point in the history
  • Loading branch information
shargon committed Apr 18, 2020
1 parent 5839014 commit 359a3bb
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/neo/Network/P2P/RemoteNode.ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ protected override UInt256 GetKeyForItem((UInt256, DateTime) item)
private readonly HashSetCache<UInt256> knownHashes = new HashSetCache<UInt256>(Blockchain.Singleton.MemPool.Capacity * 2 / 5);
private readonly HashSetCache<UInt256> sentHashes = new HashSetCache<UInt256>(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);
Expand Down Expand Up @@ -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));
}
Expand Down

0 comments on commit 359a3bb

Please sign in to comment.