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#include <xrpl/basics/CountedObject.h>
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#include <xrpl/protocol/SecretKey.h>
31#include <boost/container/static_vector.hpp>
32#include <chrono>
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
100private:
104 boost::container::static_vector<std::uint8_t, 72> signature_;
105
106 template <class Hasher>
107 void
108 hash_append(Hasher& h) const
109 {
110 using beast::hash_append;
112 hash_append(h, std::uint32_t(proposal().proposeSeq()));
113 hash_append(h, proposal().closeTime());
114 hash_append(h, proposal().prevLedger());
115 hash_append(h, proposal().position());
116 }
117};
118
137 uint256 const& proposeHash,
138 uint256 const& previousLedger,
139 std::uint32_t proposeSeq,
140 NetClock::time_point closeTime,
141 Slice const& publicKey,
142 Slice const& signature);
143
144} // namespace ripple
145
146#endif
Represents a JSON value.
Definition: json_value.h:147
std::chrono::time_point< NetClock > time_point
Definition: chrono.h:70
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:104
bool checkSign() const
Verify the signing hash of the proposal.
Json::Value getJson() const
JSON representation of proposal.
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:108
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:45
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:236
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:557
@ proposal
proposal for signing