-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnkn.h
50 lines (37 loc) · 1.01 KB
/
nkn.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef NKN_H
#define NKN_H
#include <iomanip>
#include <boost/asio.hpp>
#include "include/crypto/ed25519.h"
#include "include/wallet.h"
#include "pb/tuna.pb.h"
#include "smux-cpp/encoding.h"
#include "base64.hpp"
using boost::asio::ip::tcp;
using namespace NKN;
struct node_info {
std::string ip;
uint port;
uint service_id;
std::string price;
std::string beneficiary_addr;
std::string pubkey;
};
struct service {
uint service_id;
uint port;
std::string service_name;
};
shared_ptr<node_info> get_node_info_from_pubsub(const string &topic, const string &pk);
vector<shared_ptr<node_info>> get_node_info_from_metadata(char* metadata);
uint32_t read_var_bytes(std::shared_ptr<tcp::socket> s, char *buf);
void write_var_bytes(std::shared_ptr<tcp::socket> s, char *buf, std::size_t len);
template<typename T>
inline std::string ToString(T value) {
std::stringstream out;
out << std::fixed;
out << std::setprecision(8);
out << value;
return out.str();
}
#endif // NKN_H