Example #1
0
 internal void Write(BitReader reader, int bitCount)
 {
     for (int i = 0; i < bitCount; i++)
     {
         Write(reader.Read());
     }
 }
Example #2
0
        private IEnumerable <uint256> GetMatchedTransactionsCore(MerkleNode node, BitReader flags, IEnumerator <uint256> hashes, bool calculateHash)
        {
            if (node == null)
            {
                return(new uint256[0]);
            }
            node.IsMarked = flags.Read();

            if (node.IsLeaf || !node.IsMarked)
            {
                hashes.MoveNext();
                node.Hash = hashes.Current;
            }
            if (!node.IsMarked)
            {
                return(new uint256[0]);
            }
            if (node.IsLeaf)
            {
                return new uint256[] { node.Hash }
            }
            ;
            IEnumerable <uint256> left  = GetMatchedTransactionsCore(node.Left, flags, hashes, calculateHash);
            IEnumerable <uint256> right = GetMatchedTransactionsCore(node.Right, flags, hashes, calculateHash);

            if (calculateHash)
            {
                node.UpdateHash();
            }
            return(left.Concat(right));
        }
Example #3
0
		public bool Same(BitReader b)
		{
			while(Position != Count && b.Position != b.Count)
			{
				var valuea = Read();
				var valueb = b.Read();
				if(valuea != valueb)
					return false;
			}
			return true;
		}
Example #4
0
        private static void MarkNodes(MerkleNode root, bool[] vMatch)
        {
            var matches = new BitReader(new BitArray(vMatch));

            foreach (MerkleNode leaf in root.GetLeafs())
            {
                if (matches.Read())
                {
                    MarkToTop(leaf, true);
                }
            }
        }
Example #5
0
 public bool Same(BitReader b)
 {
     while (this.Position != this.Count && b.Position != b.Count)
     {
         bool valuea = Read();
         bool valueb = b.Read();
         if (valuea != valueb)
         {
             return(false);
         }
     }
     return(true);
 }
 public bool Same(BitReader b)
 {
     while (Position != Count && b.Position != b.Count)
     {
         var valuea = Read();
         var valueb = b.Read();
         if (valuea != valueb)
         {
             return(false);
         }
     }
     return(true);
 }
Example #7
0
		internal void Write(BitReader reader, int bitCount)
		{
			for(int i = 0 ; i < bitCount ; i++)
			{
				Write(reader.Read());
			}
		}
Example #8
0
		private static void MarkNodes(MerkleNode root, bool[] vMatch)
		{
			BitReader matches = new BitReader(new BitArray(vMatch));
			foreach(var leaf in root.GetLeafs())
			{
				if(matches.Read())
				{
					MarkToTop(leaf, true);
				}
			}
		}
Example #9
0
		private IEnumerable<uint256> GetMatchedTransactionsCore(MerkleNode node, BitReader flags, IEnumerator<uint256> hashes, bool calculateHash)
		{
			if(node == null)
				return new uint256[0];
			node.IsMarked = flags.Read();

			if(node.IsLeaf || !node.IsMarked)
			{
				hashes.MoveNext();
				node.Hash = hashes.Current;
			}
			if(!node.IsMarked)
				return new uint256[0];
			if(node.IsLeaf)
				return new uint256[] { node.Hash };
			var left = GetMatchedTransactionsCore(node.Left, flags, hashes, calculateHash);
			var right = GetMatchedTransactionsCore(node.Right, flags, hashes, calculateHash);
			if(calculateHash)
				node.UpdateHash();
			return left.Concat(right);
		}