module RLP::Decode
def consume_payload(rlp, start, type, length)
the position of the first unprocessed byte.
Returns a pair `[item, end]`, where `item` is the read item and `end` is
* `length` - the length of the payload in bytes
* `start` - the position at which to start reading
* `type` - the type of the payload (`:str` or `:list`)
* `rlp` - the rlp string to read from
Read the payload of an item from an RLP string.
#
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.new('List length prefix announced a too small length', rlp) if next_item_start > payload_end [items, next_item_start] else raise TypeError, 'Type must be either :str or :list' end end