lib/eth/rlp/decoder.rb
# Consume an RLP payload at the given position of given type and size.
Consume an RLP payload at the given position of given type and size.
Consume an RLP payload at the given position of given type and size .
def consume_payload(rlp, start, type, length)
        case type
        when :str
          [rlp[start...(start + length)], start + length]
        when :list
          items = []
          next_item_start = start
          payload_end = next_item_start + length
          while next_item_start < payload_end
            item, next_item_start = consume_item rlp, next_item_start
            items.push item
          end
          raise DecodingError, "List length prefix announced a too small length" if next_item_start > payload_end
          [items, next_item_start]
        else
          raise TypeError, "Type must be either :str or :list"
        end
      end
def consume_payload ( rlp , start , type , length ) case type when :str [ rlp [ start ... ( start + length ) ] , start + length ] when :list items = [ ] next_item_start = start payload_end = next_item_start + length while next_item_start < payload_end item , next_item_start = consume_item rlp , next_item_start items . push item end raise DecodingError , "List length prefix announced a too small length" if next_item_start > payload_end [ items , next_item_start ] else raise TypeError , "Type must be either :str or :list" end end
Consume an RLP payload at the given position of given type and size.
Consume an RLP payload at the given position of given type and size .
rlp
start
type
length