xrpld
Toggle main menu visibility
Loading...
Searching...
No Matches
xrpld
app
consensus
RCLCxPeerPos.h
1
#pragma once
2
3
#include <xrpl/basics/Slice.h>
4
#include <xrpl/basics/base_uint.h>
5
#include <xrpl/basics/chrono.h>
6
#include <xrpl/beast/hash/hash_append.h>
7
#include <xrpl/consensus/ConsensusProposal.h>
8
#include <xrpl/json/json_value.h>
9
#include <xrpl/protocol/HashPrefix.h>
10
#include <xrpl/protocol/PublicKey.h>
11
#include <xrpl/protocol/UintTypes.h>
12
13
#include <boost/container/static_vector.hpp>
14
15
#include <
cstdint
>
16
#include <
string
>
17
18
namespace
xrpl
{
19
26
class
RCLCxPeerPos
27
{
28
public
:
29
//< The type of the proposed position
30
using
Proposal
=
ConsensusProposal<NodeID, UInt256, UInt256>
;
31
42
43
RCLCxPeerPos
(
44
PublicKey
const
&
publicKey
,
45
Slice
const
&
signature
,
46
UInt256
const
& suppress,
47
Proposal
const
&
proposal
);
// trivially copyable
48
52
bool
53
checkSign
()
const
;
54
58
Slice
59
signature
()
const
60
{
61
return
{
signature_
.data(),
signature_
.size()};
62
}
63
67
PublicKey
const
&
68
publicKey
()
const
69
{
70
return
publicKey_
;
71
}
72
76
UInt256
const
&
77
suppressionID
()
const
78
{
79
return
suppression_
;
80
}
81
82
Proposal
const
&
83
proposal
()
const
84
{
85
return
proposal_
;
86
}
87
91
json::Value
92
getJson
()
const
;
93
94
std::string
95
render
()
const
96
{
97
return
proposal_
.render();
98
}
99
100
private
:
101
PublicKey
publicKey_
;
102
UInt256
suppression_
;
103
Proposal
proposal_
;
104
boost::container::static_vector<std::uint8_t, 72>
signature_
;
105
106
template
<
class
Hasher>
107
void
108
hash_append
(Hasher& h)
const
// NOLINT(readability-identifier-naming)
109
{
110
using
beast::hash_append
;
111
hash_append
(h,
HashPrefix::Proposal
);
112
hash_append
(h,
proposal
().proposeSeq());
113
hash_append
(h,
proposal
().closeTime());
114
hash_append
(h,
proposal
().prevLedger());
115
hash_append
(h,
proposal
().position());
116
}
117
};
118
136
UInt256
137
proposalUniqueId
(
138
UInt256
const
& proposeHash,
139
UInt256
const
& previousLedger,
140
std::uint32_t
proposeSeq,
141
NetClock::time_point
closeTime,
142
Slice
const
& publicKey,
143
Slice
const
& signature);
144
145
}
// namespace xrpl
std::string
json::Value
Represents a JSON value.
Definition
json_value.h:117
xrpl::ConsensusProposal
Represents a proposed position taken during a round of consensus.
Definition
ConsensusProposal.h:42
xrpl::NetClock::time_point
std::chrono::time_point< NetClock > time_point
Definition
chrono.h:48
xrpl::PublicKey
A public key.
Definition
PublicKey.h:53
xrpl::RCLCxPeerPos::publicKey
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
Definition
RCLCxPeerPos.h:68
xrpl::RCLCxPeerPos::Proposal
ConsensusProposal< NodeID, UInt256, UInt256 > Proposal
Definition
RCLCxPeerPos.h:30
xrpl::RCLCxPeerPos::signature
Slice signature() const
Signature of the proposal (not necessarily verified).
Definition
RCLCxPeerPos.h:59
xrpl::RCLCxPeerPos::suppression_
UInt256 suppression_
Definition
RCLCxPeerPos.h:102
xrpl::RCLCxPeerPos::signature_
boost::container::static_vector< std::uint8_t, 72 > signature_
Definition
RCLCxPeerPos.h:104
xrpl::RCLCxPeerPos::hash_append
void hash_append(Hasher &h) const
Definition
RCLCxPeerPos.h:108
xrpl::RCLCxPeerPos::RCLCxPeerPos
RCLCxPeerPos(PublicKey const &publicKey, Slice const &signature, UInt256 const &suppress, Proposal const &proposal)
Constructor.
Definition
RCLCxPeerPos.cpp:18
xrpl::RCLCxPeerPos::suppressionID
UInt256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
Definition
RCLCxPeerPos.h:77
xrpl::RCLCxPeerPos::checkSign
bool checkSign() const
Verify the signing hash of the proposal.
Definition
RCLCxPeerPos.cpp:36
xrpl::RCLCxPeerPos::proposal
Proposal const & proposal() const
Definition
RCLCxPeerPos.h:83
xrpl::RCLCxPeerPos::getJson
json::Value getJson() const
JSON representation of proposal.
Definition
RCLCxPeerPos.cpp:42
xrpl::RCLCxPeerPos::render
std::string render() const
Definition
RCLCxPeerPos.h:95
xrpl::RCLCxPeerPos::proposal_
Proposal proposal_
Definition
RCLCxPeerPos.h:103
xrpl::RCLCxPeerPos::publicKey_
PublicKey publicKey_
Definition
RCLCxPeerPos.h:101
xrpl::Slice
An immutable linear range of bytes.
Definition
Slice.h:28
cstdint
std::uint32_t
beast::hash_append
void hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
Definition
hash_append.h:206
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::proposalUniqueId
UInt256 proposalUniqueId(UInt256 const &proposeHash, UInt256 const &previousLedger, std::uint32_t proposeSeq, NetClock::time_point closeTime, Slice const &publicKey, Slice const &signature)
Calculate a unique identifier for a signed proposal.
Definition
RCLCxPeerPos.cpp:53
xrpl::UInt256
BaseUInt< 256 > UInt256
Definition
base_uint.h:580
xrpl::HashPrefix::Proposal
@ Proposal
proposal for signing
Definition
HashPrefix.h:79
string
Generated by
1.17.0