ex_wire v0.1.1 ExWire.Struct.Block

A struct for storing blocks as they are transported over the Eth Wire Protocol.

Link to this section Summary

Functions

Given an RLP-encoded block from Eth Wire Protocol, decodes into a Block struct

Given a Block, serializes for transport over Eth Wire Protocol

Link to this section Types

Link to this type t()
t() :: %ExWire.Struct.Block{ommers: [binary], transactions: [Blockchain.Transaction.t], transactions_list: term}

Link to this section Functions

Link to this function deserialize(rlp)
deserialize(ExRLP.t) :: t

Given an RLP-encoded block from Eth Wire Protocol, decodes into a Block struct.

Examples

iex> ExWire.Struct.Block.deserialize([[[<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]], [<<1::256>>]])
%ExWire.Struct.Block{
  transactions_list: [[<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]],
  transactions: [%Blockchain.Transaction{nonce: 5, gas_price: 6, gas_limit: 7, to: <<1::160>>, value: 8, v: 27, r: 9, s: 10, data: "hi"}],
  ommers: [<<1::256>>]
}
Link to this function serialize(struct)
serialize(t) :: ExRLP.t

Given a Block, serializes for transport over Eth Wire Protocol.

Examples

iex> %ExWire.Struct.Block{transactions_list: [[<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]], ommers: [<<1::256>>]}
...> |> ExWire.Struct.Block.serialize
[[[<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]], [<<1::256>>]]