/// <summary> /// Creates a <see cref="PreEvaluationBlock{T}"/> instance with its /// <paramref name="content"/> data, a valid proof-of-work <paramref name="nonce"/> /// which satisfies the required <see cref="PreEvaluationBlockHeader.Difficulty"/>, /// and a <paramref name="preEvaluationHash"/> digest derived from them. /// </summary> /// <param name="content">Block's content data.</param> /// <param name="hashAlgorithm">The hash algorithm used for calculating /// <see cref="PreEvaluationBlockHeader.PreEvaluationHash"/>.</param> /// <param name="nonce">A valid proof-of-work nonce which satisfies the required /// <see cref="PreEvaluationBlockHeader.Difficulty"/>.</param> /// <param name="preEvaluationHash">The hash digest of the <paramref name="hashAlgorithm"/> /// derived from the given arguments.</param> /// <exception cref="InvalidBlockProtocolVersionException">Thrown when /// the <paramref name="content"/>'s <see cref="IBlockMetadata.ProtocolVersion"/> /// is less than 0, or greater than <see cref="BlockMetadata.CurrentProtocolVersion"/>, /// the latest known protocol version.</exception> /// <exception cref="InvalidBlockIndexException">Thrown when the value to set is negative. /// </exception> /// <exception cref="InvalidBlockDifficultyException">Thrown when the value to set is /// is negative.</exception> /// <exception cref="InvalidBlockTotalDifficultyException">Thrown when /// the <paramref name="content"/>'s <see cref="IBlockMetadata.TotalDifficulty"/> is less /// than its <see cref="IBlockMetadata.Difficulty"/>.</exception> /// <exception cref="InvalidTxSignatureException">Thrown when any tx signature is invalid or /// not signed by its signer.</exception> /// <exception cref="InvalidTxPublicKeyException">Thrown when any tx signer is not derived /// from its its public key.</exception> /// <exception cref="InvalidTxNonceException">Thrown when the same tx nonce is used by /// a signer twice or more, or a tx nonce is used without its previous nonce by a signer. /// Note that this validates only a block's intrinsic integrity between its transactions, /// but does not guarantee integrity between blocks. Such validation needs to be conducted /// by <see cref="Blockchain.BlockChain{T}"/>.</exception> /// <exception cref="InvalidTxGenesisHashException">Thrown when transactions to set have /// inconsistent genesis hashes.</exception> /// <exception cref="InvalidBlockTxHashException">Thrown when the given block /// <paramref name="content"/>'s <see cref="IBlockMetadata.TxHash"/> is not consistent with /// its <see cref="IBlockContent{T}.Transactions"/>.</exception> /// <exception cref="InvalidBlockPreEvaluationHashException">Thrown when the given /// <paramref name="preEvaluationHash"/> is invalid.</exception> /// <exception cref="InvalidBlockNonceException">Thrown when the given proof-of-work /// <paramref name="nonce"/> does not satisfy the required /// <see cref="PreEvaluationBlockHeader.Difficulty"/>.</exception> public PreEvaluationBlock( IBlockContent <T> content, HashAlgorithmType hashAlgorithm, Nonce nonce, ImmutableArray <byte> preEvaluationHash ) : base(new BlockContent <T>(content), hashAlgorithm, nonce, preEvaluationHash) { }
public static void AssertBlockContentsEqual <T>( IBlockContent <T> expected, IBlockContent <T> actual ) where T : IAction, new() { AssertBlockMetadataEqual(expected, actual); Assert.Equal(expected.Transactions, actual.Transactions); }
/// <summary> /// Creates a <see cref="PreEvaluationBlock{T}"/> instance with its /// <paramref name="content"/> data and a valid proof-of-work <paramref name="nonce"/> /// which satisfies the required <see cref="PreEvaluationBlockHeader.Difficulty"/>. /// </summary> /// <param name="content">Block's content data.</param> /// <param name="hashAlgorithm">The hash algorithm used for calculating /// <see cref="PreEvaluationBlockHeader.PreEvaluationHash"/>.</param> /// <param name="nonce">A valid proof-of-work nonce which satisfies the required /// <see cref="PreEvaluationBlockHeader.Difficulty"/>.</param> /// <exception cref="InvalidBlockProtocolVersionException">Thrown when /// the <paramref name="content"/>'s to set is <see cref="IBlockMetadata.ProtocolVersion"/> /// is less than 0, or greater than <see cref="BlockMetadata.CurrentProtocolVersion"/>, /// the latest known protocol version.</exception> /// <exception cref="InvalidBlockIndexException">Thrown when the value to set is negative. /// </exception> /// <exception cref="InvalidBlockDifficultyException">Thrown when the value to set is /// is negative.</exception> /// <exception cref="InvalidBlockTotalDifficultyException">Thrown when /// the <paramref name="content"/>'s <see cref="IBlockMetadata.TotalDifficulty"/> is less /// than its <see cref="IBlockMetadata.Difficulty"/>.</exception> /// <exception cref="InvalidTxSignatureException">Thrown when any tx signature is invalid or /// not signed by its signer.</exception> /// <exception cref="InvalidTxPublicKeyException">Thrown when any tx signer is not derived /// from its its public key.</exception> /// <exception cref="InvalidTxNonceException">Thrown when the same tx nonce is used by /// a signer twice or more, or a tx nonce is used without its previous nonce by a signer. /// Note that this validates only a block's intrinsic integrity between its transactions, /// but does not guarantee integrity between blocks. Such validation needs to be conducted /// by <see cref="Blockchain.BlockChain{T}"/>.</exception> /// <exception cref="InvalidTxGenesisHashException">Thrown when transactions to set have /// inconsistent genesis hashes.</exception> /// <exception cref="InvalidBlockTxHashException">Thrown when the given block /// <paramref name="content"/>'s <see cref="IBlockMetadata.TxHash"/> is not consistent with /// its <see cref="IBlockContent{T}.Transactions"/>.</exception> /// <exception cref="InvalidBlockNonceException">Thrown when the given proof-of-work /// <paramref name="nonce"/> does not satisfy the required /// <see cref="PreEvaluationBlockHeader.Difficulty"/>. /// </exception> /// <remarks><see cref="PreEvaluationBlockHeader.PreEvaluationHash"/> is automatically /// derived from the given arguments.</remarks> public PreEvaluationBlock( IBlockContent <T> content, HashAlgorithmType hashAlgorithm, Nonce nonce ) : base( new BlockContent <T>(content), hashAlgorithm, nonce ) { }
public BlockContent(IBlockContent <T> content) : this(content, content.Transactions) { }
public static BlockContent <T> Copy <T>(this IBlockContent <T> content) where T : IAction, new() => new BlockContent <T>(content);