diff options
author | Felix Lange <fjl@twurst.com> | 2015-06-27 09:08:50 +0800 |
---|---|---|
committer | Jeffrey Wilcke <geffobscura@gmail.com> | 2015-06-30 00:51:48 +0800 |
commit | 76821d167acd7da15e13b23beeceb6779138ffe5 (patch) | |
tree | 73af5b18546dcb4db62e9e7f24d8bb103cdbfcef /rpc | |
parent | fccc7d71eb1e8e655f9bcd9c6d7856b70bbeda36 (diff) | |
download | dexon-76821d167acd7da15e13b23beeceb6779138ffe5.tar dexon-76821d167acd7da15e13b23beeceb6779138ffe5.tar.gz dexon-76821d167acd7da15e13b23beeceb6779138ffe5.tar.bz2 dexon-76821d167acd7da15e13b23beeceb6779138ffe5.tar.lz dexon-76821d167acd7da15e13b23beeceb6779138ffe5.tar.xz dexon-76821d167acd7da15e13b23beeceb6779138ffe5.tar.zst dexon-76821d167acd7da15e13b23beeceb6779138ffe5.zip |
core, eth, rpc: avoid unnecessary block header copying
Diffstat (limited to 'rpc')
-rw-r--r-- | rpc/api/parsing.go | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/rpc/api/parsing.go b/rpc/api/parsing.go index 85a9165e5..632462c31 100644 --- a/rpc/api/parsing.go +++ b/rpc/api/parsing.go @@ -270,29 +270,31 @@ func NewBlockRes(block *types.Block, fullTx bool) *BlockRes { res.BlockHash = newHexData(block.Hash()) res.ParentHash = newHexData(block.ParentHash()) res.Nonce = newHexData(block.Nonce()) - res.Sha3Uncles = newHexData(block.Header().UncleHash) + res.Sha3Uncles = newHexData(block.UncleHash()) res.LogsBloom = newHexData(block.Bloom()) - res.TransactionRoot = newHexData(block.Header().TxHash) + res.TransactionRoot = newHexData(block.TxHash()) res.StateRoot = newHexData(block.Root()) - res.Miner = newHexData(block.Header().Coinbase) + res.Miner = newHexData(block.Coinbase()) res.Difficulty = newHexNum(block.Difficulty()) res.TotalDifficulty = newHexNum(block.Td) res.Size = newHexNum(block.Size().Int64()) - res.ExtraData = newHexData(block.Header().Extra) + res.ExtraData = newHexData(block.Extra()) res.GasLimit = newHexNum(block.GasLimit()) res.GasUsed = newHexNum(block.GasUsed()) res.UnixTimestamp = newHexNum(block.Time()) - res.Transactions = make([]*TransactionRes, len(block.Transactions())) - for i, tx := range block.Transactions() { + txs := block.Transactions() + res.Transactions = make([]*TransactionRes, len(txs)) + for i, tx := range txs { res.Transactions[i] = NewTransactionRes(tx) res.Transactions[i].BlockHash = res.BlockHash res.Transactions[i].BlockNumber = res.BlockNumber res.Transactions[i].TxIndex = newHexNum(i) } - res.Uncles = make([]*UncleRes, len(block.Uncles())) - for i, uncle := range block.Uncles() { + uncles := block.Uncles() + res.Uncles = make([]*UncleRes, len(uncles)) + for i, uncle := range uncles { res.Uncles[i] = NewUncleRes(uncle) } |