public async Task <BlockHashed> MineGenesisAsync(int?numberOfThreads) { var genesisMiner = MinerFactory.Create(Genesis.GetBlockData(Cryptography, DateTime.UtcNow.Ticks), _feedback); return(await _feedback.Execute("MineGenesis", () => MineAsync(genesisMiner, numberOfThreads), () => $"{nameof(numberOfThreads)}: {numberOfThreads}")); }
private async Task <BlockHashed> GenerateGenesisBlock() { var feedback = new NullFeedBack(); var genesisMiner = _minerFactory.Create(Genesis.GetBlockData(_cryptography, DateTime.UtcNow.Ticks), feedback); genesisMiner.Start(1); return(await genesisMiner.GetBlock()); }
public async Task GenerateBlock_GenesisBlock_Invalidate_Hash() { var genesisBlock = await GenerateGenesisBlock(); var newGenesisSignedBlock = Genesis.GetBlockData(_cryptography, DateTime.UtcNow.Ticks); _chainData.ValidateGenesisBlock(new BlockHashed(newGenesisSignedBlock, genesisBlock.HashTarget), out var _); }
public bool ValidateGenesisBlock(BlockHashed newBlock, out BlockchainState blockchainState) { var expectedSignedGenesis = Genesis.GetBlockData(_cryptography, newBlock.Signed.Data.TimeStamp); var result = ValidateParent(0, Genesis.Hash, newBlock.Signed.Data, out blockchainState); if (result) { ValidateSignature(expectedSignedGenesis.Stamp, newBlock.Signed); ValidateBlockHash(expectedSignedGenesis, newBlock.HashTarget); } return(result); }