From d703f018b815e0b1a54dee51f68cc50172c31d90 Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Sat, 15 Oct 2016 17:54:01 +0200 Subject: [PATCH] Changed encoding and meta route index Encoding is now BH (data type, route) which should be more than enough for now. Because H is not signed the meta route is now always on position 0. --- Shared/Highway.py | 6 ++++-- Shared/Routing.py | 4 ++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Shared/Highway.py b/Shared/Highway.py index 62da673..24ba2bf 100644 --- a/Shared/Highway.py +++ b/Shared/Highway.py @@ -29,7 +29,9 @@ INVALID_METADATA_LAYOUT = 2 INVALID_DATA_TYPE = 3 META_ROUTE = "meta" -PACK_FORMAT = "Bh" +META_ROUTE_INDEX = 0 + +PACK_FORMAT = "BH" class ConvertFailedError(ValueError): @@ -161,7 +163,7 @@ class Shared: # Peer routes have not been received yet. As per convention the meta route # has to exist and we need it for our first send to succeed (otherwise it # would fail during route lookup). - self.peer_exchange_routes = {-1 : META_ROUTE} + self.peer_exchange_routes = {META_ROUTE_INDEX : META_ROUTE} self.peer_reverse_exchange_routes = reverse_dict(self.peer_exchange_routes) try: self.post_opened() diff --git a/Shared/Routing.py b/Shared/Routing.py index 6472aab..90c36de 100644 --- a/Shared/Routing.py +++ b/Shared/Routing.py @@ -36,8 +36,8 @@ def launch_routes(created_routes, handler): def create_exchange_map(routes): - exchange_map = {-1 : "meta"} - exchange_id = 0 + exchange_map = {0 : "meta"} + exchange_id = 1 for route in routes: if route != "meta": exchange_map[exchange_id] = route