mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
It makes much more sense this way:
LedgerEngine: Performs high-level ledger operations. TransactionEngine: Performs high-level transaction operations.
This commit is contained in:
45
src/LedgerEngine.h
Normal file
45
src/LedgerEngine.h
Normal file
@@ -0,0 +1,45 @@
|
||||
#ifndef __LEDGERENGINE__
|
||||
#define __LEDGERENGINE__
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <boost/shared_ptr.hpp>
|
||||
|
||||
#include "uint256.h"
|
||||
#include "Ledger.h"
|
||||
#include "Currency.h"
|
||||
#include "SerializedLedger.h"
|
||||
|
||||
// A LedgerEngine handles high-level operations to a ledger
|
||||
|
||||
enum LedgerEngineParms
|
||||
{
|
||||
lepCREATE = 1, // Create if not present
|
||||
};
|
||||
|
||||
class LedgerEngine
|
||||
{
|
||||
public:
|
||||
typedef boost::shared_ptr<LedgerEngine> pointer;
|
||||
|
||||
protected:
|
||||
Ledger::pointer mLedger;
|
||||
|
||||
public:
|
||||
LedgerEngine() { ; }
|
||||
LedgerEngine(Ledger::pointer l) : mLedger(l) { ; }
|
||||
|
||||
Ledger::pointer getTargetLedger() { return mLedger; }
|
||||
void setTargetLedger(Ledger::pointer ledger) { mLedger = ledger; }
|
||||
|
||||
SerializedLedgerEntry::pointer getAccountRoot(LedgerEngineParms parms, const uint160& accountID);
|
||||
|
||||
SerializedLedgerEntry::pointer getNickname(LedgerEngineParms parms, const std::string& nickname);
|
||||
SerializedLedgerEntry::pointer getNickname(LedgerEngineParms parms, const uint256& nickHash);
|
||||
|
||||
SerializedLedgerEntry::pointer getRippleState(LedgerEngineParms parms, const uint160& offeror,
|
||||
const uint160& borrower, const Currency& currency);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -2,6 +2,8 @@
|
||||
#define __TRANSACTIONENGINE__
|
||||
|
||||
#include "Ledger.h"
|
||||
#include "LedgerEngine.h"
|
||||
#include "Currency.h"
|
||||
#include "SerializedTransaction.h"
|
||||
#include "SerializedLedger.h"
|
||||
|
||||
@@ -32,7 +34,7 @@ enum TransactionEngineParams
|
||||
class TransactionEngine
|
||||
{
|
||||
protected:
|
||||
Ledger::pointer mTargetLedger;
|
||||
LedgerEngine::pointer mTxnEngine;
|
||||
|
||||
TransactionEngineResult doPayment(const SerializedTransaction&, SerializedLedgerEntry& source);
|
||||
TransactionEngineResult doInvoice(const SerializedTransaction&, SerializedLedgerEntry& source);
|
||||
@@ -43,10 +45,11 @@ protected:
|
||||
TransactionEngineResult doDelete(const SerializedTransaction&, SerializedLedgerEntry& source);
|
||||
|
||||
public:
|
||||
TransactionEngine(Ledger::pointer targetLedger) : mTargetLedger(targetLedger) { ; }
|
||||
TransactionEngine() { ; }
|
||||
TransactionEngine(LedgerEngine::pointer txnEngine) : mTxnEngine(txnEngine) { ; }
|
||||
|
||||
Ledger::pointer getTargetLedger() { return mTargetLedger; }
|
||||
void setTargetLedger(Ledger::pointer targetLedger) { mTargetLedger = targetLedger; }
|
||||
LedgerEngine::pointer getLedgerEngine() { return mTxnEngine; }
|
||||
void setLedgerEngine(LedgerEngine::pointer engine) { mTxnEngine = engine; }
|
||||
|
||||
TransactionEngineResult applyTransaction(const SerializedTransaction&, TransactionEngineParams);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user