Class: Reth::ETHProtocol::NewBlock

Inherits:
DEVp2p::Command
  • Object
show all
Defined in:
lib/reth/eth_protocol.rb

Overview

Specify a single block that the peer should know about.

The composite item in the list (following the message ID) is a block in the format described in the main Ethereum specification.

Class Method Summary collapse

Class Method Details

.decode_payload(rlp_data) ⇒ Object

Raises:

  • (AssertError)


161
162
163
164
165
166
167
168
169
# File 'lib/reth/eth_protocol.rb', line 161

def self.decode_payload(rlp_data)
  ll = RLP.decode_lazy rlp_data
  raise AssertError unless ll.size == 2

  transient_block = TransientBlock.new ll[0], Time.now
  difficulty = RLP::Sedes.big_endian_int.deserialize ll[1]

  {block: transient_block, chain_difficulty: difficulty}
end