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 auto-freeze string literals magic comment - why? why not?

"".b.freeze
BYTE_ZERO =

The empty byte is defined as “”.

"\x00".b.freeze
BYTE_ONE =

The zero byte is 0x00.

"\x01".b.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.2.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.



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

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

.decoderObject



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

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.



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

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

.encoderObject



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

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