xrpld
Loading...
Searching...
No Matches
LedgerHeader.h
1#pragma once
2
3#include <xrpl/basics/Slice.h>
4#include <xrpl/basics/base_uint.h>
5#include <xrpl/basics/chrono.h>
6#include <xrpl/beast/utility/Zero.h>
7#include <xrpl/protocol/Protocol.h>
8#include <xrpl/protocol/Serializer.h>
9#include <xrpl/protocol/XRPAmount.h>
10
11#include <cstdint>
12
13namespace xrpl {
14
19{
20 explicit LedgerHeader() = default;
21
22 //
23 // For all ledgers
24 //
25
28
29 //
30 // For closed ledgers
31 //
32
33 // Closed means "tx set already determined"
38
40
41 // If validated is false, it means "not yet validated."
42 // Once validated is true, it will never be set false at a later time.
43 // VFALCO TODO Make this not mutable
44 bool mutable validated = false;
45 bool accepted = false;
46
47 // flags indicating how this ledger close took place
48 int closeFlags = 0;
49
50 // the resolution for this ledger close time (2-120 seconds)
52
53 // For closed ledgers, the time the ledger
54 // closed. For open ledgers, the time the ledger
55 // will close if there's no transactions.
56 //
58};
59
60// ledger close flags
62
63inline bool
65{
66 return (info.closeFlags & kSLcfNoConsensusTime) == 0;
67}
68
69void
70addRaw(LedgerHeader const&, Serializer&, bool includeHash = false);
71
75LedgerHeader
76deserializeHeader(Slice data, bool hasHash = false);
77
81LedgerHeader
82deserializePrefixedHeader(Slice data, bool hasHash = false);
83
88calculateLedgerHash(LedgerHeader const& info);
89
90} // namespace xrpl
std::chrono::time_point< NetClock > time_point
Definition chrono.h:48
std::chrono::duration< rep, period > duration
Definition chrono.h:47
constexpr Zero kZero
Definition Zero.h:30
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
std::uint32_t LedgerIndex
A ledger index.
Definition Protocol.h:370
bool getCloseAgree(LedgerHeader const &info)
LedgerHeader deserializeHeader(Slice data, bool hasHash=false)
Deserialize a ledger header from a byte array.
uint256 calculateLedgerHash(LedgerHeader const &info)
Calculate the hash of a ledger header.
void addRaw(LedgerHeader const &, Serializer &, bool includeHash=false)
static std::uint32_t const kSLcfNoConsensusTime
BaseUInt< 256 > uint256
Definition base_uint.h:580
LedgerHeader deserializePrefixedHeader(Slice data, bool hasHash=false)
Deserialize a ledger header (prefixed with 4 bytes) from a byte array.
Information about the notional ledger backing the view.
NetClock::time_point parentCloseTime
LedgerHeader()=default
NetClock::duration closeTimeResolution
NetClock::time_point closeTime