Example #1
0
        public static BlockHeader UnmarshalBlockHeader(
            HashAlgorithmGetter hashAlgorithmGetter,
            Dictionary marshaled
            )
        {
            PreEvaluationBlockHeader preEvalHeader =
                UnmarshalPreEvaluationBlockHeader(hashAlgorithmGetter, marshaled);
            HashDigest <SHA256>   stateRootHash = UnmarshalBlockHeaderStateRootHash(marshaled);
            ImmutableArray <byte>?sig           = UnmarshalBlockHeaderSignature(marshaled);
            BlockHash             hash          = UnmarshalBlockHeaderHash(marshaled);

            return(new BlockHeader(preEvalHeader, stateRootHash, sig, hash));
        }
Example #2
0
        /// <summary>
        /// Creates a <see cref="BlockHeader"/> instance from the given
        /// <paramref name="preEvaluationBlockHeader"/> and <paramref name="stateRootHash"/>.
        /// This automatically derives its hash from the given inputs.
        /// </summary>
        /// <param name="preEvaluationBlockHeader">The pre-evaluation block header.</param>
        /// <param name="stateRootHash">The state root hash.</param>
        /// <param name="signature">The block signature.</param>
        /// <exception cref="InvalidBlockSignatureException">Thrown when
        /// the <paramref name="signature"/> signature is invalid.</exception>
        public BlockHeader(
            PreEvaluationBlockHeader preEvaluationBlockHeader,
            HashDigest <SHA256> stateRootHash,
            ImmutableArray <byte>?signature
            )
#pragma warning disable SA1118
            : this(
                preEvaluationBlockHeader,
                (
                    stateRootHash,
                    signature,
                    preEvaluationBlockHeader.DeriveBlockHash(stateRootHash, signature)
                )
                )
#pragma warning restore SA1118
        {