mirror of
https://github.com/savoirfairelinux/opendht.git
synced 2026-11-08 04:21:51 +00:00
add node cache, split dhtrunner.h from dht.h
This commit is contained in:
1 parent
98a3960bf8
commit
8cc53b1751
20 files changed
+602
-374
No files matched your search
+6
-6
@@ -239,9 +239,9 @@ cdef class Identity(object):
|
||||
return c
|
||||
|
||||
cdef class DhtConfig(object):
|
||||
cdef cpp.Config _config
|
||||
cdef cpp.DhtRunnerConfig _config
|
||||
def __init__(self):
|
||||
self._config = cpp.Config()
|
||||
self._config = cpp.DhtRunnerConfig()
|
||||
self._config.threaded = True;
|
||||
def setIdentity(self, Identity id):
|
||||
self._config.dht_config.id = id._id
|
||||
@@ -276,7 +276,7 @@ cdef class DhtRunner(_WithID):
|
||||
def shutdown(self, shutdown_cb=None):
|
||||
cb_obj = {'shutdown':shutdown_cb}
|
||||
ref.Py_INCREF(cb_obj)
|
||||
self.thisptr.shutdown(cpp.Dht.bindShutdownCb(shutdown_callback, <void*>cb_obj))
|
||||
self.thisptr.shutdown(cpp.bindShutdownCb(shutdown_callback, <void*>cb_obj))
|
||||
def enableLogging(self):
|
||||
cpp.enableLogging(self.thisptr[0])
|
||||
def disableLogging(self):
|
||||
@@ -308,7 +308,7 @@ cdef class DhtRunner(_WithID):
|
||||
if get_cb:
|
||||
cb_obj = {'get':get_cb, 'done':done_cb}
|
||||
ref.Py_INCREF(cb_obj)
|
||||
self.thisptr.get(key._infohash, cpp.Dht.bindGetCb(get_callback, <void*>cb_obj), cpp.Dht.bindDoneCb(done_callback, <void*>cb_obj))
|
||||
self.thisptr.get(key._infohash, cpp.bindGetCb(get_callback, <void*>cb_obj), cpp.bindDoneCb(done_callback, <void*>cb_obj))
|
||||
else:
|
||||
lock = threading.Condition()
|
||||
pending = 0
|
||||
@@ -337,7 +337,7 @@ cdef class DhtRunner(_WithID):
|
||||
"""
|
||||
cb_obj = {'done':done_cb}
|
||||
ref.Py_INCREF(cb_obj)
|
||||
self.thisptr.put(key._infohash, val._value, cpp.Dht.bindDoneCb(done_callback, <void*>cb_obj))
|
||||
self.thisptr.put(key._infohash, val._value, cpp.bindDoneCb(done_callback, <void*>cb_obj))
|
||||
def listen(self, InfoHash key, get_cb):
|
||||
t = ListenToken()
|
||||
t._h = key._infohash
|
||||
@@ -345,7 +345,7 @@ cdef class DhtRunner(_WithID):
|
||||
t._cb['cb'] = cb_obj
|
||||
# avoid the callback being destructed if the token is destroyed
|
||||
ref.Py_INCREF(cb_obj)
|
||||
t._t = self.thisptr.listen(t._h, cpp.Dht.bindGetCb(get_callback, <void*>cb_obj)).share()
|
||||
t._t = self.thisptr.listen(t._h, cpp.bindGetCb(get_callback, <void*>cb_obj)).share()
|
||||
return t
|
||||
def cancelListen(self, ListenToken token):
|
||||
self.thisptr.cancelListen(token._h, token._t)
|
||||
|
||||
+28
-32
@@ -91,41 +91,37 @@ cdef extern from "opendht/value.h" namespace "dht":
|
||||
vector[uint8_t] data
|
||||
string user_type
|
||||
|
||||
cdef extern from "opendht/dht.h" namespace "dht":
|
||||
cdef extern from "opendht/node.h" namespace "dht":
|
||||
cdef cppclass Node:
|
||||
Node() except +
|
||||
InfoHash getId() const
|
||||
string getAddrStr() const
|
||||
bool isExpired() const
|
||||
|
||||
cdef extern from "opendht/callbacks.h" namespace "dht":
|
||||
ctypedef void (*ShutdownCallbackRaw)(void *user_data)
|
||||
ctypedef bool (*GetCallbackRaw)(shared_ptr[Value] values, void *user_data)
|
||||
ctypedef void (*DoneCallbackRaw)(bool done, vector[shared_ptr[Node]]* nodes, void *user_data)
|
||||
cdef cppclass Dht:
|
||||
cppclass Config:
|
||||
InfoHash node_id
|
||||
bool is_bootstrap
|
||||
cppclass ShutdownCallback:
|
||||
ShutdownCallback() except +
|
||||
cppclass GetCallback:
|
||||
GetCallback() except +
|
||||
#GetCallback(GetCallbackRaw cb, void *user_data) except +
|
||||
cppclass DoneCallback:
|
||||
DoneCallback() except +
|
||||
#DoneCallback(DoneCallbackRaw, void *user_data) except +
|
||||
Dht() except +
|
||||
InfoHash getNodeId() const
|
||||
@staticmethod
|
||||
ShutdownCallback bindShutdownCb(ShutdownCallbackRaw cb, void *user_data)
|
||||
@staticmethod
|
||||
GetCallback bindGetCb(GetCallbackRaw cb, void *user_data)
|
||||
@staticmethod
|
||||
DoneCallback bindDoneCb(DoneCallbackRaw cb, void *user_data)
|
||||
|
||||
cdef extern from "opendht/dht.h" namespace "dht":
|
||||
cdef cppclass SecureDht:
|
||||
cppclass Config:
|
||||
Dht.Config node_config
|
||||
Identity id
|
||||
cppclass ShutdownCallback:
|
||||
ShutdownCallback() except +
|
||||
cppclass GetCallback:
|
||||
GetCallback() except +
|
||||
#GetCallback(GetCallbackRaw cb, void *user_data) except +
|
||||
cppclass DoneCallback:
|
||||
DoneCallback() except +
|
||||
#DoneCallback(DoneCallbackRaw, void *user_data) except +
|
||||
|
||||
cdef ShutdownCallback bindShutdownCb(ShutdownCallbackRaw cb, void *user_data)
|
||||
cdef GetCallback bindGetCb(GetCallbackRaw cb, void *user_data)
|
||||
cdef DoneCallback bindDoneCb(DoneCallbackRaw cb, void *user_data)
|
||||
|
||||
cppclass Config:
|
||||
InfoHash node_id
|
||||
bool is_bootstrap
|
||||
cppclass SecureDhtConfig:
|
||||
Config node_config
|
||||
Identity id
|
||||
|
||||
cdef extern from "opendht/dhtrunner.h" namespace "dht":
|
||||
ctypedef future[size_t] ListenToken
|
||||
@@ -133,7 +129,7 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht":
|
||||
cdef cppclass DhtRunner:
|
||||
DhtRunner() except +
|
||||
cppclass Config:
|
||||
SecureDht.Config dht_config
|
||||
SecureDhtConfig dht_config
|
||||
bool threaded
|
||||
InfoHash getId() const
|
||||
InfoHash getNodeId() const
|
||||
@@ -141,18 +137,18 @@ cdef extern from "opendht/dhtrunner.h" namespace "dht":
|
||||
void run(in_port_t, Config config)
|
||||
void run(const char*, const char*, const char*, Config config)
|
||||
void join()
|
||||
void shutdown(Dht.ShutdownCallback)
|
||||
void shutdown(ShutdownCallback)
|
||||
bool isRunning()
|
||||
string getStorageLog() const
|
||||
string getRoutingTablesLog(sa_family_t af) const
|
||||
string getSearchesLog(sa_family_t af) const
|
||||
void get(InfoHash key, Dht.GetCallback get_cb, Dht.DoneCallback done_cb)
|
||||
void put(InfoHash key, shared_ptr[Value] val, Dht.DoneCallback done_cb)
|
||||
ListenToken listen(InfoHash key, Dht.GetCallback get_cb)
|
||||
void get(InfoHash key, GetCallback get_cb, DoneCallback done_cb)
|
||||
void put(InfoHash key, shared_ptr[Value] val, DoneCallback done_cb)
|
||||
ListenToken listen(InfoHash key, GetCallback get_cb)
|
||||
void cancelListen(InfoHash key, SharedListenToken token)
|
||||
vector[unsigned] getNodeMessageStats(bool i)
|
||||
|
||||
ctypedef DhtRunner.Config Config
|
||||
ctypedef DhtRunner.Config DhtRunnerConfig
|
||||
|
||||
cdef extern from "opendht/log.h" namespace "dht::log":
|
||||
void enableLogging(DhtRunner& dht)
|
||||
|
||||
Reference in new issue
Block a user