eth_rlp package
HashableRLP
- class eth_rlp.main.HashableRLP(*args, **kwargs)
An extension of
rlp.Serializable
. In addition to the below functions, the class is iterable.Use like:
class MyRLP(HashableRLP): fields = ( ('name1', rlp.sedes.big_endian_int), ('name2', rlp.sedes.binary), etc... ) my_obj = MyRLP(name2=b'\xff', name1=1) list(my_obj) == [1, b'\xff'] # note that the iteration order is always in RLP-defined order
- as_dict() Dict[str, Any]
Convert rlp object to a dict
- Returns:
mapping of RLP field names to field values
- Return type:
- classmethod from_bytes(serialized_bytes: bytes | bytearray) Self
Shorthand invocation for
rlp.decode()
using this class.- Parameters:
serialized_bytes (bytes) – the byte string to decode
- Returns:
the decoded object
- Return type:
- classmethod from_dict(field_dict: Dict[str, Any]) Self
In addition to the standard initialization of.
my_obj = MyRLP(name1=1, name2=b'\xff')
This method enables initialization with.
my_obj = MyRLP.from_dict({'name1': 1, 'name2': b'\xff'})
In general, the standard initialization is preferred, but some approaches might favor this API, like when using
toolz.functoolz.pipe()
.return eth_utils.toolz.pipe( my_dict, normalize, validate, MyRLP.from_dict, )
- Parameters:
field_dict (dict) – the dictionary of values to initialize with
- Returns:
the new rlp object
- Return type: