renamed several items in dht value data

pull/2/head
Tom Early 3 years ago
parent ba2042a8e7
commit 86dbce8f15

@ -544,7 +544,7 @@ void CReflector::PutDHTPeers()
{ {
const std::string cs(g_Configure.GetString(g_Keys.names.callsign)); const std::string cs(g_Configure.GetString(g_Keys.names.callsign));
// load it up // load it up
SUrfdPeers0 p; SUrfdPeers1 p;
time(&p.timestamp); time(&p.timestamp);
p.sequence = peers_put_count++; p.sequence = peers_put_count++;
auto peers = GetPeers(); auto peers = GetPeers();
@ -555,7 +555,7 @@ void CReflector::PutDHTPeers()
ReleasePeers(); ReleasePeers();
auto nv = std::make_shared<dht::Value>(p); auto nv = std::make_shared<dht::Value>(p);
nv->user_type.assign("urfd-peers-0"); nv->user_type.assign("urfd-peers-1");
nv->id = toUType(EUrfdValueID::Peers); nv->id = toUType(EUrfdValueID::Peers);
node.putSigned( node.putSigned(
@ -569,7 +569,7 @@ void CReflector::PutDHTPeers()
void CReflector::PutDHTClients() void CReflector::PutDHTClients()
{ {
const std::string cs(g_Configure.GetString(g_Keys.names.callsign)); const std::string cs(g_Configure.GetString(g_Keys.names.callsign));
SUrfdClients0 c; SUrfdClients1 c;
time(&c.timestamp); time(&c.timestamp);
c.sequence = clients_put_count++; c.sequence = clients_put_count++;
auto clients = GetClients(); auto clients = GetClients();
@ -580,7 +580,7 @@ void CReflector::PutDHTClients()
ReleaseClients(); ReleaseClients();
auto nv = std::make_shared<dht::Value>(c); auto nv = std::make_shared<dht::Value>(c);
nv->user_type.assign("urfd-clients-0"); nv->user_type.assign("urfd-clients-1");
nv->id = toUType(EUrfdValueID::Clients); nv->id = toUType(EUrfdValueID::Clients);
node.putSigned( node.putSigned(
@ -594,7 +594,7 @@ void CReflector::PutDHTClients()
void CReflector::PutDHTUsers() void CReflector::PutDHTUsers()
{ {
const std::string cs(g_Configure.GetString(g_Keys.names.callsign)); const std::string cs(g_Configure.GetString(g_Keys.names.callsign));
SUrfdUsers0 u; SUrfdUsers1 u;
time(&u.timestamp); time(&u.timestamp);
u.sequence = users_put_count++; u.sequence = users_put_count++;
auto users = GetUsers(); auto users = GetUsers();
@ -605,7 +605,7 @@ void CReflector::PutDHTUsers()
ReleaseUsers(); ReleaseUsers();
auto nv = std::make_shared<dht::Value>(u); auto nv = std::make_shared<dht::Value>(u);
nv->user_type.assign("urfd-users-0"); nv->user_type.assign("urfd-users-1");
nv->id = toUType(EUrfdValueID::Users); nv->id = toUType(EUrfdValueID::Users);
node.putSigned( node.putSigned(

@ -22,45 +22,48 @@
#include <opendht.h> #include <opendht.h>
/* HELPERS */ /* HELPERS */
#ifndef TO_U_TYPE_DEF
#define TO_U_TYPE_DEF
template<typename E> constexpr auto toUType(E enumerator) noexcept template<typename E> constexpr auto toUType(E enumerator) noexcept
{ {
return static_cast<std::underlying_type_t<E>>(enumerator); return static_cast<std::underlying_type_t<E>>(enumerator);
} // Item #10 in "Effective Modern C++", by Scott Meyers, O'REILLY } // Item #10 in "Effective Modern C++", by Scott Meyers, O'REILLY
#endif
enum class EUrfdValueID : uint64_t { Config=1, Peers=2, Clients=3, Users=4 }; enum class EUrfdValueID : uint64_t { Config=1, Peers=2, Clients=3, Users=4 };
/* PEERS */ /* PEERS */
using PeerTuple = std::tuple<std::string, std::string, std::time_t>; using UrfdPeerTuple = std::tuple<std::string, std::string, std::time_t>;
enum class EUrfdPeerFields { Callsign, Modules, ConnectTime }; enum class EUrfdPeerFields { Callsign, Modules, ConnectTime };
struct SUrfdPeers0 struct SUrfdPeers1
{ {
std::time_t timestamp; std::time_t timestamp;
unsigned int sequence; unsigned int sequence;
std::list<PeerTuple> list; std::list<UrfdPeerTuple> list;
MSGPACK_DEFINE(timestamp, sequence, list) MSGPACK_DEFINE(timestamp, sequence, list)
}; };
/* CLIENTS */ /* CLIENTS */
using ClientTuple = std::tuple<std::string, std::string, char, std::time_t, std::time_t>; using UrfdClientTuple = std::tuple<std::string, std::string, char, std::time_t, std::time_t>;
enum class EUrfdClientFields { Callsign, Ip, Module, ConnectTime, LastHeardTime }; enum class EUrfdClientFields { Callsign, Ip, Module, ConnectTime, LastHeardTime };
struct SUrfdClients0 struct SUrfdClients1
{ {
std::time_t timestamp; std::time_t timestamp;
unsigned int sequence; unsigned int sequence;
std::list<ClientTuple> list; std::list<UrfdClientTuple> list;
MSGPACK_DEFINE(timestamp, sequence, list) MSGPACK_DEFINE(timestamp, sequence, list)
}; };
/* USERS */ /* USERS */
using UserTuple = std::tuple<std::string, std::string, char, std::string, std::time_t>; using UrfdUserTuple = std::tuple<std::string, std::string, char, std::string, std::time_t>;
enum class EUrfdUserFields { Callsign, ViaNode, OnModule, ViaPeer, LastHeardTime }; enum class EUrfdUserFields { Callsign, ViaNode, OnModule, ViaPeer, LastHeardTime };
struct SUrfdUsers0 struct SUrfdUsers1
{ {
std::time_t timestamp; std::time_t timestamp;
unsigned int sequence; unsigned int sequence;
std::list<UserTuple> list; std::list<UrfdUserTuple> list;
MSGPACK_DEFINE(timestamp, sequence, list) MSGPACK_DEFINE(timestamp, sequence, list)
}; };

Loading…
Cancel
Save

Powered by TurnKey Linux.