ex_wire v0.1.1 ExWire.Packet.BlockBodies

Eth Wire Packet for getting block bodies from a peer.

**BlockBodies** [`+0x06`, [`transactions_0`, `uncles_0`] , ...]

Reply to `GetBlockBodies`. The items in the list (following the message ID) are
some of the blocks, minus the header, in the format described in the main Ethereum
specification, previously asked for in a `GetBlockBodies` message. This may
validly contain no items if no blocks were able to be returned for the
`GetBlockBodies` query.

Link to this section Summary

Functions

Given an RLP-encoded BlockBodies packet from Eth Wire Protocol, decodes into a BlockBodies struct

Handles a BlockBodies message. This is when we have received a given set of blocks back from a peer

Given a BlockBodies packet, serializes for transport over Eth Wire Protocol

Link to this section Types

Link to this type t()
t() :: %ExWire.Packet.BlockBodies{blocks: [ExWire.Struct.Block.t]}

Link to this section Functions

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

Given an RLP-encoded BlockBodies packet from Eth Wire Protocol, decodes into a BlockBodies struct.

Examples

iex> ExWire.Packet.BlockBodies.deserialize([ [[[<<5>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]], [<<1::256>>]], [[[<<6>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]], [<<1::256>>]] ])
%ExWire.Packet.BlockBodies{
  blocks: [
    %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>>]
    },
    %ExWire.Struct.Block{
      transactions_list: [[<<6>>, <<6>>, <<7>>, <<1::160>>, <<8>>, "hi", <<27>>, <<9>>, <<10>>]],
      transactions: [%Blockchain.Transaction{nonce: 6, gas_price: 6, gas_limit: 7, to: <<1::160>>, value: 8, v: 27, r: 9, s: 10, data: "hi"}],
      ommers: [<<1::256>>]
    }
  ]
}

Handles a BlockBodies message. This is when we have received a given set of blocks back from a peer.

Examples

iex> %ExWire.Packet.GetBlockBodies{hashes: [<<5>>, <<6>>]}
...> |> ExWire.Packet.GetBlockBodies.handle()
:ok
Link to this function serialize(packet)
serialize(t) :: ExRLP.t

Given a BlockBodies packet, serializes for transport over Eth Wire Protocol.

Examples

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