Module: RLP::Decode
Constant Summary
Constants included from Constant
Constant::BYTE_EMPTY, Constant::BYTE_ZERO, Constant::LIST_PREFIX_OFFSET, Constant::LONG_LENGTH_LIMIT, Constant::PRIMITIVE_PREFIX_OFFSET, Constant::SHORT_LENGTH_LIMIT
Instance Method Summary collapse
Methods included from Utils
#big_endian_to_int, #bytes_to_str, #encode_hex, #int_to_big_endian, #list?, #primitive?, #str_to_bytes
Instance Method Details
#decode(rlp, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rlp/decode.rb', line 7 def decode(rlp, ={}) sedes = .delete(:sedes) strict = .delete(:strict) {|k| true } rlp = str_to_bytes(rlp) begin item, next_start = consume_item(rlp, 0) rescue Exception => e raise DecodingError.new("Cannot decode rlp string: #{e}", rlp) end raise DecodingError.new("RLP string ends with #{rlp.size - next_start} superfluous bytes", rlp) if next_start != rlp.size && strict if sedes obj = sedes.deserialize(item) # TODO: (options) #TODO: cache flow obj else item end end |