rippled
Loading...
Searching...
No Matches
LedgerHeader.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of rippled: https://github.com/ripple/rippled
4 Copyright (c) 2023 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_PROTOCOL_LEDGERHEADER_H_INCLUDED
21#define RIPPLE_PROTOCOL_LEDGERHEADER_H_INCLUDED
22
23#include <xrpl/basics/Slice.h>
24#include <xrpl/basics/base_uint.h>
25#include <xrpl/basics/chrono.h>
26#include <xrpl/protocol/Protocol.h>
27#include <xrpl/protocol/Serializer.h>
28#include <xrpl/protocol/XRPAmount.h>
29
30namespace ripple {
31
34{
35 explicit LedgerHeader() = default;
36
37 //
38 // For all ledgers
39 //
40
43
44 //
45 // For closed ledgers
46 //
47
48 // Closed means "tx set already determined"
49 uint256 hash = beast::zero;
50 uint256 txHash = beast::zero;
51 uint256 accountHash = beast::zero;
52 uint256 parentHash = beast::zero;
53
54 XRPAmount drops = beast::zero;
55
56 // If validated is false, it means "not yet validated."
57 // Once validated is true, it will never be set false at a later time.
58 // VFALCO TODO Make this not mutable
59 bool mutable validated = false;
60 bool accepted = false;
61
62 // flags indicating how this ledger close took place
63 int closeFlags = 0;
64
65 // the resolution for this ledger close time (2-120 seconds)
67
68 // For closed ledgers, the time the ledger
69 // closed. For open ledgers, the time the ledger
70 // will close if there's no transactions.
71 //
73};
74
75// We call them "headers" in conversation
76// but "info" in code. Unintuitive.
77// This alias lets us give the "correct" name to the class
78// without yet disturbing existing uses.
80
81// ledger close flags
83
84inline bool
86{
87 return (info.closeFlags & sLCF_NoConsensusTime) == 0;
88}
89
90void
91addRaw(LedgerHeader const&, Serializer&, bool includeHash = false);
92
94LedgerHeader
95deserializeHeader(Slice data, bool hasHash = false);
96
98LedgerHeader
99deserializePrefixedHeader(Slice data, bool hasHash = false);
100
101} // namespace ripple
102
103#endif
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
LedgerHeader deserializePrefixedHeader(Slice data, bool hasHash=false)
Deserialize a ledger header (prefixed with 4 bytes) from a byte array.
bool getCloseAgree(LedgerHeader const &info)
static std::uint32_t const sLCF_NoConsensusTime
void addRaw(LedgerHeader const &, Serializer &, bool includeHash=false)
LedgerHeader deserializeHeader(Slice data, bool hasHash=false)
Deserialize a ledger header from a byte array.
Information about the notional ledger backing the view.
NetClock::time_point closeTime
NetClock::duration closeTimeResolution
NetClock::time_point parentCloseTime