lokinet/pybind/llarp/router_contact.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

33 lines
1.0 KiB
C++

#include <llarp/router_contact.hpp>
#include <llarp/dht/key.hpp>
#include <common.hpp>
namespace llarp
{
void
RouterContact_Init(py::module& mod)
{
py::class_<RouterContact>(mod, "RouterContact")
.def(py::init<>())
.def_property_readonly(
"routerID",
[](const RouterContact* const rc) -> llarp::RouterID {
return llarp::RouterID(rc->pubkey);
})
.def_property_readonly(
"AsDHTKey",
[](const RouterContact* const rc) -> llarp::dht::Key_t {
return llarp::dht::Key_t{rc->pubkey.as_array()};
})
.def("ReadFile", &RouterContact::Read)
.def("WriteFile", &RouterContact::Write)
.def("ToString", &RouterContact::ToString)
.def("__str__", &RouterContact::ToString)
.def("__repr__", &RouterContact::ToString)
.def("Verify", [](const RouterContact* const rc) -> bool {
const llarp_time_t now = llarp::time_now_ms();
return rc->Verify(now);
});
}
} // namespace llarp