rippled
Loading...
Searching...
No Matches
RCLCxPeerPos.h
1#pragma once
2
3#include <xrpld/consensus/ConsensusProposal.h>
4
5#include <xrpl/basics/base_uint.h>
6#include <xrpl/beast/hash/hash_append.h>
7#include <xrpl/json/json_value.h>
8#include <xrpl/protocol/HashPrefix.h>
9#include <xrpl/protocol/PublicKey.h>
10
11#include <boost/container/static_vector.hpp>
12
13#include <cstdint>
14#include <string>
15
16namespace xrpl {
17
24{
25public:
26 //< The type of the proposed position
28
40 PublicKey const& publicKey,
41 Slice const& signature,
42 uint256 const& suppress,
43 Proposal const& proposal); // trivially copyable
44
46 bool
47 checkSign() const;
48
50 Slice
51 signature() const
52 {
53 return {signature_.data(), signature_.size()};
54 }
55
57 PublicKey const&
58 publicKey() const
59 {
60 return publicKey_;
61 }
62
64 uint256 const&
66 {
67 return suppression_;
68 }
69
70 Proposal const&
71 proposal() const
72 {
73 return proposal_;
74 }
75
78 getJson() const;
79
81 render() const
82 {
83 return proposal_.render();
84 }
85
86private:
90 boost::container::static_vector<std::uint8_t, 72> signature_;
91
92 template <class Hasher>
93 void
94 hash_append(Hasher& h) const
95 {
98 hash_append(h, std::uint32_t(proposal().proposeSeq()));
99 hash_append(h, proposal().closeTime());
100 hash_append(h, proposal().prevLedger());
101 hash_append(h, proposal().position());
102 }
103};
104
123 uint256 const& proposeHash,
124 uint256 const& previousLedger,
125 std::uint32_t proposeSeq,
126 NetClock::time_point closeTime,
127 Slice const& publicKey,
128 Slice const& signature);
129
130} // namespace xrpl
Represents a JSON value.
Definition json_value.h:130
std::string render() const
std::chrono::time_point< NetClock > time_point
Definition chrono.h:46
A public key.
Definition PublicKey.h:42
A peer's signed, proposed position for use in RCLConsensus.
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.
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
std::string render() const
Json::Value getJson() const
JSON representation of proposal.
An immutable linear range of bytes.
Definition Slice.h:26
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Definition Slice.h:78
std::enable_if_t< is_contiguously_hashable< T, Hasher >::value > 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
base_uint< 256 > uint256
Definition base_uint.h:531
@ proposal
proposal for signing
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.