Decentralised Art Server
High-performance C++ backend that exposes HTML interface and a secure REST API for managing Performative Transactions entities
 
Loading...
Searching...
No Matches
rpc_client.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <algorithm>
4#include <atomic>
5#include <cstdint>
6#include <string>
7#include <utility>
8
9#include <nlohmann/json.hpp>
10
11namespace dcn::events
12{
13 class RpcClient final
14 {
15 public:
17 std::string rpc_url,
18 unsigned int rpc_timeout_ms);
19 ~RpcClient();
20
21 RpcClient(const RpcClient &) = delete;
22 RpcClient & operator=(const RpcClient &) = delete;
23 RpcClient(RpcClient &&) = delete;
25
26 void stop();
27 std::uint64_t callCount() const;
28 nlohmann::json callSync(
29 const std::string & method,
30 nlohmann::json params) const;
31
32 private:
33 static nlohmann::json _callBlocking(
34 const std::string & rpc_url,
35 const std::string & method_name,
36 unsigned int timeout_seconds,
37 nlohmann::json request);
38
39 private:
40 const std::string _rpc_url;
41 const unsigned int _rpc_timeout_ms;
42
43 mutable std::atomic<std::uint64_t> _call_count{0};
44 };
45}
Definition rpc_client.hpp:14
RpcClient & operator=(const RpcClient &)=delete
RpcClient & operator=(RpcClient &&)=delete
void stop()
Definition rpc_client.cpp:25
RpcClient(RpcClient &&)=delete
~RpcClient()
Definition rpc_client.cpp:20
nlohmann::json callSync(const std::string &method, nlohmann::json params) const
Definition rpc_client.cpp:35
RpcClient(const RpcClient &)=delete
std::uint64_t callCount() const
Definition rpc_client.cpp:30
Definition decoded_event.hpp:11