Skip to content
Snippets Groups Projects
Commit bad8bdfe authored by Adrien Béraud's avatar Adrien Béraud
Browse files

python: support 'permanent' argument for put

parent 13194b66
No related branches found
No related tags found
No related merge requests found
...@@ -587,7 +587,7 @@ cdef class DhtRunner(_WithID): ...@@ -587,7 +587,7 @@ cdef class DhtRunner(_WithID):
while pending > 0: while pending > 0:
lock.wait() lock.wait()
return res return res
def put(self, InfoHash key, Value val, done_cb=None): def put(self, InfoHash key, Value val, done_cb=None, permanent=False):
"""Publish a new value on the DHT at key. """Publish a new value on the DHT at key.
key -- the DHT key where to put the value key -- the DHT key where to put the value
...@@ -597,7 +597,7 @@ cdef class DhtRunner(_WithID): ...@@ -597,7 +597,7 @@ cdef class DhtRunner(_WithID):
if done_cb: if done_cb:
cb_obj = {'done':done_cb} cb_obj = {'done':done_cb}
ref.Py_INCREF(cb_obj) ref.Py_INCREF(cb_obj)
self.thisptr.get().put(key._infohash, val._value, cpp.bindDoneCb(done_callback, <void*>cb_obj)) self.thisptr.get().put(key._infohash, val._value, cpp.bindDoneCb(done_callback, <void*>cb_obj), cpp.time_point.max(), permanent)
else: else:
lock = threading.Condition() lock = threading.Condition()
pending = 0 pending = 0
......
...@@ -26,7 +26,7 @@ from libc.string cimport const_char, const_uchar ...@@ -26,7 +26,7 @@ from libc.string cimport const_char, const_uchar
ctypedef uint16_t in_port_t ctypedef uint16_t in_port_t
ctypedef unsigned short int sa_family_t; ctypedef unsigned short int sa_family_t;
cdef extern from "<iostream>" namespace "std::chrono" nogil: cdef extern from "<chrono>" namespace "std::chrono" nogil:
cdef cppclass duration[ulong]: cdef cppclass duration[ulong]:
duration() except + duration() except +
...@@ -59,6 +59,13 @@ cdef extern from "<future>" namespace "std" nogil: ...@@ -59,6 +59,13 @@ cdef extern from "<future>" namespace "std" nogil:
bool valid() const bool valid() const
shared_future[T] share() shared_future[T] share()
cdef extern from "opendht/utils.h" namespace "dht":
cdef cppclass time_point:
@staticmethod
time_point min() const
@staticmethod
time_point max() const
cdef extern from "opendht/infohash.h" namespace "dht": cdef extern from "opendht/infohash.h" namespace "dht":
cdef cppclass InfoHash: cdef cppclass InfoHash:
InfoHash() except + InfoHash() except +
...@@ -254,7 +261,7 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht": ...@@ -254,7 +261,7 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht":
string getRoutingTablesLog(sa_family_t af) const string getRoutingTablesLog(sa_family_t af) const
string getSearchesLog(sa_family_t af) const string getSearchesLog(sa_family_t af) const
void get(InfoHash key, GetCallback get_cb, DoneCallback done_cb, nullptr_t f, Where w) void get(InfoHash key, GetCallback get_cb, DoneCallback done_cb, nullptr_t f, Where w)
void put(InfoHash key, shared_ptr[Value] val, DoneCallback done_cb) void put(InfoHash key, shared_ptr[Value] val, DoneCallback done_cb, time_point created, bool permanent)
ListenToken listen(InfoHash key, ValueCallback get_cb) ListenToken listen(InfoHash key, ValueCallback get_cb)
void cancelListen(InfoHash key, SharedListenToken token) void cancelListen(InfoHash key, SharedListenToken token)
vector[unsigned] getNodeMessageStats(bool i) vector[unsigned] getNodeMessageStats(bool i)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment