You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lokinet/pybind/llarp/dht/dht_types.cpp

28 lines
658 B
C++

#include <dht/key.hpp>
#include "common.hpp"
#include <pybind11/operators.h>
namespace llarp
{
namespace dht
{
void
DHTTypes_Init(py::module& mod)
{
py::class_< Key_t >(mod, "DHTKey")
.def(py::self == py::self)
.def(py::self < py::self)
.def(py::self ^ py::self)
.def("distance",
[](const Key_t* const lhs, const Key_t* const rhs) {
return *lhs ^ *rhs;
})
.def("ShortString", [](const Key_t* const key) {
return llarp::RouterID(key->as_array()).ShortString();
});
}
} // namespace dht
} // namespace llarp