forked from stellar/stellar-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTxSetFrame.h
93 lines (67 loc) · 2.42 KB
/
TxSetFrame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#pragma once
// Copyright 2014 Stellar Development Foundation and contributors. Licensed
// under the Apache License, Version 2.0. See the COPYING file at the root
// of this distribution or at http://www.apache.org/licenses/LICENSE-2.0
#include "ledger/LedgerHashUtils.h"
#include "overlay/StellarXDR.h"
#include "transactions/TransactionFrame.h"
#include <deque>
#include <functional>
#include <unordered_map>
namespace stellar
{
class Application;
class TxSetFrame;
typedef std::shared_ptr<TxSetFrame> TxSetFramePtr;
class TxSetFrame
{
bool mHashIsValid;
Hash mHash;
Hash mPreviousLedgerHash;
using AccountTransactionQueue = std::deque<TransactionFramePtr>;
bool checkOrTrim(Application& app,
std::function<bool(TransactionFramePtr, SequenceNumber)>
processInvalidTxLambda,
std::function<bool(std::deque<TransactionFramePtr> const&)>
processLastInvalidTxLambda);
std::unordered_map<AccountID, AccountTransactionQueue>
buildAccountTxQueues();
friend struct SurgeCompare;
public:
std::vector<TransactionFramePtr> mTransactions;
TxSetFrame(Hash const& previousLedgerHash);
TxSetFrame(TxSetFrame const& other) = default;
// make it from the wire
TxSetFrame(Hash const& networkID, TransactionSet const& xdrSet);
// returns the hash of this tx set
Hash getContentsHash();
Hash& previousLedgerHash();
Hash const& previousLedgerHash() const;
void sortForHash();
std::vector<TransactionFramePtr> sortForApply();
bool checkValid(Application& app);
// remove invalid transaction from this set and return those removed
// transactions
std::vector<TransactionFramePtr> trimInvalid(Application& app);
void surgePricingFilter(Application& app);
void removeTx(TransactionFramePtr tx);
void
add(TransactionFramePtr tx)
{
mTransactions.push_back(tx);
mHashIsValid = false;
}
size_t size(LedgerHeader const& lh) const;
size_t
sizeTx() const
{
return mTransactions.size();
}
size_t sizeOp() const;
// return the base fee associated with this transaction set
int64_t getBaseFee(LedgerHeader const& lh) const;
// return the sum of all fees that this transaction set would take
int64_t getTotalFees(LedgerHeader const& lh) const;
void toXDR(TransactionSet& set);
};
} // namespace stellar