Skip to content

Commit

Permalink
Avoid processing own hashes (3x) (neo-project#1009)
Browse files Browse the repository at this point in the history
* Avoid processing own hashes

* Shargon's suggestion I

* Shargon's suggestion II

* rename
  • Loading branch information
vncoelho authored and Tommo-L committed Jun 22, 2020
1 parent b1f078d commit 39d4e70
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
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 Contains(T item)
{
return dictionary.Contains(item);
}

public void ExceptWith(IEnumerable<UInt256> hashes)
{
foreach (var hash in hashes)
Expand Down
2 changes: 1 addition & 1 deletion neo/Network/P2P/ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ private void OnInventoryReceived(IInventory inventory)

private void OnInvMessageReceived(InvPayload payload)
{
UInt256[] hashes = payload.Hashes.Where(p => knownHashes.Add(p)).ToArray();
UInt256[] hashes = payload.Hashes.Where(p => knownHashes.Add(p) && !sentHashes.Contains(p)).ToArray();
if (hashes.Length == 0) return;
switch (payload.Type)
{
Expand Down

0 comments on commit 39d4e70

Please sign in to comment.