commit cbfd53251998531a3592aedc2ed9ebae177d55d9 Author: Dave Rolek dmr-x@riseup.net Date: Sun May 27 19:48:40 2018 +0000
Refactor to use split() helper in a few cases that didn't
There are still a few cases outside stem.client that could be refactored to use the split function. --- stem/client/cell.py | 3 ++- stem/client/datatype.py | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/stem/client/cell.py b/stem/client/cell.py index 4718a3a6..9f7e8447 100644 --- a/stem/client/cell.py +++ b/stem/client/cell.py @@ -478,7 +478,8 @@ class CreatedFastCell(CircuitCell): if len(content) != HASH_LEN * 2: raise ValueError('Key material and derivatived key should be %i bytes, but was %i' % (HASH_LEN * 2, len(content)))
- return CreatedFastCell(circ_id, content[HASH_LEN:], content[:HASH_LEN]) + key_material, derivative_key = split(content, HASH_LEN) + return CreatedFastCell(circ_id, derivative_key, key_material)
def __hash__(self): return _hash_attr(self, 'circ_id', 'derivative_key', 'key_material') diff --git a/stem/client/datatype.py b/stem/client/datatype.py index 9812ced0..59b89bd6 100644 --- a/stem/client/datatype.py +++ b/stem/client/datatype.py @@ -357,7 +357,9 @@ class Size(Field): return struct.unpack(self.format, packed)[0]
def pop(self, packed): - return self.unpack(packed[:self.size]), packed[self.size:] + to_unpack, remainder = split(packed, self.size) + + return self.unpack(to_unpack), remainder
class Address(Field):
tor-commits@lists.torproject.org