2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/router_contact.hpp>
|
2022-07-19 18:22:38 +00:00
|
|
|
|
2021-03-09 22:24:35 +00:00
|
|
|
#include <llarp/dht/key.hpp>
|
2022-07-19 18:22:38 +00:00
|
|
|
#include <llarp/util/time.hpp>
|
|
|
|
#include "common.hpp"
|
2020-01-17 13:22:08 +00:00
|
|
|
|
|
|
|
namespace llarp
|
|
|
|
{
|
|
|
|
void
|
|
|
|
RouterContact_Init(py::module& mod)
|
|
|
|
{
|
2020-04-07 18:38:56 +00:00
|
|
|
py::class_<RouterContact>(mod, "RouterContact")
|
2020-01-17 13:22:08 +00:00
|
|
|
.def(py::init<>())
|
2020-03-07 01:20:11 +00:00
|
|
|
.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()};
|
|
|
|
})
|
2020-01-17 13:22:08 +00:00
|
|
|
.def("ReadFile", &RouterContact::Read)
|
|
|
|
.def("WriteFile", &RouterContact::Write)
|
2020-03-03 19:56:33 +00:00
|
|
|
.def("ToString", &RouterContact::ToString)
|
|
|
|
.def("__str__", &RouterContact::ToString)
|
|
|
|
.def("__repr__", &RouterContact::ToString)
|
2020-03-03 04:15:18 +00:00
|
|
|
.def("Verify", [](const RouterContact* const rc) -> bool {
|
2020-01-17 13:22:08 +00:00
|
|
|
const llarp_time_t now = llarp::time_now_ms();
|
2020-03-03 04:15:18 +00:00
|
|
|
return rc->Verify(now);
|
2020-01-17 13:22:08 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
} // namespace llarp
|