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#include <boost/container/flat_set.hpp>
28#include <optional>
29
30namespace ripple {
31
32class TxMeta
33{
34private:
36 {
37 explicit CtorHelper() = default;
38 };
39 template <class T>
40 TxMeta(
41 uint256 const& txID,
42 std::uint32_t ledger,
43 T const& data,
45
46public:
48 TxMeta(uint256 const& txID, std::uint32_t ledger, Blob const&);
49 TxMeta(uint256 const& txID, std::uint32_t ledger, std::string const&);
50 TxMeta(uint256 const& txID, std::uint32_t ledger, STObject const&);
51
52 uint256 const&
53 getTxID() const
54 {
55 return mTransactionID;
56 }
58 getLgrSeq() const
59 {
60 return mLedger;
61 }
62 int
63 getResult() const
64 {
65 return mResult;
66 }
67 TER
69 {
70 return TER::fromInt(mResult);
71 }
73 getIndex() const
74 {
75 return mIndex;
76 }
77
78 void
79 setAffectedNode(uint256 const&, SField const& type, std::uint16_t nodeType);
81 getAffectedNode(SLE::ref node, SField const& type); // create if needed
84
86 boost::container::flat_set<AccountID>
87 getAffectedAccounts() const;
88
91 {
92 return getAsObject().getJson(p);
93 }
94 void
96
98 getAsObject() const;
99 STArray&
101 {
102 return (mNodes);
103 }
104 STArray const&
105 getNodes() const
106 {
107 return (mNodes);
108 }
109
110 void
111 setDeliveredAmount(STAmount const& delivered)
112 {
113 mDelivered = delivered;
114 }
115
118 {
119 XRPL_ASSERT(
121 "ripple::TxMeta::getDeliveredAmount : non-null delivered amount");
122 return *mDelivered;
123 }
124
125 bool
127 {
128 return static_cast<bool>(mDelivered);
129 }
130
131private:
136
138
140};
141
142} // namespace ripple
143
144#endif
Represents a JSON value.
Definition: json_value.h:147
Identifies fields.
Definition: SField.h:144
Json::Value getJson(JsonOptions options) const override
Definition: STObject.cpp:795
static constexpr TERSubset fromInt(int from)
Definition: TER.h:411
std::optional< STAmount > mDelivered
Definition: TxMeta.h:137
STArray const & getNodes() const
Definition: TxMeta.h:105
STArray mNodes
Definition: TxMeta.h:139
bool hasDeliveredAmount() const
Definition: TxMeta.h:126
STAmount getDeliveredAmount() const
Definition: TxMeta.h:117
STArray & getNodes()
Definition: TxMeta.h:100
uint256 mTransactionID
Definition: TxMeta.h:132
std::uint32_t getIndex() const
Definition: TxMeta.h:73
int getResult() const
Definition: TxMeta.h:63
void setAffectedNode(uint256 const &, SField const &type, std::uint16_t nodeType)
Definition: TxMeta.cpp:92
STObject getAsObject() const
Definition: TxMeta.cpp:212
std::uint32_t getLgrSeq() const
Definition: TxMeta.h:58
void setDeliveredAmount(STAmount const &delivered)
Definition: TxMeta.h:111
Json::Value getJson(JsonOptions p) const
Definition: TxMeta.h:90
TER getResultTER() const
Definition: TxMeta.h:68
std::uint32_t mLedger
Definition: TxMeta.h:133
std::uint32_t mIndex
Definition: TxMeta.h:134
uint256 const & getTxID() const
Definition: TxMeta.h:53
boost::container::flat_set< AccountID > getAffectedAccounts() const
Return a list of accounts affected by this transaction.
Definition: TxMeta.cpp:119
void addRaw(Serializer &, TER, std::uint32_t index)
Definition: TxMeta.cpp:225
STObject & getAffectedNode(SLE::ref node, SField const &type)
Definition: TxMeta.cpp:178
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: algorithm.h:26
@ transactionID
transaction plus signature to give transaction ID
Note, should be treated as flags that can be | and &.
Definition: STBase.h:36