diff options
Diffstat (limited to 'gnunet/dht.py')
-rw-r--r-- | gnunet/dht.py | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/gnunet/dht.py b/gnunet/dht.py index b97c7a1..e9aa525 100644 --- a/gnunet/dht.py +++ b/gnunet/dht.py | |||
@@ -30,9 +30,12 @@ class GetResult(threading.Thread): | |||
30 | 30 | ||
31 | if request: | 31 | if request: |
32 | if request.record_route: | 32 | if request.record_route: |
33 | request.callback(self.block_type, self.key, self.data, self.expiry, get_path=self.get_path, put_path=self.put_path) | 33 | request.callback(self.block_type, self.key, self.data, |
34 | self.expiry, get_path=self.get_path, | ||
35 | put_path=self.put_path) | ||
34 | else: | 36 | else: |
35 | request.callback(self.block_type, self.key, self.data, self.expiry) | 37 | request.callback(self.block_type, self.key, self.data, |
38 | self.expiry) | ||
36 | 39 | ||
37 | 40 | ||
38 | def _result(expiry, key, get_path, put_path, block_type, data, path): | 41 | def _result(expiry, key, get_path, put_path, block_type, data, path): |
@@ -44,7 +47,8 @@ def _result(expiry, key, get_path, put_path, block_type, data, path): | |||
44 | data = bytearray(data) | 47 | data = bytearray(data) |
45 | GetResult(expiry, key, get_path, put_path, block_type, data, path) | 48 | GetResult(expiry, key, get_path, put_path, block_type, data, path) |
46 | 49 | ||
47 | sysbus.add_signal_receiver(_result, "result", "gnu.gnunet.dht.get", "gnu.gnunet.dht", path_keyword="path") | 50 | sysbus.add_signal_receiver(_result, "result", "gnu.gnunet.dht.get", |
51 | "gnu.gnunet.dht", path_keyword="path") | ||
48 | 52 | ||
49 | 53 | ||
50 | class GetRequest: | 54 | class GetRequest: |
@@ -54,7 +58,8 @@ class GetRequest: | |||
54 | self.record_route = record_route | 58 | self.record_route = record_route |
55 | 59 | ||
56 | def filter_known_results(self, keys): | 60 | def filter_known_results(self, keys): |
57 | keys = dbus.Array([dbusize(HashCode(key)) for key in list(keys)], signature="v") | 61 | keys = dbus.Array([dbusize(HashCode(key)) |
62 | for key in list(keys)], signature="v") | ||
58 | try: | 63 | try: |
59 | sysbus.get_object("gnu.gnunet.dht", self._path).filter_known_results(keys, dbus_interface="gnu.gnunet.dht.get") | 64 | sysbus.get_object("gnu.gnunet.dht", self._path).filter_known_results(keys, dbus_interface="gnu.gnunet.dht.get") |
60 | except dbus.DBusException as e: | 65 | except dbus.DBusException as e: |
@@ -67,7 +72,8 @@ class GetRequest: | |||
67 | handle_exception(e, "dht", "gnu.gnunet.dht") | 72 | handle_exception(e, "dht", "gnu.gnunet.dht") |
68 | 73 | ||
69 | 74 | ||
70 | def put(key, desired_replication_level, block_type, data, expiry=None, demultiplex_everywhere=False, record_route=False, bart=False): | 75 | def put(key, desired_replication_level, block_type, data, expiry=None, |
76 | demultiplex_everywhere=False, record_route=False, bart=False): | ||
71 | key = dbusize(HashCode(key), True) | 77 | key = dbusize(HashCode(key), True) |
72 | desired_replication_level = dbus.UInt32(desired_replication_level) | 78 | desired_replication_level = dbus.UInt32(desired_replication_level) |
73 | if block_type not in block.TYPES: | 79 | if block_type not in block.TYPES: |
@@ -94,7 +100,8 @@ def put(key, desired_replication_level, block_type, data, expiry=None, demultipl | |||
94 | handle_exception(e, "dht", "gnu.gnunet.dht") | 100 | handle_exception(e, "dht", "gnu.gnunet.dht") |
95 | 101 | ||
96 | 102 | ||
97 | def get_start(callback, block_type, key, desired_replication_level, demultiplex_everywhere=False, record_route=False, bart=False): | 103 | def get_start(callback, block_type, key, desired_replication_level, |
104 | demultiplex_everywhere=False, record_route=False, bart=False): | ||
98 | if block_type not in block.TYPES: | 105 | if block_type not in block.TYPES: |
99 | raise ValueError("'block_type' must be one of %s" % block.TYPES) | 106 | raise ValueError("'block_type' must be one of %s" % block.TYPES) |
100 | block_type = dbus.String(block_type, variant_level=1) | 107 | block_type = dbus.String(block_type, variant_level=1) |