diff --git a/python/opendht.pyx b/python/opendht.pyx index 1dcfc773fb11619ec8c7575dadbcb787663ab0af..6b4af8ffe606968b6612daa853c770660cef66ba 100644 --- a/python/opendht.pyx +++ b/python/opendht.pyx @@ -587,7 +587,7 @@ cdef class DhtRunner(_WithID): while pending > 0: lock.wait() 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. key -- the DHT key where to put the value @@ -597,7 +597,7 @@ cdef class DhtRunner(_WithID): if done_cb: cb_obj = {'done':done_cb} 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: lock = threading.Condition() pending = 0 diff --git a/python/opendht_cpp.pxd b/python/opendht_cpp.pxd index 4b9bd41a31eb4b51165929f8b4d9c12986597755..e2c4e74a8258270af9e0a7248eaadba8bdebbbd0 100644 --- a/python/opendht_cpp.pxd +++ b/python/opendht_cpp.pxd @@ -26,7 +26,7 @@ from libc.string cimport const_char, const_uchar ctypedef uint16_t in_port_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]: duration() except + @@ -59,6 +59,13 @@ cdef extern from "<future>" namespace "std" nogil: bool valid() const 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 cppclass InfoHash: InfoHash() except + @@ -254,7 +261,7 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht": string getRoutingTablesLog(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 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) void cancelListen(InfoHash key, SharedListenToken token) vector[unsigned] getNodeMessageStats(bool i)