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{
36public:
38 TxMeta(uint256 const& txID, std::uint32_t ledger, Blob const&);
39 TxMeta(uint256 const& txID, std::uint32_t ledger, STObject const&);
40
41 uint256 const&
42 getTxID() const
43 {
44 return transactionID_;
45 }
47 getLgrSeq() const
48 {
49 return ledgerSeq_;
50 }
51 int
52 getResult() const
53 {
54 return result_;
55 }
56 TER
58 {
59 return TER::fromInt(result_);
60 }
62 getIndex() const
63 {
64 return index_;
65 }
66
67 void
68 setAffectedNode(uint256 const&, SField const& type, std::uint16_t nodeType);
70 getAffectedNode(SLE::ref node, SField const& type); // create if needed
73
75 boost::container::flat_set<AccountID>
76 getAffectedAccounts() const;
77
80 {
81 return getAsObject().getJson(p);
82 }
83 void
85
87 getAsObject() const;
88 STArray&
90 {
91 return nodes_;
92 }
93 STArray const&
94 getNodes() const
95 {
96 return nodes_;
97 }
98
99 void
101 {
102 if (obj.isFieldPresent(sfDeliveredAmount))
103 deliveredAmount_ = obj.getFieldAmount(sfDeliveredAmount);
104
105 if (obj.isFieldPresent(sfParentBatchID))
106 parentBatchID_ = obj.getFieldH256(sfParentBatchID);
107 }
108
111 {
112 return deliveredAmount_;
113 }
114
115 void
117 {
118 deliveredAmount_ = amount;
119 }
120
121 void
126
127private:
132
135
137};
138
139} // namespace ripple
140
141#endif
Represents a JSON value.
Definition json_value.h:149
Identifies fields.
Definition SField.h:146
STAmount const & getFieldAmount(SField const &field) const
Definition STObject.cpp:671
bool isFieldPresent(SField const &field) const
Definition STObject.cpp:484
Json::Value getJson(JsonOptions=JsonOptions::none) const override
Definition STObject.cpp:853
uint256 getFieldH256(SField const &field) const
Definition STObject.cpp:645
static constexpr TERSubset fromInt(int from)
Definition TER.h:433
void setParentBatchID(std::optional< uint256 > const &id)
Definition TxMeta.h:122
STArray const & getNodes() const
Definition TxMeta.h:94
STArray & getNodes()
Definition TxMeta.h:89
std::optional< uint256 > parentBatchID_
Definition TxMeta.h:134
std::optional< STAmount > deliveredAmount_
Definition TxMeta.h:133
std::uint32_t index_
Definition TxMeta.h:130
std::uint32_t getIndex() const
Definition TxMeta.h:62
int getResult() const
Definition TxMeta.h:52
STArray nodes_
Definition TxMeta.h:136
void setAffectedNode(uint256 const &, SField const &type, std::uint16_t nodeType)
Definition TxMeta.cpp:85
STObject getAsObject() const
Definition TxMeta.cpp:220
uint256 transactionID_
Definition TxMeta.h:128
std::uint32_t getLgrSeq() const
Definition TxMeta.h:47
void setDeliveredAmount(std::optional< STAmount > const &amount)
Definition TxMeta.h:116
Json::Value getJson(JsonOptions p) const
Definition TxMeta.h:79
TER getResultTER() const
Definition TxMeta.h:57
uint256 const & getTxID() const
Definition TxMeta.h:42
void setAdditionalFields(STObject const &obj)
Definition TxMeta.h:100
std::uint32_t ledgerSeq_
Definition TxMeta.h:129
boost::container::flat_set< AccountID > getAffectedAccounts() const
Return a list of accounts affected by this transaction.
Definition TxMeta.cpp:112
void addRaw(Serializer &, TER, std::uint32_t index)
Definition TxMeta.cpp:237
STObject & getAffectedNode(SLE::ref node, SField const &type)
Definition TxMeta.cpp:184
std::optional< STAmount > const & getDeliveredAmount() const
Definition TxMeta.h:110
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