public void AddBlock(TinyBlock newBlock) { if (newBlock.PreviousHash == null) { newBlock.PreviousHash = GetLatestBlock().Hash; newBlock.SetBlockHash(); } newBlock.MineBlock(); this.Chain.Add(newBlock); }
public TinyBlock CreateGenesisBlock(int difficulty = 0) { if (difficulty == 0) { return(new TinyBlock(0, DateTime.Now, new TinyTransaction("0"), difficulty, new Objects.Helpers().GenerateDefaultString(32))); } else { var block = new TinyBlock(0, DateTime.Now, new TinyTransaction("0"), difficulty, new Objects.Helpers().GenerateDefaultString(32)); block.MineBlock(); return(block); } }