def to_h(with_state: false, full_transactions: false, with_storage_roots: false, with_uncles: false)
      b = { header: header.to_h }

      txlist = []
      get_transactions.each_with_index do |tx, i|
        receipt_rlp = @receipts[RLP.encode(i)]
        receipt = RLP.decode receipt_rlp, sedes: Receipt
        txjson = full_transactions ? tx.to_h : tx.full_hash

        logs = receipt.logs.map {|l| Log.serialize(l) }

        txlist.push(
          tx: txjson,
          medstate: Utils.encode_hex(receipt.state_root),
          gas: receipt.gas_used.to_s,
          logs: logs,
          bloom: Sedes.int256.serialize(receipt.bloom)
        )
      end
      b[:transactions] = txlist

      if with_state
        state_dump = {}
        @state.each do |address, v|
          state_dump[Utils.encode_hex(address)] = account_to_dict(address, with_storage_root: with_storage_roots)
        end
        b[:state] = state_dump
      end

      if with_uncles
        b[:uncles] = uncles.map {|u| RLP.decode(u, sedes: BlockHeader) }
      end

      b
    end
def to_h(with_state: false, full_transactions: false, with_storage_roots: false, with_uncles: false)
      b = { header: header.to_h }

      txlist = []
      get_transactions.each_with_index do |tx, i|
        receipt_rlp = @receipts[RLP.encode(i)]
        receipt = RLP.decode receipt_rlp, sedes: Receipt
        txjson = full_transactions ? tx.to_h : tx.full_hash

        logs = receipt.logs.map {|l| Log.serialize(l) }

        txlist.push(
          tx: txjson,
          medstate: Utils.encode_hex(receipt.state_root),
          gas: receipt.gas_used.to_s,
          logs: logs,
          bloom: Sedes.int256.serialize(receipt.bloom)
        )
      end
      b[:transactions] = txlist

      if with_state
        state_dump = {}
        @state.each do |address, v|
          state_dump[Utils.encode_hex(address)] = account_to_dict(address, with_storage_root: with_storage_roots)
        end
        b[:state] = state_dump
      end

      if with_uncles
        b[:uncles] = uncles.map {|u| RLP.decode(u, sedes: BlockHeader) }
      end

      b
    end
Serialize the block to a readable hash.

 @param with_state [Bool] include state for all accounts
 @param full_transactions [Bool] include serialized transactions (hashes
   otherwise)
 @param with_storage_roots [Bool] if account states are included also
   include their storage roots
 @param with_uncles [Bool] include uncle hashes

 @return [Hash] a hash represents the block