[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [stem/master] Add convenience method for packing payload of a RELAY cell



commit aa3b674ef3c7d22c16c6480937531f38b208a0c1
Author: Dave Rolek <dmr-x@xxxxxxxxxx>
Date:   Fri Aug 10 19:55:22 2018 +0000

    Add convenience method for packing payload of a RELAY cell
    
    There may be a bit too much going on here - i.e. these methods may not
    be anything but a bit redundant - but things will get trimmed down later
    when the API is better worked out.
---
 stem/client/cell.py | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/stem/client/cell.py b/stem/client/cell.py
index 381a7387..39a729f1 100644
--- a/stem/client/cell.py
+++ b/stem/client/cell.py
@@ -424,7 +424,7 @@ class RelayCell(CircuitCell):
     return digest
 
   def pack(self, link_protocol):
-    payload = RelayCell._pack_payload(self.command_int, self.recognized, self.stream_id, self.digest, len(self.data), self.data, self.unused)
+    payload = self.pack_payload()
 
     return RelayCell._pack(link_protocol, payload, unused = b'', circ_id = self.circ_id)
 
@@ -456,6 +456,17 @@ class RelayCell(CircuitCell):
 
     return command, recognized, stream_id, digest, data_len, data, unused
 
+  def pack_payload(self, **kwargs):
+    """
+    Convenience method for running _pack_payload on self.
+
+    :param bool pad_remaining: (optional, defaults to **True**) pads up to payload size if **True**
+
+    :returns: **bytes** with the packed payload
+    """
+
+    return RelayCell._pack_payload(self.command_int, self.recognized, self.stream_id, self.digest, len(self.data), self.data, self.unused, **kwargs)
+
   @staticmethod
   def _pack_payload(command_int, recognized, stream_id, digest, data_len, data, unused = b'', pad_remainder = True):
     """



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits