2020-03-01 00:34:48 +00:00
|
|
|
#include "common.hpp"
|
|
|
|
|
|
|
|
#include "router_id.hpp"
|
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
void
|
2020-03-07 01:20:11 +00:00
|
|
|
RouterID_Init(py::module& mod)
|
2020-03-01 00:34:48 +00:00
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<RouterID>(mod, "RouterID")
|
|
|
|
.def(
|
|
|
|
"FromHex",
|
2020-06-29 21:46:25 +00:00
|
|
|
[](RouterID* r, const std::string& hex) {
|
|
|
|
if (hex.size() != 2 * r->size() || !lokimq::is_hex(hex))
|
|
|
|
throw std::runtime_error("FromHex requires a 64-digit hex string");
|
|
|
|
lokimq::from_hex(hex.begin(), hex.end(), r->data());
|
2020-04-07 18:38:56 +00:00
|
|
|
})
|
2020-03-01 00:34:48 +00:00
|
|
|
.def("__repr__", &RouterID::ToString)
|
|
|
|
.def("__str__", &RouterID::ToString)
|
2020-03-01 00:42:42 +00:00
|
|
|
.def("ShortString", &RouterID::ShortString)
|
2020-06-17 21:42:22 +00:00
|
|
|
.def("__eq__", [](const RouterID& lhs, const RouterID& rhs) { return lhs == rhs; });
|
2020-03-01 00:34:48 +00:00
|
|
|
}
|
2020-03-07 01:20:11 +00:00
|
|
|
} // namespace llarp
|