from-rpc.js
function blockFromRpc (blockParams, uncles) {
  uncles = uncles || []
  const block = new Block({
    transactions: [],
    uncleHeaders: []
  })
  block.header = blockHeaderFromRpc(blockParams)

  block.transactions = (blockParams.transactions || []).map(function (_txParams) {
    const txParams = normalizeTxParams(_txParams)
    // override from address
    const fromAddress = ethUtil.toBuffer(txParams.from)
    delete txParams.from
    const tx = new Transaction(txParams)
    tx._from = fromAddress
    tx.getSenderAddress = function () { return fromAddress }
    // override hash
    const txHash = ethUtil.toBuffer(txParams.hash)
    tx.hash = function () { return txHash }
    return tx
  })
  block.uncleHeaders = uncles.map(function (uncleParams) {
    return blockHeaderFromRpc(uncleParams)
  })

  return block
}
function blockFromRpc (blockParams, uncles) {
  uncles = uncles || []
  const block = new Block({
    transactions: [],
    uncleHeaders: []
  })
  block.header = blockHeaderFromRpc(blockParams)

  block.transactions = (blockParams.transactions || []).map(function (_txParams) {
    const txParams = normalizeTxParams(_txParams)
    // override from address
    const fromAddress = ethUtil.toBuffer(txParams.from)
    delete txParams.from
    const tx = new Transaction(txParams)
    tx._from = fromAddress
    tx.getSenderAddress = function () { return fromAddress }
    // override hash
    const txHash = ethUtil.toBuffer(txParams.hash)
    tx.hash = function () { return txHash }
    return tx
  })
  block.uncleHeaders = uncles.map(function (uncleParams) {
    return blockHeaderFromRpc(uncleParams)
  })

  return block
}
function blockFromRpc ( blockParams , uncles ) { uncles = uncles || [ ] const block = new Block ( { transactions : [ ] , uncleHeaders : [ ] } ) block . header = blockHeaderFromRpc ( blockParams ) block . transactions = ( blockParams . transactions || [ ] ) . map ( function ( _txParams ) { const txParams = normalizeTxParams ( _txParams ) // override from address const fromAddress = ethUtil . toBuffer ( txParams . from ) delete txParams . from const tx = new Transaction ( txParams ) tx . _from = fromAddress tx . getSenderAddress = function ( ) { return fromAddress } // override hash const txHash = ethUtil . toBuffer ( txParams . hash ) tx . hash = function ( ) { return txHash } return tx } ) block . uncleHeaders = uncles . map ( function ( uncleParams ) { return blockHeaderFromRpc ( uncleParams ) } ) return block }
Creates a new block object from Ethereum JSON RPC.
@param {Object} blockParams - Ethereum JSON RPC of block (eth_getBlockByNumber)
@param {Array.<Object>} Optional list of Ethereum JSON RPC of uncles (eth_getUncleByBlockHashAndIndex)
Creates a new block object from Ethereum JSON RPC .