Ring Daemon 16.0.0
Loading...
Searching...
No Matches
swarm_protocol.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2004-2025 Savoir-faire Linux Inc.
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <https://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <string>
20#include <string_view>
21#include <msgpack.hpp>
22
23#include <opendht/infohash.h>
24
25using namespace std::literals;
26using NodeId = dht::h256;
27
28namespace jami {
29
30namespace swarm_protocol {
31
32static constexpr int version = 1;
33
34enum class Query : uint8_t { FIND = 1, FOUND = 2 };
35
36using NodeId = dht::PkId;
37
38struct Request
39{
40 Query q; // Type of query
41 int num; // Number of nodes
44};
45
47{
49 std::vector<NodeId> nodes;
50 std::vector<NodeId> mobile_nodes;
51
53};
54
55struct Message
56{
57 int v = version;
58 bool is_mobile {false};
59 std::optional<Request> request;
60 std::optional<Response> response;
62};
63
64}; // namespace swarm_protocol
65
66} // namespace jami
static constexpr int version
void emitSignal(Args... args)
Definition ring_signal.h:64
dht::PkId NodeId
std::optional< Request > request
MSGPACK_DEFINE_MAP(v, is_mobile, request, response)
std::optional< Response > response
MSGPACK_DEFINE_MAP(q, num, nodeId)
std::vector< NodeId > mobile_nodes
MSGPACK_DEFINE_MAP(q, nodes, mobile_nodes)
std::vector< NodeId > nodes
MSGPACK_ADD_ENUM(jami::swarm_protocol::Query)