Example #1
0
        /// <summary>
        /// Adds the packet.
        /// </summary>
        /// <param name="packet">The packet.</param>
        /// <returns>true; if the message is completed, otherwise false</returns>
        public bool AddPacket(Packet packet)
        {
            ReceivedPacket p = new ReceivedPacket(packet, BlockCount);

            foreach (var smaller in SelectSubsets(p.Blocks.Count, newLeaves, p.Blocks))
                if (smaller.Blocks.IsProperSubsetOf(p.Blocks))
                    p.Xor(smaller);

            if (p.Blocks.Count == 1)
            {
                newLeaves.Clear();
                newLeaves.Enqueue(p);

                while (newLeaves.Count > 0)
                {
                    var next = newLeaves.Dequeue();
                    if (next.Blocks.Count == 1)
                        SubtractNewLeaf(next, newLeaves);
                }
            }

            AddToList(p);

            return IsComplete;
        }
Example #2
0
            public ReceivedPacket(Packet packet, int blockCount)
            {
                Data = packet.Data;

                Blocks = new HashSet<int>();
                Helpers.CalculateBlockSet(packet.PacketSeed, blockCount, Blocks);

                GenerateHash();
            }