Skip to content

Commit

Permalink
Update ProtocolHandler.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
erikzhang committed Nov 25, 2019
1 parent 9a73bf8 commit 04fdfa8
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions neo/Network/P2P/ProtocolHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ internal class ProtocolHandler : UntypedActor
public class SetFilter { public BloomFilter Filter; }
internal class Timer { }

private class PendingKnownHashesCollection : KeyedCollection<UInt256, KeyValuePair<UInt256, DateTime>>
private class PendingKnownHashesCollection : KeyedCollection<UInt256, (UInt256, DateTime)>
{
protected override UInt256 GetKeyForItem(KeyValuePair<UInt256, DateTime> item)
protected override UInt256 GetKeyForItem((UInt256, DateTime) item)
{
return item.Key;
return item.Item1;
}
}

Expand Down Expand Up @@ -314,7 +314,7 @@ private void OnInvMessageReceived(InvPayload payload)
}
if (hashes.Length == 0) return;
foreach (UInt256 hash in hashes)
pendingKnownHashes.Add(new KeyValuePair<UInt256, DateTime>(hash, DateTime.UtcNow));
pendingKnownHashes.Add((hash, DateTime.UtcNow));
system.TaskManager.Tell(new TaskManager.NewTasks { Payload = InvPayload.Create(payload.Type, hashes) }, Context.Parent);
}

Expand Down Expand Up @@ -362,10 +362,10 @@ private void RefreshPendingKnownHashes()
{
while (pendingKnownHashes.Count > 0)
{
KeyValuePair<UInt256, DateTime> item = pendingKnownHashes.First();
if (DateTime.UtcNow - item.Value <= PendingTimeout)
var (hash, time) = pendingKnownHashes[0];
if (DateTime.UtcNow - time <= PendingTimeout)
break;
pendingKnownHashes.Remove(item);
pendingKnownHashes.Remove(hash);
}
}

Expand Down

0 comments on commit 04fdfa8

Please sign in to comment.