ipfs-chromium
library
include
ipfs_client
ipns_record.h
1
#ifndef IPFS_IPNS_RECORD_H_
2
#define IPFS_IPNS_RECORD_H_
3
4
#include <ipfs_client/ipns_cbor_entry.h>
5
6
#include <vocab/byte_view.h>
7
8
#if __has_include(<third_party/ipfs_client/keys.pb.h>)
9
#include <third_party/ipfs_client/keys.pb.h>
10
#else
11
#include "ipfs_client/keys.pb.h"
12
#endif
13
14
#include <functional>
15
#include <optional>
16
17
namespace
libp2p::peer {
18
class
PeerId;
19
}
20
namespace
libp2p::multi
{
21
struct
ContentIdentifier;
22
}
23
24
namespace
ipfs {
25
26
class
Cid;
27
class
Client;
28
29
constexpr
static
std::size_t MAX_IPNS_PB_SERIALIZED_SIZE = 10 * 1024;
30
31
std::optional<IpnsCborEntry> ValidateIpnsRecord(ByteView top_level_bytes,
32
Cid
const
& name,
33
Client&);
34
38
struct
ValidatedIpns
{
39
std::string
value
;
40
std::time_t
use_until
;
41
std::time_t
cache_until
;
42
47
std::uint64_t
sequence
;
48
std::int64_t
resolution_ms
;
49
53
std::time_t
fetch_time
= std::time(
nullptr
);
54
std::string
gateway_source
;
55
56
ValidatedIpns
();
59
explicit
ValidatedIpns
(
IpnsCborEntry
const
& entry);
60
ValidatedIpns
(
ValidatedIpns
&&);
61
ValidatedIpns
(
ValidatedIpns
const
&);
62
ValidatedIpns
& operator=(
ValidatedIpns
const
&);
63
64
std::string
Serialize
()
const
;
65
72
static
ValidatedIpns
Deserialize
(std::string bytes);
73
};
74
75
}
// namespace ipfs
76
77
#endif
// IPFS_IPNS_RECORD_H_
libp2p::multi
Definition:
dag_node.h:28
ipfs::IpnsCborEntry
Parsed out data contained in the CBOR data of an IPNS record.
Definition:
ipns_cbor_entry.h:11
ipfs::ValidatedIpns
Data from IPNS record modulo the verification parts.
Definition:
ipns_record.h:38
ipfs::ValidatedIpns::Serialize
std::string Serialize() const
Turn into a well-defined list of bytes.
Definition:
ipns_record.cc:229
ipfs::ValidatedIpns::sequence
std::uint64_t sequence
The version of the record.
Definition:
ipns_record.h:47
ipfs::ValidatedIpns::fetch_time
std::time_t fetch_time
When the record was fetched.
Definition:
ipns_record.h:53
ipfs::ValidatedIpns::ValidatedIpns
ValidatedIpns()
Create an invalid default object.
ipfs::ValidatedIpns::cache_until
std::time_t cache_until
Inspired by TTL.
Definition:
ipns_record.h:41
ipfs::ValidatedIpns::gateway_source
std::string gateway_source
Who gave us this record?
Definition:
ipns_record.h:54
ipfs::ValidatedIpns::resolution_ms
std::int64_t resolution_ms
How long it took to fetch the record.
Definition:
ipns_record.h:48
ipfs::ValidatedIpns::use_until
std::time_t use_until
An expiration timestamp.
Definition:
ipns_record.h:40
ipfs::ValidatedIpns::Deserialize
static ValidatedIpns Deserialize(std::string bytes)
Create a ValidatedIpns from untyped bytes.
Definition:
ipns_record.cc:238
ipfs::ValidatedIpns::value
std::string value
The path the record claims the IPNS name points to.
Definition:
ipns_record.h:39
Generated by
1.9.1