private static void AddTransactionsToBlocksAndCalculateHashes(IMBlock block1, IMBlock block2, IMBlock block3, IMBlock block4) { block1.AddTransaction(txnPool.GetTransaction()); block1.AddTransaction(txnPool.GetTransaction()); block1.AddTransaction(txnPool.GetTransaction()); block1.AddTransaction(txnPool.GetTransaction()); block2.AddTransaction(txnPool.GetTransaction()); block2.AddTransaction(txnPool.GetTransaction()); block2.AddTransaction(txnPool.GetTransaction()); block2.AddTransaction(txnPool.GetTransaction()); block3.AddTransaction(txnPool.GetTransaction()); block3.AddTransaction(txnPool.GetTransaction()); block3.AddTransaction(txnPool.GetTransaction()); block3.AddTransaction(txnPool.GetTransaction()); block4.AddTransaction(txnPool.GetTransaction()); block4.AddTransaction(txnPool.GetTransaction()); block4.AddTransaction(txnPool.GetTransaction()); block4.AddTransaction(txnPool.GetTransaction()); block1.SetBlockHash(null); block2.SetBlockHash(block1); block3.SetBlockHash(block2); block4.SetBlockHash(block3); }
public void AcceptBlock(IMBlock block) { if (HeadBlock == null) { HeadBlock = block; HeadBlock.PreviousBlockHash = null; } CurrentBlock = block; Blocks.Add(block); }
public void SetBlockHash(IMBlock parent) { if (parent != null) { PreviousBlockHash = parent.BlockHash; parent.NextBlock = this; } else { PreviousBlockHash = null; } BuildMerkleTree(); (Nonce, BlockHash) = ProofOfWork.CalculateProofOfWork(CalculateBlockHash(PreviousBlockHash), Difficulty); if (KeyStore != null) { BlockSignature = KeyStore.SignBlock(BlockHash); } }