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
39 RCLCxPeerPos(PublicKey const& publicKey, Slice const& signature, uint256 const& suppress, Proposal&& proposal);
40
42 bool
43 checkSign() const;
44
46 Slice
47 signature() const
48 {
49 return {signature_.data(), signature_.size()};
50 }
51
53 PublicKey const&
54 publicKey() const
55 {
56 return publicKey_;
57 }
58
60 uint256 const&
62 {
63 return suppression_;
64 }
65
66 Proposal const&
67 proposal() const
68 {
69 return proposal_;
70 }
71
74 getJson() const;
75
77 render() const
78 {
79 return proposal_.render();
80 }
81
82private:
86 boost::container::static_vector<std::uint8_t, 72> signature_;
87
88 template <class Hasher>
89 void
90 hash_append(Hasher& h) const
91 {
94 hash_append(h, std::uint32_t(proposal().proposeSeq()));
95 hash_append(h, proposal().closeTime());
96 hash_append(h, proposal().prevLedger());
97 hash_append(h, proposal().position());
98 }
99};
100
119 uint256 const& proposeHash,
120 uint256 const& previousLedger,
121 std::uint32_t proposeSeq,
122 NetClock::time_point closeTime,
123 Slice const& publicKey,
124 Slice const& signature);
125
126} // 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:45
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:77
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:526
@ 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.