From 8638b98179b59ee4666521a1b63aee3b887efa17 Mon Sep 17 00:00:00 2001 From: Philip Trauner Date: Sun, 11 Sep 2016 20:32:13 +0200 Subject: [PATCH] Removed max route length and added route ids Routes are now handled as numbers by the networking layer. This changes requires the first message to be a dict of all routes with their associated ids. This way only 2 bytes are used per message, not 16 like before. --- Shared/Routing.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Shared/Routing.py b/Shared/Routing.py index 8651ad7..524da7c 100644 --- a/Shared/Routing.py +++ b/Shared/Routing.py @@ -1,5 +1,3 @@ -import ESock - BROADCAST = 0 ROUTE = 1 SOCK = 2 @@ -38,8 +36,6 @@ def create_routes(routes, handler): routes = routes.copy() reverse_routes = {} for prefix in routes: - if len(prefix) > ESock.MAX_ROUTE_LENGTH: - raise InvalidRouteLength("'%s' is too long (maximum: %d)" % (prefix, ESock.MAX_ROUTE_LENGTH)) if type(routes[prefix]) is tuple or type(routes[prefix]) is list: routes[prefix] = routes[prefix][0](**routes[prefix][1]) reverse_routes[routes[prefix]] = prefix @@ -53,4 +49,11 @@ def create_routes(routes, handler): routes[prefix].route = reverse_routes[routes[prefix]] routes[prefix].PATCHED = True routes[prefix].start(handler) - return routes \ No newline at end of file + return routes + + +def create_exchange_map(routes): + exchange_map = {"meta" : -1} + for route in range(len(routes)): + exchange_map[route] = routes[route] + return exchange_map \ No newline at end of file