lokinet/pybind/llarp/router_id.cpp
Thomas Winget 7caa87862e standardize include format and pragma once
All #ifndef guards on headers have been removed, I think,
in favor of #pragma once

Headers are now included as `#include "filename"` if the included file
resides in the same directory as the file including it, or any
subdirectory therein.  Otherwise they are included as
`#include <project/top/dir/relative/path/filename>`

The above does not include system/os headers.
2021-03-09 19:01:41 -05:00

24 lines
749 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() || !oxenmq::is_hex(hex))
throw std::runtime_error("FromHex requires a 64-digit hex string");
oxenmq::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