mirror of
https://github.com/oxen-io/lokinet.git
synced 2024-11-15 12:13:24 +00:00
d02558350a
- Update oxen-mq submodule to latest stable - Add oxen-encoding submodule - Convert all oxenmq encoding usage to oxenc - Modernize cmake handling of oxenmq/oxenc
24 lines
747 B
C++
24 lines
747 B
C++
#include <common.hpp>
|
|
|
|
#include <llarp/router_id.hpp>
|
|
|
|
namespace llarp
|
|
{
|
|
void
|
|
RouterID_Init(py::module& mod)
|
|
{
|
|
py::class_<RouterID>(mod, "RouterID")
|
|
.def(
|
|
"FromHex",
|
|
[](RouterID* r, const std::string& hex) {
|
|
if (hex.size() != 2 * r->size() || !oxenc::is_hex(hex))
|
|
throw std::runtime_error("FromHex requires a 64-digit hex string");
|
|
oxenc::from_hex(hex.begin(), hex.end(), r->data());
|
|
})
|
|
.def("__repr__", &RouterID::ToString)
|
|
.def("__str__", &RouterID::ToString)
|
|
.def("ShortString", &RouterID::ShortString)
|
|
.def("__eq__", [](const RouterID& lhs, const RouterID& rhs) { return lhs == rhs; });
|
|
}
|
|
} // namespace llarp
|