public Block MapBlock(Core.Block block) => new Block { difficulty = block.Difficulty.ToString(), blockHash = block.Hash.ToString(), parentHash = block.ParentHash.ToString(), gasLimit = block.GasLimit, gasUsed = block.GasUsed, blockNumber = (long)block.Number, timestamp = (long)block.Timestamp, extraData = block.Header.ExtraData, miner = block.Beneficiary.ToString(), nonce = block.Header.Nonce.ToString(), size = Rlp.Encode(block).Bytes.Length, transactions = block.Transactions? .Select((t, i) => MapTransaction(i, block.Number, block.Hash, t)).ToList() ?? new List <Transaction>(), logsBloom = block.Header.Bloom.ToString(), receiptsRoot = block.Header.ReceiptsRoot.ToString(), stateRoot = block.Header.StateRoot.ToString(), transactionRoot = block.TxRoot.ToString(), totalDifficulty = block.TotalDifficulty?.ToString() ?? string.Empty, uncles = block.Ommers?.Select(o => o.Hash.ToString()).ToList() ?? new List <string>(), sha3uncles = block.Header.OmmersHash.ToString() };
private Task SendBlockAsync(IWebsocketClient client, Core.Block block) => _sender.SendAsync(client, new BlockMessage(new Block(block.Number, block.Hash?.ToString(), block.ParentHash?.ToString(), (long)block.Timestamp, block.Author?.ToString(), block.GasUsed, block.GasLimit, block.Difficulty.ToString(), block.TotalDifficulty?.ToString(), block.Transactions?.Select(t => new Transaction(t.Hash?.ToString())) ?? Enumerable.Empty <Transaction>(), block.TransactionsRoot.ToString(), block.StateRoot.ToString(), block.Ommers?.Select(o => new Uncle()) ?? Enumerable.Empty <Uncle>())));
private async Task ProduceAvroBlockAsync(string topic, Core.Block block) { var message = new Message <Null, Block> { Value = _mapper.MapBlock(block) }; var deliveryReport = await _producerBlocks.ProduceAsync(topic, message); if (_logger.IsDebug) { _logger.Debug($"Delivered '{deliveryReport.Value}' to '{deliveryReport.TopicPartitionOffset}'"); } }
public Block MapBlock(Core.Block block) => block == null ? null : new Block { Hash = block.Hash.Bytes, Header = MapBlockHeader(block.Header), Transactions = block.Transactions?.Select(MapTransaction).ToArray() ?? new Transaction[0], Ommers = block.Ommers?.Select(MapBlockHeader).ToArray() ?? new BlockHeader[0], ParentHash = block.ParentHash.Bytes, Beneficiary = block.Beneficiary.Bytes, StateRoot = block.StateRoot.Bytes, TransactionsRoot = block.TransactionsRoot.Bytes, GasLimit = block.GasLimit, GasUsed = block.GasUsed, Timestamp = block.Timestamp.ToString(), Number = block.Number.ToString(), Difficulty = block.Difficulty.ToString(), TotalDifficulty = block.TotalDifficulty?.ToString() };