Пример #1
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));
        }
Пример #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 };
			var left = GetMatchedTransactionsCore(node.Left, flags, hashes, calculateHash);
			var right = GetMatchedTransactionsCore(node.Right, flags, hashes, calculateHash);
			if(calculateHash)
				node.UpdateHash();
			return left.Concat(right);
		}