rippled
Loading...
Searching...
No Matches
RCLCxPeerPos.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2012, 2013 Ripple Labs Inc.
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef RIPPLE_APP_CONSENSUS_RCLCXPEERPOS_H_INCLUDED
21#define RIPPLE_APP_CONSENSUS_RCLCXPEERPOS_H_INCLUDED
22
23#include <xrpld/consensus/ConsensusProposal.h>
24
25#include <xrpl/basics/base_uint.h>
26#include <xrpl/beast/hash/hash_append.h>
27#include <xrpl/json/json_value.h>
28#include <xrpl/protocol/HashPrefix.h>
29#include <xrpl/protocol/PublicKey.h>
30
31#include <boost/container/static_vector.hpp>
32
33#include <cstdint>
34#include <string>
35
36namespace ripple {
37
44{
45public:
46 //< The type of the proposed position
48
60 PublicKey const& publicKey,
61 Slice const& signature,
62 uint256 const& suppress,
64
66 bool
67 checkSign() const;
68
70 Slice
71 signature() const
72 {
73 return {signature_.data(), signature_.size()};
74 }
75
77 PublicKey const&
78 publicKey() const
79 {
80 return publicKey_;
81 }
82
84 uint256 const&
86 {
87 return suppression_;
88 }
89
90 Proposal const&
91 proposal() const
92 {
93 return proposal_;
94 }
95
98 getJson() const;
99
101 render() const
102 {
103 return proposal_.render();
104 }
105
106private:
110 boost::container::static_vector<std::uint8_t, 72> signature_;
111
112 template <class Hasher>
113 void
114 hash_append(Hasher& h) const
115 {
116 using beast::hash_append;
118 hash_append(h, std::uint32_t(proposal().proposeSeq()));
119 hash_append(h, proposal().closeTime());
120 hash_append(h, proposal().prevLedger());
121 hash_append(h, proposal().position());
122 }
123};
124
143 uint256 const& proposeHash,
144 uint256 const& previousLedger,
145 std::uint32_t proposeSeq,
146 NetClock::time_point closeTime,
147 Slice const& publicKey,
148 Slice const& signature);
149
150} // namespace ripple
151
152#endif
Represents a JSON value.
Definition: json_value.h:148
std::string render() const
std::chrono::time_point< NetClock > time_point
Definition: chrono.h:69
A public key.
Definition: PublicKey.h:62
A peer's signed, proposed position for use in RCLConsensus.
Definition: RCLCxPeerPos.h:44
Proposal const & proposal() const
Definition: RCLCxPeerPos.h:91
boost::container::static_vector< std::uint8_t, 72 > signature_
Definition: RCLCxPeerPos.h:110
bool checkSign() const
Verify the signing hash of the proposal.
Json::Value getJson() const
JSON representation of proposal.
std::string render() const
Definition: RCLCxPeerPos.h:101
PublicKey const & publicKey() const
Public key of peer that sent the proposal.
Definition: RCLCxPeerPos.h:78
void hash_append(Hasher &h) const
Definition: RCLCxPeerPos.h:114
Slice signature() const
Signature of the proposal (not necessarily verified)
Definition: RCLCxPeerPos.h:71
uint256 const & suppressionID() const
Unique id used by hash router to suppress duplicates.
Definition: RCLCxPeerPos.h:85
ConsensusProposal< NodeID, uint256, uint256 > Proposal
Definition: RCLCxPeerPos.h:47
An immutable linear range of bytes.
Definition: Slice.h:46
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.
Definition: hash_append.h:237
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
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:558
@ proposal
proposal for signing