Updated to use option types

This commit is contained in:
coffeepots 2018-08-28 21:45:09 +01:00 committed by zah
parent f3df5156d9
commit 396f31f643
1 changed files with 10 additions and 18 deletions

View File

@ -304,10 +304,8 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
discard discard
func populateBlockObject(header: BlockHeader, blockBody: BlockBodyRef): BlockObject = func populateBlockObject(header: BlockHeader, blockBody: BlockBodyRef): BlockObject =
result.number = new BlockNumber result.number = some(header.blockNumber)
result.number[] = header.blockNumber result.hash = some(header.hash)
result.hash = new Hash256
result.hash[] = header.hash
result.parentHash = header.parentHash result.parentHash = header.parentHash
result.nonce = header.nonce.toUint result.nonce = header.nonce.toUint
@ -320,8 +318,7 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
startIdx += 32 startIdx += 32
result.sha3Uncles = keccak256.digest(rawData) result.sha3Uncles = keccak256.digest(rawData)
result.logsBloom = new BloomFilter result.logsBloom = some(header.bloom)
result.logsBloom[] = header.bloom
result.transactionsRoot = header.txRoot result.transactionsRoot = header.txRoot
result.stateRoot = header.stateRoot result.stateRoot = header.stateRoot
result.receiptsRoot = header.receiptRoot result.receiptsRoot = header.receiptRoot
@ -365,7 +362,7 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
raise newException(ValueError, "Cannot find hash") raise newException(ValueError, "Cannot find hash")
populateBlockObject(header, body) populateBlockObject(header, body)
proc populateTransactionObject(transaction: Transaction, txIndex: int, blockHeader: BlockHeader, blockHash: Hash256): TransactionObject = proc populateTransactionObject(transaction: Transaction, txIndex: int64, blockHeader: BlockHeader, blockHash: Hash256): TransactionObject =
let let
vmState = newBaseVMState(blockHeader, chain) vmState = newBaseVMState(blockHeader, chain)
accountDb = vmState.chaindb.getStateDb(blockHash, true) accountDb = vmState.chaindb.getStateDb(blockHash, true)
@ -376,15 +373,11 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
result.hash = txHash result.hash = txHash
result.nonce = txCount result.nonce = txCount
result.blockHash = new Hash256 result.blockHash = some(blockHash)
result.blockHash[] = blockHash result.blockNumber = some(blockHeader.blockNumber)
result.blockNumber = new BlockNumber result.transactionIndex = some(txIndex)
result.blockNumber[] = blockHeader.blockNumber
result.transactionIndex = new int64
result.transactionIndex[] = txIndex
result.source = transaction.getSender() result.source = transaction.getSender()
result.to = new EthAddress result.to = some(transaction.to)
result.to[] = transaction.to
result.value = transaction.value result.value = transaction.value
result.gasPrice = transaction.gasPrice result.gasPrice = transaction.gasPrice
result.gas = accountGas result.gas = accountGas
@ -443,12 +436,11 @@ proc setupP2PRPC*(node: EthereumNode, rpcsrv: RpcServer) =
result.blockHash = blockHeader.hash result.blockHash = blockHeader.hash
result.blockNumber = blockHeader.blockNumber result.blockNumber = blockHeader.blockNumber
result.sender = transaction.getSender() result.sender = transaction.getSender()
result.to = new EthAddress result.to = some(transaction.to)
result.to[] = transaction.to
result.cumulativeGasUsed = cumulativeGas result.cumulativeGasUsed = cumulativeGas
result.gasUsed = receipt.gasUsed result.gasUsed = receipt.gasUsed
# TODO: Get contract address if the transaction was a contract creation. # TODO: Get contract address if the transaction was a contract creation.
result.contractAddress = nil result.contractAddress = none(EthAddress)
result.logs = receipt.logs result.logs = receipt.logs
result.logsBloom = blockHeader.bloom result.logsBloom = blockHeader.bloom
# post-transaction stateroot (pre Byzantium). # post-transaction stateroot (pre Byzantium).