public Transaction(byte[] sender, byte[] recipient, int amount, IHashFactory hashFactory) { Sender = sender; Recipient = recipient; Amount = amount; Nonce = hashFactory.GetNonceGenerator().GetNextNonce(); Hash = ComputeHash(hashFactory); }
public Block(byte[] minerAddress, byte[] previousHash, ICollection <Transaction> transactions, IHashFactory hashFactory) { MinerAddress = minerAddress; Transactions = transactions; CreationTime = DateTime.Now; IDigest digest = hashFactory.GetDigest(); INonceGenerator nonceGenerator = hashFactory.GetNonceGenerator(); PreviousHash = new byte[previousHash.Length]; Array.Copy(previousHash, PreviousHash, previousHash.Length); MerkleRoot = ComputeMerkleRoot(hashFactory); Nonce = nonceGenerator.GetNextNonce(); Hash = ComputeHash(hashFactory); }