From 6c33d251dfc46d45b4200d0673c5af83fb7b7543 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 26 Aug 2017 15:46:52 +0530 Subject: [PATCH] Reduce src_id/dst_id to 16 bits. --- docs/howitworks.rst | 4 ++-- econtext/core.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/howitworks.rst b/docs/howitworks.rst index 3f597558..b9f5946e 100644 --- a/docs/howitworks.rst +++ b/docs/howitworks.rst @@ -247,9 +247,9 @@ master and slave: +====================+======+======================================================+ | ``hmac`` | 20 | SHA-1 over remaining fields. | +--------------------+------+------------------------------------------------------+ -| ``dst_id`` | 4 | Integer source context ID. | +| ``dst_id`` | 2 | Integer target context ID. | +--------------------+------+------------------------------------------------------+ -| ``src_id`` | 4 | Integer source context ID. | +| ``src_id`` | 2 | Integer source context ID. | +--------------------+------+------------------------------------------------------+ | ``handle`` | 4 | Integer target handle in recipient. | +--------------------+------+------------------------------------------------------+ diff --git a/econtext/core.py b/econtext/core.py index 9a8ee457..6026e424 100644 --- a/econtext/core.py +++ b/econtext/core.py @@ -473,7 +473,7 @@ class Stream(BasicStream): if not buf: return self.on_disconnect(broker) - HEADER_FMT = '>20sLLLLL' + HEADER_FMT = '>20shhLLL' HEADER_LEN = struct.calcsize(HEADER_FMT) MAC_LEN = sha.digest_size @@ -528,7 +528,7 @@ class Stream(BasicStream): """Send `data` to `handle`, and tell the broker we have output. May be called from any thread.""" IOLOG.debug('%r._send(%r)', self, msg) - pkt = struct.pack('>LLLLL', msg.dst_id, msg.src_id, + pkt = struct.pack('>hhLLL', msg.dst_id, msg.src_id, msg.handle, msg.reply_to or 0, len(msg.data) ) + msg.data self._whmac.update(pkt)