Bitcoin ABC 0.26.3
P2P Digital Currency
Loading...
Searching...
No Matches
protocol.h
Go to the documentation of this file.
1// Copyright (c) 2020 The Bitcoin developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5#ifndef BITCOIN_AVALANCHE_PROTOCOL_H
6#define BITCOIN_AVALANCHE_PROTOCOL_H
7
9#include <protocol.h> // for CInv
10#include <serialize.h>
11#include <uint256.h>
12
13#include <cstdint>
14#include <vector>
15
16namespace avalanche {
17
18class Vote {
21
22public:
23 Vote() : error(-1), hash() {}
25
26 const uint256 &GetHash() const { return hash; }
27 uint32_t GetError() const { return error; }
28
29 // serialization support
31};
32
33class Response {
36 std::vector<Vote> votes;
37
38public:
39 Response() : round(-1), cooldown(-1) {}
42
43 uint64_t getRound() const { return round; }
44 uint32_t getCooldown() const { return cooldown; }
45 const std::vector<Vote> &GetVotes() const { return votes; }
46
47 // serialization support
49 READWRITE(obj.round, obj.cooldown, obj.votes);
50 }
51};
52
53class Poll {
55 std::vector<CInv> invs;
56
57public:
58 Poll(uint64_t roundIn, std::vector<CInv> invsIn)
59 : round(roundIn), invs(invsIn) {}
60
61 uint64_t GetRound() { return round; }
62 const std::vector<CInv> &GetInvs() const { return invs; }
63
64 // serialization support
66};
67
68class Hello {
71
72public:
75
76 SchnorrSig GetSig() { return sig; }
77
78 // serialization support
79 SERIALIZE_METHODS(Hello, obj) { READWRITE(obj.delegation, obj.sig); }
80};
81
82} // namespace avalanche
83
84#endif // BITCOIN_AVALANCHE_PROTOCOL_H
Delegation delegation
Definition protocol.h:69
Hello(Delegation delegationIn, SchnorrSig sigIn)
Definition protocol.h:73
SchnorrSig sig
Definition protocol.h:70
SERIALIZE_METHODS(Hello, obj)
Definition protocol.h:79
SchnorrSig GetSig()
Definition protocol.h:76
std::vector< CInv > invs
Definition protocol.h:55
uint64_t GetRound()
Definition protocol.h:61
uint64_t round
Definition protocol.h:54
const std::vector< CInv > & GetInvs() const
Definition protocol.h:62
Poll(uint64_t roundIn, std::vector< CInv > invsIn)
Definition protocol.h:58
SERIALIZE_METHODS(Poll, obj)
Definition protocol.h:65
uint32_t getCooldown() const
Definition protocol.h:44
const std::vector< Vote > & GetVotes() const
Definition protocol.h:45
SERIALIZE_METHODS(Response, obj)
Definition protocol.h:48
Response(uint64_t roundIn, uint32_t cooldownIn, std::vector< Vote > votesIn)
Definition protocol.h:40
uint64_t getRound() const
Definition protocol.h:43
std::vector< Vote > votes
Definition protocol.h:36
uint32_t cooldown
Definition protocol.h:35
SERIALIZE_METHODS(Vote, obj)
Definition protocol.h:30
uint256 hash
Definition protocol.h:20
Vote(uint32_t errorIn, uint256 hashIn)
Definition protocol.h:24
uint32_t GetError() const
Definition protocol.h:27
const uint256 & GetHash() const
Definition protocol.h:26
uint32_t error
Definition protocol.h:19
256-bit opaque blob.
Definition uint256.h:129
std::array< uint8_t, CPubKey::SCHNORR_SIZE > SchnorrSig
a Schnorr signature
Definition key.h:25
Implement std::hash so RCUPtr can be used as a key for maps or sets.
Definition rcu.h:257
T GetRand(T nMax=std::numeric_limits< T >::max()) noexcept
Generate a uniform random integer of type T in the range [0..nMax) nMax defaults to std::numeric_limi...
Definition random.h:85
#define READWRITE(...)
Definition serialize.h:166