lokinet/llarp/rpc.hpp

68 lines
1009 B
C++
Raw Normal View History

2018-10-19 11:41:36 +00:00
#ifndef LLARP_RPC_HPP
#define LLARP_RPC_HPP
#include <crypto.hpp>
#include <ev.h>
#include <time.hpp>
2018-10-19 11:41:36 +00:00
#include <string>
2018-11-01 12:47:14 +00:00
#include <functional>
2018-10-19 11:41:36 +00:00
namespace llarp
{
struct Router;
2018-10-19 11:41:36 +00:00
namespace rpc
{
struct ServerImpl;
2018-11-01 12:47:14 +00:00
/// jsonrpc server
2018-10-19 11:41:36 +00:00
struct Server
{
Server(llarp::Router* r);
2018-10-19 11:41:36 +00:00
~Server();
bool
Start(const std::string& bindaddr);
/// stop and close
void
Stop();
2018-10-19 11:41:36 +00:00
private:
ServerImpl* m_Impl;
};
2018-11-01 12:47:14 +00:00
struct CallerImpl;
/// jsonrpc caller
struct Caller
{
Caller(llarp::Router* r);
2018-11-01 12:47:14 +00:00
~Caller();
/// start with jsonrpc endpoint address
bool
Start(const std::string& remote);
/// stop and close
void
Stop();
/// test if a router is valid
2018-11-21 17:46:33 +00:00
bool
VerifyRouter(const llarp::PubKey& pk);
/// do per second tick
2018-11-01 12:47:14 +00:00
void
2018-11-21 17:46:33 +00:00
Tick(llarp_time_t now);
2018-11-01 12:47:14 +00:00
private:
CallerImpl* m_Impl;
};
2018-10-19 11:41:36 +00:00
} // namespace rpc
} // namespace llarp
#endif