mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Work on offer backend.
This commit is contained in:
@@ -46,8 +46,8 @@ LedgerEntryFormat LedgerFormats[]=
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(Account), STI_ACCOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Sequence), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountIn), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountOut), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerPays), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerGets), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(OwnerNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(BookNode), STI_UINT64, SOE_REQUIRED, 0 },
|
||||
|
||||
@@ -30,8 +30,6 @@ enum SOE_Field
|
||||
sfAccount,
|
||||
sfAccountID,
|
||||
sfAmount,
|
||||
sfAmountIn,
|
||||
sfAmountOut,
|
||||
sfAuthorizedKey,
|
||||
sfBalance,
|
||||
sfBookNode,
|
||||
@@ -52,6 +50,7 @@ enum SOE_Field
|
||||
sfFlags,
|
||||
sfGenerator,
|
||||
sfGeneratorID,
|
||||
sfGetsIssuer,
|
||||
sfHash,
|
||||
sfHighID,
|
||||
sfHighLimit,
|
||||
@@ -60,8 +59,6 @@ enum SOE_Field
|
||||
sfIndexNext,
|
||||
sfIndexPrevious,
|
||||
sfInvoiceID,
|
||||
sfIssuerIn,
|
||||
sfIssuerOut,
|
||||
sfLastNode,
|
||||
sfLastReceive,
|
||||
sfLastTxn,
|
||||
@@ -81,6 +78,7 @@ enum SOE_Field
|
||||
sfOfferSequence,
|
||||
sfOwnerNode,
|
||||
sfPaths,
|
||||
sfPaysIssuer,
|
||||
sfPubKey,
|
||||
sfQualityIn,
|
||||
sfQualityOut,
|
||||
@@ -89,6 +87,8 @@ enum SOE_Field
|
||||
sfSignature,
|
||||
sfSigningKey,
|
||||
sfSourceTag,
|
||||
sfTakerGets,
|
||||
sfTakerPays,
|
||||
sfTarget,
|
||||
sfTargetLedger,
|
||||
sfTransferRate,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -89,10 +89,11 @@ enum TransactionEngineParams
|
||||
|
||||
enum TransactionAccountAction
|
||||
{
|
||||
taaACCESS,
|
||||
taaNONE,
|
||||
taaCREATE,
|
||||
taaMODIFY,
|
||||
taaDELETE
|
||||
taaDELETE,
|
||||
taaUNFUNDED,
|
||||
};
|
||||
|
||||
typedef std::pair<TransactionAccountAction, SerializedLedgerEntry::pointer> AffectedAccount;
|
||||
@@ -100,14 +101,19 @@ typedef std::pair<TransactionAccountAction, SerializedLedgerEntry::pointer> Affe
|
||||
class TransactionEngine
|
||||
{
|
||||
private:
|
||||
typedef boost::unordered_map<SLE::pointer, TransactionAccountAction> entryMap;
|
||||
typedef boost::unordered_map<SLE::pointer, TransactionAccountAction>::iterator entryMap_iterator;
|
||||
typedef boost::unordered_map<SLE::pointer, TransactionAccountAction>::const_iterator entryMap_const_iterator;
|
||||
typedef boost::unordered_map<SLE::pointer, TransactionAccountAction>::iterator::value_type entryMap_value_type;
|
||||
|
||||
TransactionEngineResult dirAdd(
|
||||
std::vector<AffectedAccount>& accounts,
|
||||
entryMap& emEntries,
|
||||
uint64& uNodeDir, // Node of entry.
|
||||
const uint256& uRootIndex,
|
||||
const uint256& uLedgerIndex);
|
||||
|
||||
TransactionEngineResult dirDelete(
|
||||
std::vector<AffectedAccount>& accounts,
|
||||
entryMap& emEntries,
|
||||
const uint64& uNodeDir, // Node item is mentioned in.
|
||||
const uint256& uRootIndex,
|
||||
const uint256& uLedgerIndex); // Item being deleted
|
||||
@@ -135,33 +141,51 @@ private:
|
||||
} paymentGroup;
|
||||
#endif
|
||||
|
||||
TransactionEngineResult setAuthorized(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts, bool bMustSetGenerator);
|
||||
TransactionEngineResult setAuthorized(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc, bool bMustSetGenerator);
|
||||
|
||||
TransactionEngineResult takeOffers(
|
||||
entryMap& emEntries,
|
||||
bool bPassive,
|
||||
const uint256& uBookBase,
|
||||
const uint160& uTakerAccountID,
|
||||
const STAmount& saTakerPays,
|
||||
const STAmount& saTakerGets,
|
||||
const STAmount& saTakerFunds,
|
||||
STAmount& saTakerPaid,
|
||||
STAmount& saTakerGot);
|
||||
|
||||
protected:
|
||||
Ledger::pointer mDefaultLedger, mAlternateLedger;
|
||||
Ledger::pointer mLedger;
|
||||
uint64 mLedgerParentCloseTime;
|
||||
|
||||
TransactionEngineResult doAccountSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doClaim(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doCreditSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doDelete(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doInvoice(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doOfferCreate(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doOfferCancel(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doNicknameSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doPasswordFund(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doPasswordSet(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doPayment(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts,
|
||||
const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doStore(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doTake(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
TransactionEngineResult doWalletAdd(const SerializedTransaction& txn, std::vector<AffectedAccount>& accounts);
|
||||
entryMap mEntries;
|
||||
|
||||
SLE::pointer entryCreate(LedgerEntryType letType);
|
||||
void entryDelete(SLE::pointer sleEntry);
|
||||
void entryModify(SLE::pointer sleEntry);
|
||||
void entryUnfunded(SLE::pointer sleEntry);
|
||||
bool entryExists(SLE::pointer sleEntry);
|
||||
|
||||
STAmount rippleBalance(const uint160& uAccountID, const uint160& uIssuerAccountID, const uint160& uCurrency);
|
||||
|
||||
void rippleCredit(entryMap& emEntries, const uint160& uAccountID, const uint160& uIssuerAccountID, const uint160& uCurrency, const STAmount& saCredit);
|
||||
void rippleDebit(entryMap& emEntries, const uint160& uAccountID, const uint160& uIssuerAccountID, const uint160& uCurrency, const STAmount& saDebit);
|
||||
|
||||
TransactionEngineResult doAccountSet(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc);
|
||||
TransactionEngineResult doClaim(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc);
|
||||
TransactionEngineResult doCreditSet(const SerializedTransaction& txn, entryMap& emEntries, const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doDelete(const SerializedTransaction& txn, entryMap& emEntries);
|
||||
TransactionEngineResult doInvoice(const SerializedTransaction& txn, entryMap& emEntries);
|
||||
TransactionEngineResult doOfferCreate(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc, const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doOfferCancel(const SerializedTransaction& txn, entryMap& emEntries, const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doNicknameSet(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc, const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doPasswordFund(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc, const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doPasswordSet(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc);
|
||||
TransactionEngineResult doPayment(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc, const uint160& uSrcAccountID);
|
||||
TransactionEngineResult doStore(const SerializedTransaction& txn, entryMap& emEntries);
|
||||
TransactionEngineResult doTake(const SerializedTransaction& txn, entryMap& emEntries);
|
||||
TransactionEngineResult doWalletAdd(const SerializedTransaction& txn, entryMap& emEntries, SLE::pointer sleSrc);
|
||||
|
||||
public:
|
||||
TransactionEngine() { ; }
|
||||
|
||||
@@ -56,8 +56,8 @@ TransactionFormat InnerTxnFormats[]=
|
||||
},
|
||||
{ "OfferCreate", ttOFFER_CREATE, {
|
||||
{ S_FIELD(Flags), STI_UINT32, SOE_FLAGS, 0 },
|
||||
{ S_FIELD(AmountIn), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(AmountOut), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerPays), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(TakerGets), STI_AMOUNT, SOE_REQUIRED, 0 },
|
||||
{ S_FIELD(SourceTag), STI_UINT32, SOE_IFFLAG, 1 },
|
||||
{ S_FIELD(Destination), STI_ACCOUNT, SOE_IFFLAG, 2 },
|
||||
{ S_FIELD(Expiration), STI_UINT32, SOE_IFFLAG, 4 },
|
||||
|
||||
Reference in New Issue
Block a user