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.
This commit is contained in:
Philip Trauner 2016-10-15 17:54:01 +02:00
parent 2f17bd41ff
commit d703f018b8
2 changed files with 6 additions and 4 deletions

View file

@ -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()

View file

@ -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