public object ToJson() { return(new { number = Number?.ToJson(), hash = Hash?.ToJson(), parentHash = ParentHash?.ToJson(), nonce = Nonce?.ToJson(), MixHash = MixHash?.ToJson(), sha3Uncles = Sha3Uncles?.ToJson(), logsBloom = LogsBloom?.ToJson(), transactionsRoot = TransactionsRoot?.ToJson(), stateRoot = StateRoot?.ToJson(), receiptsRoot = ReceiptsRoot?.ToJson(), miner = Miner?.ToJson(), difficulty = Difficulty?.ToJson(), totalDifficulty = TotalDifficulty?.ToJson(), extraData = ExtraData?.ToJson(), size = Size?.ToJson(), gasLimit = GasLimit?.ToJson(), gasUsed = GasUsed?.ToJson(), timestamp = Timestamp?.ToJson(), transactions = Transactions?.Select(x => x.ToJson()).ToArray() ?? TransactionHashes?.Select(x => x.ToJson()).ToArray(), uncles = Uncles?.Select(x => x.ToJson()).ToArray() }); }
private void ToBytes(IBytesSink sink) { LedgerIndex.ToBytes(sink); TotalDrops.ToBytes(sink); ParentHash.ToBytes(sink); TransactionHash.ToBytes(sink); StateHash.ToBytes(sink); ParentCloseTime.ToBytes(sink); CloseTime.ToBytes(sink); CloseResolution.ToBytes(sink); CloseFlags.ToBytes(sink); }
public async Task newBlock_accepts_previously_assembled_block_multiple_times([Values(1, 3)] int times) { using MergeTestBlockchain chain = await CreateBlockChain(); IConsensusRpcModule rpc = CreateConsensusModule(chain); Keccak startingHead = chain.BlockTree.HeadHash; BlockHeader startingBestSuggestedHeader = chain.BlockTree.BestSuggestedHeader !; AssembleBlockRequest assembleBlockRequest = new() { ParentHash = startingHead }; ResultWrapper <BlockRequestResult?> assembleBlockResult = await rpc.consensus_assembleBlock(assembleBlockRequest); assembleBlockResult.Data !.ParentHash.Should().Be(startingHead); for (int i = 0; i < times; i++) { ResultWrapper <NewBlockResult> newBlockResult = await rpc.consensus_newBlock(assembleBlockResult.Data !); newBlockResult.Data.Valid.Should().BeTrue(); } Keccak bestSuggestedHeaderHash = chain.BlockTree.BestSuggestedHeader !.Hash !; bestSuggestedHeaderHash.Should().Be(assembleBlockResult.Data !.BlockHash); bestSuggestedHeaderHash.Should().NotBe(startingBestSuggestedHeader !.Hash !); }