public async Task <bool> ValidateBlockAfterExecuteAsync(IBlock block) { if (block.Height == KernelConstants.GenesisBlockHeight) { return(true); } var indexedCrossChainBlockData = await _crossChainDataProvider.GetIndexedCrossChainBlockDataAsync(block.Header.GetHash(), block.Height); var extraData = _crossChainExtraDataExtractor.ExtractCrossChainData(block.Header); try { if (indexedCrossChainBlockData == null) { return(extraData == null); } var res = await ValidateCrossChainBlockDataAsync(indexedCrossChainBlockData, extraData, block); return(res); } finally { await LocalEventBus.PublishAsync(new CrossChainDataValidatedEvent()); } }
private ResponseParentChainBlockData FillExtraDataInResponse(ResponseParentChainBlockData responseParentChainBlockData, BlockHeader blockHeader, bool needOtherExtraData) { var transactionStatusMerkleRoot = _crossChainExtraDataExtractor.ExtractTransactionStatusMerkleTreeRoot(blockHeader); responseParentChainBlockData.BlockData.Root.TransactionStatusMerkleRoot = transactionStatusMerkleRoot; var crossChainExtra = _crossChainExtraDataExtractor.ExtractCrossChainData(blockHeader); responseParentChainBlockData.BlockData.Root.CrossChainExtraData = crossChainExtra; if (needOtherExtraData) { // only pack extra information after side chain creation // but the problem of communication data size still exists responseParentChainBlockData.BlockData.ExtraData.Add(_crossChainExtraDataExtractor.ExtractCommonExtraDataForExchange(blockHeader)); } return(responseParentChainBlockData); }