mirror of
https://github.com/XRPLF/rippled.git
synced 2026-06-05 17:56:49 +00:00
This change reorganizes the `tx/transactors` directory for consistency and discoverability. There are no behavioral changes, this is a pure refactor. Underscores were chosen as the way to separate multi-words as this is the more popular option in C++ projects. Specific changes: - Rename all subdirectories to lowercase/snake_case (`AMM` → `amm`, `Check` → `check`, `NFT` → `nft`, `PermissionedDomain` → `permissioned_domain`, etc.) - Merge `AMM/` and `Offer/` into `dex/`, including `PermissionedDEXHelpers` - Rename `MPT/` → `token/`, absorbing `SetTrust` and `Clawback` - Move top-level transactors into named groups: `account/`, `bridge/`, `credentials/`, `did/`, `escrow/`, `oracle/`, `payment/`, `payment_channel/`, `system/` - Update all include paths across the codebase and `transactions.macro`
97 lines
2.0 KiB
C++
97 lines
2.0 KiB
C++
#pragma once
|
|
|
|
#include <xrpl/protocol/AccountID.h>
|
|
|
|
#include <cstdint>
|
|
|
|
namespace xrpl {
|
|
|
|
/** Maintains AMM info per overall payment engine execution and
|
|
* individual iteration.
|
|
* Only one instance of this class is created in Flow.cpp::flow().
|
|
* The reference is percolated through calls to AMMLiquidity class,
|
|
* which handles AMM offer generation.
|
|
*/
|
|
class AMMContext
|
|
{
|
|
public:
|
|
// Restrict number of AMM offers. If this restriction is removed
|
|
// then need to restrict in some other way because AMM offers are
|
|
// not counted in the BookStep offer counter.
|
|
constexpr static std::uint8_t MaxIterations = 30;
|
|
|
|
private:
|
|
// Tx account owner is required to get the AMM trading fee in BookStep
|
|
AccountID account_;
|
|
// true if payment has multiple paths
|
|
bool multiPath_{false};
|
|
// Is true if AMM offer is consumed during a payment engine iteration.
|
|
bool ammUsed_{false};
|
|
// Counter of payment engine iterations with consumed AMM
|
|
std::uint16_t ammIters_{0};
|
|
|
|
public:
|
|
AMMContext(AccountID const& account, bool multiPath) : account_(account), multiPath_(multiPath)
|
|
{
|
|
}
|
|
~AMMContext() = default;
|
|
AMMContext(AMMContext const&) = delete;
|
|
AMMContext&
|
|
operator=(AMMContext const&) = delete;
|
|
|
|
bool
|
|
multiPath() const
|
|
{
|
|
return multiPath_;
|
|
}
|
|
|
|
void
|
|
setMultiPath(bool fs)
|
|
{
|
|
multiPath_ = fs;
|
|
}
|
|
|
|
void
|
|
setAMMUsed()
|
|
{
|
|
ammUsed_ = true;
|
|
}
|
|
|
|
void
|
|
update()
|
|
{
|
|
if (ammUsed_)
|
|
++ammIters_;
|
|
ammUsed_ = false;
|
|
}
|
|
|
|
bool
|
|
maxItersReached() const
|
|
{
|
|
return ammIters_ >= MaxIterations;
|
|
}
|
|
|
|
std::uint16_t
|
|
curIters() const
|
|
{
|
|
return ammIters_;
|
|
}
|
|
|
|
AccountID
|
|
account() const
|
|
{
|
|
return account_;
|
|
}
|
|
|
|
/** Strand execution may fail. Reset the flag at the start
|
|
* of each payment engine iteration.
|
|
*/
|
|
void
|
|
clear()
|
|
{
|
|
ammUsed_ = false;
|
|
}
|
|
};
|
|
|
|
} // namespace xrpl
|