2021-03-09 22:24:35 +00:00
|
|
|
#include <common.hpp>
|
2020-03-01 00:34:48 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/router_id.hpp>
|
2020-03-01 00:34:48 +00:00
|
|
|
|
|
|
|
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) {
|
2022-02-17 18:44:31 +00:00
|
|
|
if (hex.size() != 2 * r->size() || !oxenc::is_hex(hex))
|
2020-06-29 21:46:25 +00:00
|
|
|
throw std::runtime_error("FromHex requires a 64-digit hex string");
|
2022-02-17 18:44:31 +00:00
|
|
|
oxenc::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
|