public void Switch(Networks network) { if (_blockChain != null) { _blockChain.Dispose(); _blockChain = null; } _blockChain = _blockChainFactory.Build(network); }
public void TestVerifyChain_UnloadinLoading() { var blockChain = new BlockChain(); var block = blockChain.GetNextBlock(); block.Data = "hi"; block.Alpha = 1; block.TimeStamp = DateTime.Now; blockChain.AddNextBlock(block); blockChain.Dispose(); var loadedChain = new BlockChain("dotcoin.chain"); Assert.True(loadedChain.Size() == 2); }
static void Main(string[] args) { Console.WriteLine($"Start {DateTime.Now}"); BlockChain reg = new BlockChain(); reg.CreateBlock(new AccountRegisterData(0, 1000, 1000)); reg.CreateBlock(new AccountRegisterData(1000, -100, 900)); reg.CreateBlock(new AccountRegisterData(900, 500, 1400)); Console.WriteLine($"End {DateTime.Now}"); //reg.PrintBlockChain(); //reg.ValidateBlockChain(); reg.Serialize(); reg.Dispose(); BlockChain bc = new BlockChain(); bc.CreateBlock(new AccountRegisterData(1400, -200, 1200)); bc.PrintBlockChain(); bc.Dispose(); Console.Write("Press any key ..."); Console.ReadKey(); }