rippled
LedgerFormats.cpp
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 #include <ripple/protocol/ErrorCodes.h>
21 #include <ripple/protocol/LedgerFormats.h>
22 #include <ripple/protocol/jss.h>
23 #include <algorithm>
24 #include <array>
25 #include <utility>
26 
27 namespace ripple {
28 
30 {
31  // Fields shared by all ledger formats:
32  static const std::initializer_list<SOElement> commonFields{
36  };
37 
38  add(jss::AccountRoot,
40  {
57  },
58  commonFields);
59 
60  add(jss::DirectoryNode,
61  ltDIR_NODE,
62  {
63  {sfOwner, soeOPTIONAL}, // for owner directories
64  {sfTakerPaysCurrency, soeOPTIONAL}, // for order book directories
65  {sfTakerPaysIssuer, soeOPTIONAL}, // for order book directories
66  {sfTakerGetsCurrency, soeOPTIONAL}, // for order book directories
67  {sfTakerGetsIssuer, soeOPTIONAL}, // for order book directories
68  {sfExchangeRate, soeOPTIONAL}, // for order book directories
73  },
74  commonFields);
75 
76  add(jss::Offer,
77  ltOFFER,
78  {
89  },
90  commonFields);
91 
92  add(jss::RippleState,
94  {
106  },
107  commonFields);
108 
109  add(jss::Escrow,
110  ltESCROW,
111  {
124  },
125  commonFields);
126 
127  add(jss::LedgerHashes,
129  {
131  soeOPTIONAL}, // Remove if we do a ledger restart
134  },
135  commonFields);
136 
137  add(jss::Amendments,
138  ltAMENDMENTS,
139  {
140  {sfAmendments, soeOPTIONAL}, // Enabled
142  },
143  commonFields);
144 
145  add(jss::FeeSettings,
147  {
152  },
153  commonFields);
154 
155  add(jss::Ticket,
156  ltTICKET,
157  {
163  },
164  commonFields);
165 
166  // All fields are soeREQUIRED because there is always a
167  // SignerEntries. If there are no SignerEntries the node is deleted.
168  add(jss::SignerList,
170  {
177  },
178  commonFields);
179 
180  add(jss::PayChannel,
181  ltPAYCHAN,
182  {
197  },
198  commonFields);
199 
200  add(jss::Check,
201  ltCHECK,
202  {
215  },
216  commonFields);
217 
218  add(jss::DepositPreauth,
220  {
226  },
227  commonFields);
228 
229  add(jss::NegativeUNL,
231  {
235  },
236  commonFields);
237 }
238 
239 LedgerFormats const&
241 {
242  static LedgerFormats instance;
243  return instance;
244 }
245 
246 } // namespace ripple
ripple::sfIndexNext
const SF_UINT64 sfIndexNext
ripple::sfSignerListID
const SF_UINT32 sfSignerListID
ripple::sfHighQualityIn
const SF_UINT32 sfHighQualityIn
ripple::sfPreviousTxnLgrSeq
const SF_UINT32 sfPreviousTxnLgrSeq
ripple::sfOwnerCount
const SF_UINT32 sfOwnerCount
ripple::sfPreviousTxnID
const SF_HASH256 sfPreviousTxnID
ripple::KnownFormats< LedgerEntryType >::add
Item const & add(char const *name, LedgerEntryType type, std::initializer_list< SOElement > uniqueFields, std::initializer_list< SOElement > commonFields={})
Add a new format.
Definition: KnownFormats.h:168
ripple::sfSourceTag
const SF_UINT32 sfSourceTag
ripple::sfReserveBase
const SF_UINT32 sfReserveBase
ripple::sfSendMax
const SF_AMOUNT sfSendMax
utility
ripple::sfOwnerNode
const SF_UINT64 sfOwnerNode
ripple::sfDestination
const SF_ACCOUNT sfDestination
ripple::sfAmount
const SF_AMOUNT sfAmount
ripple::sfWalletSize
const SF_UINT32 sfWalletSize
ripple::sfFirstLedgerSequence
const SF_UINT32 sfFirstLedgerSequence
ripple::sfTakerGetsCurrency
const SF_HASH160 sfTakerGetsCurrency
ripple::sfBookDirectory
const SF_HASH256 sfBookDirectory
ripple::sfOwner
const SF_ACCOUNT sfOwner
ripple::sfSequence
const SF_UINT32 sfSequence
ripple::sfRegularKey
const SF_ACCOUNT sfRegularKey
ripple::ltESCROW
@ ltESCROW
Definition: LedgerFormats.h:80
ripple::sfWalletLocator
const SF_HASH256 sfWalletLocator
ripple::soeREQUIRED
@ soeREQUIRED
Definition: SOTemplate.h:34
ripple::sfEmailHash
const SF_HASH128 sfEmailHash
ripple::sfTicketSequence
const SF_UINT32 sfTicketSequence
ripple::ltLEDGER_HASHES
@ ltLEDGER_HASHES
Definition: LedgerFormats.h:74
ripple::ltAMENDMENTS
@ ltAMENDMENTS
Definition: LedgerFormats.h:76
ripple::ltSIGNER_LIST
@ ltSIGNER_LIST
Definition: LedgerFormats.h:70
algorithm
ripple::ltTICKET
@ ltTICKET
Definition: LedgerFormats.h:68
ripple::sfTakerGetsIssuer
const SF_HASH160 sfTakerGetsIssuer
ripple::ltCHECK
@ ltCHECK
Definition: LedgerFormats.h:85
ripple::sfExpiration
const SF_UINT32 sfExpiration
ripple::sfSignerQuorum
const SF_UINT32 sfSignerQuorum
ripple::sfIndexes
const SF_VECTOR256 sfIndexes
ripple::sfLowNode
const SF_UINT64 sfLowNode
ripple::sfTakerPays
const SF_AMOUNT sfTakerPays
ripple::sfLowQualityOut
const SF_UINT32 sfLowQualityOut
ripple::sfLowLimit
const SF_AMOUNT sfLowLimit
ripple::sfSettleDelay
const SF_UINT32 sfSettleDelay
ripple::ltFEE_SETTINGS
@ ltFEE_SETTINGS
Definition: LedgerFormats.h:78
ripple::sfTakerPaysIssuer
const SF_HASH160 sfTakerPaysIssuer
ripple::sfReserveIncrement
const SF_UINT32 sfReserveIncrement
ripple::sfIndexPrevious
const SF_UINT64 sfIndexPrevious
ripple::soeOPTIONAL
@ soeOPTIONAL
Definition: SOTemplate.h:35
ripple::sfBookNode
const SF_UINT64 sfBookNode
ripple::LedgerFormats::LedgerFormats
LedgerFormats()
Create the object.
Definition: LedgerFormats.cpp:29
ripple::sfLowQualityIn
const SF_UINT32 sfLowQualityIn
ripple::sfValidatorToDisable
const SF_VL sfValidatorToDisable
array
ripple::sfTicketCount
const SF_UINT32 sfTicketCount
ripple::sfDestinationNode
const SF_UINT64 sfDestinationNode
ripple::sfTakerGets
const SF_AMOUNT sfTakerGets
ripple::sfLedgerIndex
const SF_HASH256 sfLedgerIndex
ripple::sfTransferRate
const SF_UINT32 sfTransferRate
ripple::sfTickSize
const SF_UINT8 sfTickSize
ripple::sfAuthorize
const SF_ACCOUNT sfAuthorize
ripple::sfHighLimit
const SF_AMOUNT sfHighLimit
ripple::sfExchangeRate
const SF_UINT64 sfExchangeRate
ripple::ltDEPOSIT_PREAUTH
@ ltDEPOSIT_PREAUTH
Definition: LedgerFormats.h:87
ripple::sfTakerPaysCurrency
const SF_HASH160 sfTakerPaysCurrency
ripple::LedgerFormats::getInstance
static LedgerFormats const & getInstance()
Definition: LedgerFormats.cpp:240
ripple::sfSignerEntries
const SField sfSignerEntries
ripple::sfBaseFee
const SF_UINT64 sfBaseFee
ripple::sfHashes
const SF_VECTOR256 sfHashes
ripple::ltNEGATIVE_UNL
@ ltNEGATIVE_UNL
Definition: LedgerFormats.h:89
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::ltRIPPLE_STATE
@ ltRIPPLE_STATE
Definition: LedgerFormats.h:66
ripple::sfLedgerEntryType
const SF_UINT16 sfLedgerEntryType
ripple::sfAccountTxnID
const SF_HASH256 sfAccountTxnID
ripple::sfCondition
const SF_VL sfCondition
ripple::sfFlags
const SF_UINT32 sfFlags
ripple::sfInvoiceID
const SF_HASH256 sfInvoiceID
ripple::sfDestinationTag
const SF_UINT32 sfDestinationTag
ripple::sfRootIndex
const SF_HASH256 sfRootIndex
ripple::sfBalance
const SF_AMOUNT sfBalance
ripple::sfReferenceFeeUnits
const SF_UINT32 sfReferenceFeeUnits
ripple::sfCancelAfter
const SF_UINT32 sfCancelAfter
ripple::sfMessageKey
const SF_VL sfMessageKey
ripple::sfHighQualityOut
const SF_UINT32 sfHighQualityOut
ripple::LedgerFormats
Holds the list of known ledger entry formats.
Definition: LedgerFormats.h:138
ripple::ltPAYCHAN
@ ltPAYCHAN
Definition: LedgerFormats.h:83
ripple::sfFinishAfter
const SF_UINT32 sfFinishAfter
ripple::sfAccount
const SF_ACCOUNT sfAccount
ripple::ltDIR_NODE
@ ltDIR_NODE
Directory node.
Definition: LedgerFormats.h:64
ripple::ltOFFER
@ ltOFFER
Definition: LedgerFormats.h:72
ripple::sfDomain
const SF_VL sfDomain
ripple::sfLastLedgerSequence
const SF_UINT32 sfLastLedgerSequence
ripple::ltACCOUNT_ROOT
@ ltACCOUNT_ROOT
Definition: LedgerFormats.h:53
ripple::sfMajorities
const SField sfMajorities
ripple::sfDisabledValidators
const SField sfDisabledValidators
ripple::sfPublicKey
const SF_VL sfPublicKey
ripple::sfHighNode
const SF_UINT64 sfHighNode
ripple::sfAmendments
const SF_VECTOR256 sfAmendments
ripple::sfValidatorToReEnable
const SF_VL sfValidatorToReEnable
std::initializer_list