rippled
Loading...
Searching...
No Matches
RCLCxPeerPos.h
1#ifndef XRPL_APP_CONSENSUS_RCLCXPEERPOS_H_INCLUDED
2#define XRPL_APP_CONSENSUS_RCLCXPEERPOS_H_INCLUDED
3
4#include <xrpld/consensus/ConsensusProposal.h>
5
6#include <xrpl/basics/base_uint.h>
7#include <xrpl/beast/hash/hash_append.h>
8#include <xrpl/json/json_value.h>
9#include <xrpl/protocol/HashPrefix.h>
10#include <xrpl/protocol/PublicKey.h>
11
12#include <boost/container/static_vector.hpp>
13
14#include <cstdint>
15#include <string>
16
17namespace ripple {
18
25{
26public:
27 //< The type of the proposed position
29
41 PublicKey const& publicKey,
42 Slice const& signature,
43 uint256 const& suppress,
45
47 bool
48 checkSign() const;
49
51 Slice
52 signature() const
53 {
54 return {signature_.data(), signature_.size()};
55 }
56
58 PublicKey const&
59 publicKey() const
60 {
61 return publicKey_;
62 }
63
65 uint256 const&
67 {
68 return suppression_;
69 }
70
71 Proposal const&
72 proposal() const
73 {
74 return proposal_;
75 }
76
79 getJson() const;
80
82 render() const
83 {
84 return proposal_.render();
85 }
86
87private:
91 boost::container::static_vector<std::uint8_t, 72> signature_;
92
93 template <class Hasher>
94 void
95 hash_append(Hasher& h) const
96 {
99 hash_append(h, std::uint32_t(proposal().proposeSeq()));
100 hash_append(h, proposal().closeTime());
101 hash_append(h, proposal().prevLedger());
102 hash_append(h, proposal().position());
103 }
104};
105
124 uint256 const& proposeHash,
125 uint256 const& previousLedger,
126 std::uint32_t proposeSeq,
127 NetClock::time_point closeTime,
128 Slice const& publicKey,
129 Slice const& signature);
130
131} // namespace ripple
132
133#endif
Represents a JSON value.
Definition json_value.h:130
std::chrono::time_point< NetClock > time_point
Definition chrono.h:50
A public key.
Definition PublicKey.h:43
A peer's signed, proposed position for use in RCLConsensus.
Proposal const & proposal() const
boost::container::static_vector< std::uint8_t, 72 > signature_
bool checkSign() const
Verify the signing hash of the proposal.
Json::Value getJson() const
JSON representation of proposal.
std::string render() const
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
void hash_append(Hasher &h) const
Slice signature() const
Signature of the proposal (not necessarily verified)
uint256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
ConsensusProposal< NodeID, uint256, uint256 > Proposal
An immutable linear range of bytes.
Definition Slice.h:27
std::uint8_t const * data() const noexcept
Return a pointer to beginning of the storage.
Definition Slice.h:79
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:6
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.
base_uint< 256 > uint256
Definition base_uint.h:539
@ proposal
proposal for signing