bep5_swarms.cpp 995 Bytes
Newer Older
1
#include "bep5_swarms.h"
2
#include "util.h"
3
4
5
6
7
8

namespace ouinet { namespace bep5 {

std::string compute_injector_swarm_name(const ouinet::util::Ed25519PublicKey& pubkey, unsigned protocol_version)
{
    return util::str
9
        ( "ed25519:", util::base32up_encode(pubkey.serialize())
10
11
12
13
14
15
16
        , "/v", protocol_version
        , "/injectors");
}

std::string compute_bridge_swarm_name(const ouinet::util::Ed25519PublicKey& pubkey, unsigned protocol_version)
{
    return util::str
17
        ( "ed25519:", util::base32up_encode(pubkey.serialize())
18
19
20
21
        , "/v", protocol_version
        , "/bridges");
}

22
std::string compute_uri_swarm_prefix(const ouinet::util::Ed25519PublicKey& pubkey, unsigned protocol_version)
23
24
{
    return util::str
25
        ( "ed25519:", util::base32up_encode(pubkey.serialize())
26
        , "/v", protocol_version
27
28
29
30
31
32
        , "/uri/");
}

std::string compute_uri_swarm_name(boost::string_view prefix, boost::string_view uri)
{
    return util::str(prefix, uri);
33
34
35
}

}} // namespaces