rippled
RCLCxLedger.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012-2016 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_RCLCXLEDGER_H_INCLUDED
21 #define RIPPLE_APP_CONSENSUS_RCLCXLEDGER_H_INCLUDED
22 
23 #include <ripple/app/ledger/Ledger.h>
24 #include <ripple/app/ledger/LedgerToJson.h>
25 #include <ripple/ledger/ReadView.h>
26 #include <ripple/protocol/RippleLedgerHash.h>
27 #include <memory>
28 
29 namespace ripple {
30 
36 {
37 public:
39  using ID = LedgerHash;
41  using Seq = LedgerIndex;
42 
49  RCLCxLedger() = default;
50 
56  {
57  }
58 
60  Seq const&
61  seq() const
62  {
63  return ledger_->info().seq;
64  }
65 
67  ID const&
68  id() const
69  {
70  return ledger_->info().hash;
71  }
72 
74  ID const&
75  parentID() const
76  {
77  return ledger_->info().parentHash;
78  }
79 
83  {
84  return ledger_->info().closeTimeResolution;
85  }
86 
88  bool
89  closeAgree() const
90  {
91  return ripple::getCloseAgree(ledger_->info());
92  }
93 
96  closeTime() const
97  {
98  return ledger_->info().closeTime;
99  }
100 
104  {
105  return ledger_->info().parentCloseTime;
106  }
107 
110  getJson() const
111  {
112  return ripple::getJson({*ledger_, {}});
113  }
114 
121 };
122 } // namespace ripple
123 #endif
ripple::RCLCxLedger::closeAgree
bool closeAgree() const
Whether consensus process agreed on close time of the ledger.
Definition: RCLCxLedger.h:89
ripple::LedgerHash
uint256 LedgerHash
Definition: RippleLedgerHash.h:27
ripple::RCLCxLedger::Seq
LedgerIndex Seq
Sequence number of a ledger.
Definition: RCLCxLedger.h:41
ripple::LedgerIndex
std::uint32_t LedgerIndex
A ledger index.
Definition: Protocol.h:90
std::shared_ptr
STL class.
ripple::RCLCxLedger::RCLCxLedger
RCLCxLedger()=default
Default constructor.
std::chrono::duration
ripple::RCLCxLedger::RCLCxLedger
RCLCxLedger(std::shared_ptr< Ledger const > const &l)
Constructor.
Definition: RCLCxLedger.h:55
ripple::RCLCxLedger::closeTime
NetClock::time_point closeTime() const
The close time of this ledger.
Definition: RCLCxLedger.h:96
ripple::RCLCxLedger::seq
Seq const & seq() const
Sequence number of the ledger.
Definition: RCLCxLedger.h:61
ripple::RCLCxLedger::parentID
ID const & parentID() const
Unique identifier (hash) of this ledger's parent.
Definition: RCLCxLedger.h:75
ripple::RCLCxLedger::closeTimeResolution
NetClock::duration closeTimeResolution() const
Resolution used when calculating this ledger's close time.
Definition: RCLCxLedger.h:82
ripple::base_uint< 256 >
ripple::RCLCxLedger::getJson
Json::Value getJson() const
JSON representation of this ledger.
Definition: RCLCxLedger.h:110
std::chrono::time_point
ripple::RCLCxLedger::id
ID const & id() const
Unique identifier (hash) of this ledger.
Definition: RCLCxLedger.h:68
ripple::RCLCxLedger::ID
LedgerHash ID
Unique identifier of a ledger.
Definition: RCLCxLedger.h:39
std::uint32_t
memory
ripple::getJson
Json::Value getJson(LedgerFill const &fill)
Return a new Json::Value representing the ledger with given options.
Definition: LedgerToJson.cpp:296
ripple::getCloseAgree
bool getCloseAgree(LedgerInfo const &info)
Definition: ReadView.h:351
ripple::RCLCxLedger
Represents a ledger in RCLConsensus.
Definition: RCLCxLedger.h:35
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::RCLCxLedger::ledger_
std::shared_ptr< Ledger const > ledger_
The ledger instance.
Definition: RCLCxLedger.h:120
Json::Value
Represents a JSON value.
Definition: json_value.h:145
ripple::RCLCxLedger::parentCloseTime
NetClock::time_point parentCloseTime() const
The close time of this ledger's parent.
Definition: RCLCxLedger.h:103