Module: Klay::Rlp::Decoder
Overview
Provides an RLP-decoder.
Class Method Summary collapse
-
.perform(rlp) ⇒ Object
Decodes an RLP-encoded object.
Instance Method Summary collapse
-
#perform(rlp) ⇒ Object
Decodes an RLP-encoded object.
Class Method Details
.perform(rlp) ⇒ Object
Decodes an RLP-encoded object.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/klay/rlp/decoder.rb', line 33 def perform(rlp) rlp = Util.hex_to_bin rlp if Util.is_hex? rlp rlp = Util.str_to_bytes rlp begin item, next_start = consume_item rlp, 0 rescue Exception => e raise DecodingError, "Cannot decode rlp string: #{e}" end raise DecodingError, "RLP string ends with #{rlp.size - next_start} superfluous bytes" if next_start != rlp.size return item end |
Instance Method Details
#perform(rlp) ⇒ Object
Decodes an RLP-encoded object.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/klay/rlp/decoder.rb', line 33 def perform(rlp) rlp = Util.hex_to_bin rlp if Util.is_hex? rlp rlp = Util.str_to_bytes rlp begin item, next_start = consume_item rlp, 0 rescue Exception => e raise DecodingError, "Cannot decode rlp string: #{e}" end raise DecodingError, "RLP string ends with #{rlp.size - next_start} superfluous bytes" if next_start != rlp.size return item end |