Module: Rlp

Defined in:
lib/rlp-lite.rb,
lib/rlp-lite/util.rb,
lib/rlp-lite/sedes.rb,
lib/rlp-lite/decoder.rb,
lib/rlp-lite/encoder.rb,
lib/rlp-lite/version.rb,
lib/rlp-lite/sedes/list.rb,
lib/rlp-lite/sedes/binary.rb,
lib/rlp-lite/sedes/big_endian_int.rb

Overview

Provides an recursive-length prefix (RLP) encoder and decoder.

Defined Under Namespace

Modules: Sedes, Util Classes: Data, Decoder, DecodingError, DeserializationError, Encoder, EncodingError, RlpException, SerializationError

Constant Summary collapse

BYTE_EMPTY =

todo/check - use encoding -ascii-8bit for source file or ? - why? why not? use #b/.b to ensure binary encoding? - why? why not?

"".freeze
BYTE_ZERO =

The empty byte is defined as “”.

"\x00".freeze
BYTE_ONE =

The zero byte is 0x00.

"\x01".freeze
SHORT_LENGTH_LIMIT =

The RLP short length limit.

56
LONG_LENGTH_LIMIT =

The RLP long length limit.

(256 ** 8)
PRIMITIVE_PREFIX_OFFSET =

The RLP primitive type offset.

0x80
LIST_PREFIX_OFFSET =

The RLP array type offset.

0xc0
INFINITY =

Infinity as constant for convenience.

(1.0 / 0.0)
VERSION =
'0.1.0'

Class Method Summary collapse

Class Method Details

.decode(rlp) ⇒ Object

Performes an Decoder on any RLP-encoded item.

Parameters:

  • rlp (String)

    a packed, RLP-encoded item.

Returns:

  • (Object)

    a decoded ruby object.



72
# File 'lib/rlp-lite.rb', line 72

def self.decode(rlp) decoder.perform( rlp ); end

.decoderObject



58
# File 'lib/rlp-lite.rb', line 58

def self.decoder() @decoder ||= Decoder.new; end

.encode(obj) ⇒ String

Performes an Encoder on any ruby object.

Parameters:

  • obj (Object)

    any ruby object.

Returns:

  • (String)

    a packed, RLP-encoded item.



65
# File 'lib/rlp-lite.rb', line 65

def self.encode(obj) encoder.perform( obj ); end

.encoderObject



57
# File 'lib/rlp-lite.rb', line 57

def self.encoder() @encoder ||= Encoder.new; end