xrpld
Loading...
Searching...
No Matches
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
18namespace xrpl {
19
27{
28public:
29 //< The type of the proposed position
31
42
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&
78 {
79 return suppression_;
80 }
81
82 Proposal const&
83 proposal() const
84 {
85 return proposal_;
86 }
87
92 getJson() const;
93
95 render() const
96 {
97 return proposal_.render();
98 }
99
100private:
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;
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
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
Represents a JSON value.
Definition json_value.h:117
Represents a proposed position taken during a round of consensus.
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
A public key.
Definition PublicKey.h:53
uint256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
RCLCxPeerPos(PublicKey const &publicKey, Slice const &signature, uint256 const &suppress, Proposal const &proposal)
Constructor.
ConsensusProposal< NodeID, uint256, uint256 > Proposal
Slice signature() const
Signature of the proposal (not necessarily verified).
boost::container::static_vector< std::uint8_t, 72 > signature_
void hash_append(Hasher &h) const
bool checkSign() const
Verify the signing hash of the proposal.
Proposal const & proposal() const
json::Value getJson() const
JSON representation of proposal.
std::string render() const
An immutable linear range of bytes.
Definition Slice.h:28
void hash_append(Hasher &h, T const &t) noexcept
Logically concatenate input data to a Hasher.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
@ Proposal
proposal for signing
Definition HashPrefix.h:79
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.
BaseUInt< 256 > uint256
Definition base_uint.h:580