gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] [gnunet-python] 03/32: Added filter_known_results, stop fun


From: gnunet
Subject: [GNUnet-SVN] [gnunet-python] 03/32: Added filter_known_results, stop functions to dht. Bug fixes.
Date: Sat, 13 Apr 2019 13:20:20 +0200

This is an automated email from the git hooks/post-receive script.

ng0 pushed a commit to branch master
in repository gnunet-python.

commit 6c2287eb042c560098f0cdcbfb1997b1a62c3cdf
Author: Andrew Cann <address@hidden>
AuthorDate: Sun May 11 02:54:29 2014 +0000

    Added filter_known_results, stop functions to dht. Bug fixes.
---
 .gitignore         |  4 ++++
 example-dht.py     |  4 +++-
 gnunet/__init__.py |  2 +-
 gnunet/dht.py      | 13 +++++++++++++
 4 files changed, 21 insertions(+), 2 deletions(-)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..7e6f516
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,4 @@
+*.swp
+*.swo
+/gnunet/__pycache__
+
diff --git a/example-dht.py b/example-dht.py
index 726e0be..64dd1cb 100755
--- a/example-dht.py
+++ b/example-dht.py
@@ -16,7 +16,9 @@ def result_callback(block_type, key, data, expiry, get_path, 
put_path):
   print("  put_path   == %s" % repr(put_path))
   print("  data       == %s" % repr(data))
 
-gnunet.dht.get_start(result_callback, "test", key, 1, record_route=True)
+req = gnunet.dht.get_start(result_callback, "test", key, 1, record_route=True)
+req.filter_known_results([])
+req.stop()
 
 time.sleep(1)
 
diff --git a/gnunet/__init__.py b/gnunet/__init__.py
index 425ab86..a517180 100644
--- a/gnunet/__init__.py
+++ b/gnunet/__init__.py
@@ -6,7 +6,7 @@ class GNUNetDaemonError(Exception):
 class _Key:
   def __init__(self, arg, subtype, bits):
     if isinstance(arg, subtype):
-      self._data = arg.data
+      self._data = arg._data
     elif isinstance(arg, str):
       self._data = strings.string_to_data(arg)
     else:
diff --git a/gnunet/dht.py b/gnunet/dht.py
index d26b7f2..849f07a 100644
--- a/gnunet/dht.py
+++ b/gnunet/dht.py
@@ -51,6 +51,19 @@ class GetRequest:
     self.callback = callback
     self.record_route = record_route
 
+  def filter_known_results(self, keys):
+    keys = dbus.Array([dbusize(HashCode(key)) for key in list(keys)], 
signature="v")
+    try:
+      sysbus.get_object("gnu.gnunet.dht", 
self._path).filter_known_results(keys, dbus_interface="gnu.gnunet.dht.get")
+    except dbus.DBusException as e:
+      handle_exception(e, "dht", "gnu.gnunet.dht")
+
+  def stop(self):
+    try:
+      sysbus.get_object("gnu.gnunet.dht", 
self._path).stop(dbus_interface="gnu.gnunet.dht.get")
+    except dbus.DBusException as e:
+      handle_exception(e, "dht", "gnu.gnunet.dht")
+
 def put(key, desired_replication_level, block_type, data, expiry=None, 
demultiplex_everywhere=False, record_route=False, bart=False):
   key = dbusize(HashCode(key), True)
   desired_replication_level = dbus.UInt32(desired_replication_level)

-- 
To stop receiving notification emails like this one, please contact
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]