private void OnInvMessageReceived(InvPayload payload) { UInt256[] hashes = payload.Hashes.Where(p => knownHashes.Add(p) && !sentHashes.Contains(p)).ToArray(); if (hashes.Length == 0) { return; } switch (payload.Type) { case InventoryType.Block: using (Snapshot snapshot = Blockchain.Singleton.GetSnapshot()) hashes = hashes.Where(p => !snapshot.ContainsBlock(p)).ToArray(); break; case InventoryType.TX: using (Snapshot snapshot = Blockchain.Singleton.GetSnapshot()) hashes = hashes.Where(p => !snapshot.ContainsTransaction(p)).ToArray(); break; } if (hashes.Length == 0) { return; } system.TaskManager.Tell(new TaskManager.NewTasks { Payload = InvPayload.Create(payload.Type, hashes) }, Context.Parent); }
internal static void Remove <T>(this HashSet <T> set, FIFOSet <T> other) where T : IEquatable <T> { if (set.Count > other.Count) { set.ExceptWith(other); } else { set.RemoveWhere(u => other.Contains(u)); } }