diff --git a/python/opendht.pyx b/python/opendht.pyx index 75400685..e960326b 100644 --- a/python/opendht.pyx +++ b/python/opendht.pyx @@ -118,6 +118,18 @@ cdef class Value(object): self._value.reset(new cpp.Value(val, len(val))) def __str__(self): return self._value.get().toString().decode() + property owner: + def __get__(self): + h = InfoHash() + h._infohash = self._value.get().owner.getId() + return h + property recipient: + def __get__(self): + h = InfoHash() + h._infohash = self._value.get().recipient + return h + def __set__(self, InfoHash h): + self._value.get().recipient = h._infohash property data: def __get__(self): return string(self._value.get().data.data(), self._value.get().data.size()) diff --git a/python/opendht_cpp.pxd b/python/opendht_cpp.pxd index c7ac337a..23cde35b 100644 --- a/python/opendht_cpp.pxd +++ b/python/opendht_cpp.pxd @@ -39,14 +39,6 @@ cdef extern from "opendht/infohash.h" namespace "dht": @staticmethod InfoHash getRandom() -cdef extern from "opendht/value.h" namespace "dht": - cdef cppclass Value: - Value() except + - Value(vector[uint8_t]) except + - Value(const uint8_t* dat_ptr, size_t dat_len) except + - string toString() const - vector[uint8_t] data - cdef extern from "opendht/crypto.h" namespace "dht::crypto": ctypedef pair[shared_ptr[PrivateKey], shared_ptr[Certificate]] Identity cdef Identity generateIdentity(string name, Identity ca, unsigned bits) @@ -63,6 +55,18 @@ cdef extern from "opendht/crypto.h" namespace "dht::crypto": Certificate() InfoHash getId() const +cdef extern from "opendht/value.h" namespace "dht": + cdef cppclass Value: + Value() except + + Value(vector[uint8_t]) except + + Value(const uint8_t* dat_ptr, size_t dat_len) except + + string toString() const + uint64_t id + PublicKey owner + InfoHash recipient + vector[uint8_t] data + string user_type + cdef extern from "opendht/dht.h" namespace "dht": cdef cppclass Node: Node() except +