rippled
Loading...
Searching...
No Matches
TxMeta.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_TX_TRANSACTIONMETA_H_INCLUDED
21#define RIPPLE_APP_TX_TRANSACTIONMETA_H_INCLUDED
22
23#include <xrpl/beast/utility/Journal.h>
24#include <xrpl/protocol/STArray.h>
25#include <xrpl/protocol/STLedgerEntry.h>
26#include <xrpl/protocol/TER.h>
27
28#include <boost/container/flat_set.hpp>
29
30#include <optional>
31
32namespace ripple {
33
34class TxMeta
35{
36private:
38 {
39 explicit CtorHelper() = default;
40 };
41 template <class T>
42 TxMeta(
43 uint256 const& txID,
44 std::uint32_t ledger,
45 T const& data,
47
48public:
49 TxMeta(
51 std::uint32_t ledger,
52 std::optional<uint256> parentBatchId = std::nullopt);
53 TxMeta(uint256 const& txID, std::uint32_t ledger, Blob const&);
54 TxMeta(uint256 const& txID, std::uint32_t ledger, std::string const&);
55 TxMeta(uint256 const& txID, std::uint32_t ledger, STObject const&);
56
57 uint256 const&
58 getTxID() const
59 {
60 return mTransactionID;
61 }
63 getLgrSeq() const
64 {
65 return mLedger;
66 }
67 int
68 getResult() const
69 {
70 return mResult;
71 }
72 TER
74 {
75 return TER::fromInt(mResult);
76 }
78 getIndex() const
79 {
80 return mIndex;
81 }
82
83 void
84 setAffectedNode(uint256 const&, SField const& type, std::uint16_t nodeType);
86 getAffectedNode(SLE::ref node, SField const& type); // create if needed
89
91 boost::container::flat_set<AccountID>
92 getAffectedAccounts() const;
93
96 {
97 return getAsObject().getJson(p);
98 }
99 void
101
103 getAsObject() const;
104 STArray&
106 {
107 return (mNodes);
108 }
109 STArray const&
110 getNodes() const
111 {
112 return (mNodes);
113 }
114
115 void
116 setDeliveredAmount(STAmount const& delivered)
117 {
118 mDelivered = delivered;
119 }
120
123 {
124 XRPL_ASSERT(
126 "ripple::TxMeta::getDeliveredAmount : non-null delivered amount");
127 return *mDelivered;
128 }
129
130 bool
132 {
133 return static_cast<bool>(mDelivered);
134 }
135
136 void
137 setParentBatchId(uint256 const& parentBatchId)
138 {
139 mParentBatchId = parentBatchId;
140 }
141
142 uint256
144 {
145 XRPL_ASSERT(
147 "ripple::TxMeta::getParentBatchId : non-null batch id");
148 return *mParentBatchId;
149 }
150
151 bool
153 {
154 return static_cast<bool>(mParentBatchId);
155 }
156
157private:
162
165
167};
168
169} // namespace ripple
170
171#endif
Represents a JSON value.
Definition json_value.h:149
Identifies fields.
Definition SField.h:144
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STObject.cpp:825
static constexpr TERSubset fromInt(int from)
Definition TER.h:429
uint256 getParentBatchId() const
Definition TxMeta.h:143
std::optional< STAmount > mDelivered
Definition TxMeta.h:163
STArray const & getNodes() const
Definition TxMeta.h:110
STArray mNodes
Definition TxMeta.h:166
std::optional< uint256 > mParentBatchId
Definition TxMeta.h:164
bool hasDeliveredAmount() const
Definition TxMeta.h:131
STAmount getDeliveredAmount() const
Definition TxMeta.h:122
STArray & getNodes()
Definition TxMeta.h:105
uint256 mTransactionID
Definition TxMeta.h:158
std::uint32_t getIndex() const
Definition TxMeta.h:78
int getResult() const
Definition TxMeta.h:68
void setAffectedNode(uint256 const &, SField const &type, std::uint16_t nodeType)
Definition TxMeta.cpp:115
STObject getAsObject() const
Definition TxMeta.cpp:247
std::uint32_t getLgrSeq() const
Definition TxMeta.h:63
void setDeliveredAmount(STAmount const &delivered)
Definition TxMeta.h:116
Json::Value getJson(JsonOptions p) const
Definition TxMeta.h:95
TER getResultTER() const
Definition TxMeta.h:73
std::uint32_t mLedger
Definition TxMeta.h:159
std::uint32_t mIndex
Definition TxMeta.h:160
uint256 const & getTxID() const
Definition TxMeta.h:58
void setParentBatchId(uint256 const &parentBatchId)
Definition TxMeta.h:137
boost::container::flat_set< AccountID > getAffectedAccounts() const
Return a list of accounts affected by this transaction.
Definition TxMeta.cpp:142
void addRaw(Serializer &, TER, std::uint32_t index)
Definition TxMeta.cpp:264
STObject & getAffectedNode(SLE::ref node, SField const &type)
Definition TxMeta.cpp:213
bool hasParentBatchId() const
Definition TxMeta.h:152
T is_same_v
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:25
@ transactionID
transaction plus signature to give transaction ID
Note, should be treated as flags that can be | and &.
Definition STBase.h:37