Example #1
0
        public async Task FillBlockExtraData_Test()
        {
            var blockHeader = new BlockHeader()
            {
                Height = 100,
            };
            await _blockExtraDataService.FillBlockExtraData(blockHeader);

            blockHeader.ExtraData.Count.ShouldBe(0);

            blockHeader.Height = 1;
            await _blockExtraDataService.FillBlockExtraData(blockHeader);

            blockHeader.ExtraData.Count.ShouldBe(1);
        }
        public async Task <Block> GenerateBlockBeforeExecutionAsync(GenerateBlockDto generateBlockDto)
        {
            var block = new Block
            {
                Header = new BlockHeader
                {
                    ChainId           = _staticChainInformationProvider.ChainId,
                    Height            = generateBlockDto.PreviousBlockHeight + 1,
                    PreviousBlockHash = generateBlockDto.PreviousBlockHash,
                    Time = generateBlockDto.BlockTime
                },
                Body = new BlockBody()
            };

            // get block extra data with _blockExtraDataService including consensus data, cross chain data etc..
            await _blockExtraDataService.FillBlockExtraData(block.Header);

            // calculate and set tx merkle tree root
            //block.Complete(currentBlockTime, results);
            return(block);
        }