diff options
Diffstat (limited to 'example-dht.py')
-rwxr-xr-x | example-dht.py | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/example-dht.py b/example-dht.py new file mode 100755 index 0000000..726e0be --- /dev/null +++ b/example-dht.py | |||
@@ -0,0 +1,22 @@ | |||
1 | #!/usr/bin/python3 | ||
2 | |||
3 | import gnunet.dht | ||
4 | import time | ||
5 | |||
6 | key = gnunet.HashCode("RMKN0U1JNA3PVCL148D6JI0STVG94A8A65INOK849CF1RT6BGF26AMMT14GMDMNRDFSJRJME6IKJ3LDFBUL2R1TPQJE64I55I32QN5G") | ||
7 | |||
8 | gnunet.dht.put(key, 1, "test", b"hello") | ||
9 | |||
10 | def result_callback(block_type, key, data, expiry, get_path, put_path): | ||
11 | print("Got result from DHT") | ||
12 | print(" block_type == %s" % repr(block_type)) | ||
13 | print(" key == %s" % repr(key)) | ||
14 | print(" expiry == %s" % repr(expiry)) | ||
15 | print(" get_path == %s" % repr(get_path)) | ||
16 | print(" put_path == %s" % repr(put_path)) | ||
17 | print(" data == %s" % repr(data)) | ||
18 | |||
19 | gnunet.dht.get_start(result_callback, "test", key, 1, record_route=True) | ||
20 | |||
21 | time.sleep(1) | ||
22 | |||