[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Add serialize_versions helper
commit 222bff37e5fb896341a3a4157c5608d44b8315e0
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Wed Jan 3 13:11:19 2018 -0800
Add serialize_versions helper
Probably not what we're gonna have long term, but lets start moving some
endosome functionality over.
---
stem/client.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/stem/client.py b/stem/client.py
index 4da12bba..8c5ad506 100644
--- a/stem/client.py
+++ b/stem/client.py
@@ -31,6 +31,8 @@ providing higher level functions in much the same way as our
Relay - Connection with a relay's ORPort.
"""
+import struct
+
from stem.util import enum
PackType = enum.Enum(
@@ -46,3 +48,15 @@ class Relay(object):
Connection with a `Tor relay's ORPort
<https://gitweb.torproject.org/torspec.git/tree/tor-spec.txt>`_.
"""
+
+
+def serialize_versions(versions):
+ """
+ Provides the payload for a series of link versions.
+
+ :param list versions: link versions to serialize
+
+ :returns: **bytes** with a payload for these versions
+ """
+
+ return b''.join([struct.pack(PackType.SHORT, v) for v in versions])
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits