Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid processing own messages (2x) #1010

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions neo/IO/Caching/FIFOSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ public bool Add(T item)
return true;
}

public bool HasItem(T item)
{
return dictionary.Contains(item);
}

public void ExceptWith(IEnumerable<UInt256> hashes)
{
foreach (var hash in hashes)
Expand Down
3 changes: 2 additions & 1 deletion neo/Network/P2P/ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,8 @@ private void OnInventoryReceived(IInventory inventory)
private void OnInvMessageReceived(InvPayload payload)
{
UInt256[] hashes = payload.Hashes.Where(p => knownHashes.Add(p)).ToArray();
vncoelho marked this conversation as resolved.
Show resolved Hide resolved
if (hashes.Length == 0) return;
bool sentByMe = payload.Hashes.Any(p => sentHashes.HasItem(p));
if (hashes.Length == 0 || sentByMe) return;
switch (payload.Type)
{
case InventoryType.Block:
Expand Down