mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Remove more Account from AccountStateNode and LedgerEntrySet revision.
This commit is contained in:
@@ -10,12 +10,12 @@
|
||||
#include "Ledger.h"
|
||||
#include "Serializer.h"
|
||||
|
||||
AccountState::AccountState(const NewcoinAddress& id) : mAccountID(id), mValid(false)
|
||||
AccountState::AccountState(const NewcoinAddress& id) : mValid(false)
|
||||
{
|
||||
if (!id.isValid()) return;
|
||||
mLedgerEntry = boost::make_shared<SerializedLedgerEntry>(ltACCOUNT_ROOT);
|
||||
mLedgerEntry->setIndex(Ledger::getAccountRootIndex(id));
|
||||
mLedgerEntry->setIFieldAccount(sfAccount, id);
|
||||
|
||||
mValid = true;
|
||||
}
|
||||
|
||||
@@ -23,9 +23,8 @@ AccountState::AccountState(SerializedLedgerEntry::pointer ledgerEntry) : mLedger
|
||||
{
|
||||
if (!mLedgerEntry) return;
|
||||
if (mLedgerEntry->getType() != ltACCOUNT_ROOT) return;
|
||||
mAccountID = mLedgerEntry->getIValueFieldAccount(sfAccount);
|
||||
if (mAccountID.isValid())
|
||||
mValid = true;
|
||||
|
||||
mValid = true;
|
||||
}
|
||||
|
||||
std::string AccountState::createGravatarUrl(uint128 uEmailHash)
|
||||
|
||||
@@ -21,7 +21,6 @@ public:
|
||||
typedef boost::shared_ptr<AccountState> pointer;
|
||||
|
||||
private:
|
||||
NewcoinAddress mAccountID;
|
||||
NewcoinAddress mAuthorizedKey;
|
||||
SerializedLedgerEntry::pointer mLedgerEntry;
|
||||
|
||||
@@ -41,7 +40,6 @@ public:
|
||||
return mLedgerEntry->getIValueFieldAccount(sfAuthorizedKey);
|
||||
}
|
||||
|
||||
const NewcoinAddress& getAccountID() const { return mAccountID; }
|
||||
STAmount getBalance() const { return mLedgerEntry->getIValueFieldAmount(sfBalance); }
|
||||
uint32 getSeq() const { return mLedgerEntry->getIFieldU32(sfSequence); }
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ LedgerEntrySet LedgerEntrySet::duplicate() const
|
||||
return LedgerEntrySet(mEntries, mSet, mSeq + 1);
|
||||
}
|
||||
|
||||
void LedgerEntrySet::setTo(LedgerEntrySet& e)
|
||||
void LedgerEntrySet::setTo(const LedgerEntrySet& e)
|
||||
{
|
||||
mEntries = e.mEntries;
|
||||
mSet = e.mSet;
|
||||
|
||||
@@ -42,7 +42,7 @@ public:
|
||||
|
||||
// set functions
|
||||
LedgerEntrySet duplicate() const; // Make a duplicate of this set
|
||||
void setTo(LedgerEntrySet&); // Set this set to have the same contents as another
|
||||
void setTo(const LedgerEntrySet&); // Set this set to have the same contents as another
|
||||
void swapWith(LedgerEntrySet&); // Swap the contents of two sets
|
||||
|
||||
int getSeq() const { return mSeq; }
|
||||
|
||||
@@ -342,6 +342,7 @@ public:
|
||||
static STAmount multiply(const STAmount& v1, const STAmount& v2, const uint160& currencyOut);
|
||||
|
||||
// Someone is offering X for Y, what is the rate?
|
||||
// Rate: smaller is better, the taker wants the most out: in/out
|
||||
static uint64 getRate(const STAmount& offerOut, const STAmount& offerIn);
|
||||
static STAmount setRate(uint64 rate, const uint160& currencyOut);
|
||||
|
||||
|
||||
@@ -3221,6 +3221,8 @@ bool TransactionEngine::calcNode(unsigned int uIndex, PathState::pointer pspCur,
|
||||
}
|
||||
|
||||
// Calculate the next increment of a path.
|
||||
// The increment is what can satisfy a portion or all of the requested output at the best quality.
|
||||
// <-- pspCur->uQuality
|
||||
void TransactionEngine::pathNext(PathState::pointer pspCur, int iPaths)
|
||||
{
|
||||
// The next state is what is available in preference order.
|
||||
@@ -3228,20 +3230,18 @@ void TransactionEngine::pathNext(PathState::pointer pspCur, int iPaths)
|
||||
|
||||
unsigned int uLast = pspCur->vpnNodes.size() - 1;
|
||||
|
||||
pspCur->lesEntries = mNodes.duplicate(); // Checkpoint state?
|
||||
|
||||
if (!calcNode(uLast, pspCur, iPaths == 1))
|
||||
if (calcNode(uLast, pspCur, iPaths == 1))
|
||||
{
|
||||
// Calculate relative quality.
|
||||
pspCur->uQuality = STAmount::getRate(pspCur->saOutAct, pspCur->saInAct);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Mark path as inactive.
|
||||
pspCur->uQuality = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply an increment of the path, then calculate the next increment.
|
||||
void TransactionEngine::pathApply(PathState::pointer pspCur)
|
||||
{
|
||||
}
|
||||
|
||||
// XXX Need to audit for things like setting accountID not having memory.
|
||||
TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction& txn)
|
||||
{
|
||||
@@ -3484,23 +3484,28 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
||||
while (tenUNKNOWN == terResult)
|
||||
{
|
||||
PathState::pointer pspBest;
|
||||
LedgerEntrySet lesCheckpoint;
|
||||
|
||||
mNodes.swapWith(lesCheckpoint); // Checkpoint ledger prior to path application.
|
||||
|
||||
// Find the best path.
|
||||
BOOST_FOREACH(PathState::pointer pspCur, vpsPaths)
|
||||
{
|
||||
mNodes.setTo(lesCheckpoint.duplicate()); // Vary ledger from checkpoint.
|
||||
|
||||
pathNext(pspCur, vpsPaths.size()); // Compute increment
|
||||
|
||||
mNodes.swapWith(pspCur->lesEntries); // For the path, save ledger state.
|
||||
|
||||
if (!pspBest || (pspCur->uQuality && PathState::lessPriority(pspBest, pspCur)))
|
||||
pspBest = pspCur;
|
||||
}
|
||||
|
||||
if (!pspBest)
|
||||
if (pspBest)
|
||||
{
|
||||
//
|
||||
// Apply path.
|
||||
//
|
||||
// Apply best path.
|
||||
|
||||
// Install changes for path.
|
||||
// Install ledger for best past.
|
||||
mNodes.swapWith(pspBest->lesEntries);
|
||||
|
||||
// Figure out if done.
|
||||
@@ -3518,8 +3523,7 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
||||
else if (saPaid.isZero())
|
||||
{
|
||||
// Nothing claimed.
|
||||
terResult = terPATH_EMPTY; // XXX No effect except unfundeds and charge fee.
|
||||
// XXX
|
||||
terResult = terPATH_EMPTY; // XXX No effect except unfundeds and charge fee.
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -239,7 +239,6 @@ protected:
|
||||
STAmount accountFunds(const uint160& uAccountID, const STAmount& saDefault);
|
||||
|
||||
PathState::pointer pathCreate(const STPath& spPath);
|
||||
void pathApply(PathState::pointer pspCur);
|
||||
void pathNext(PathState::pointer pspCur, int iPaths);
|
||||
bool calcNode(unsigned int uIndex, PathState::pointer pspCur, bool bMultiQuality);
|
||||
bool calcNodeOfferRev(unsigned int uIndex, PathState::pointer pspCur, bool bMultiQuality);
|
||||
|
||||
Reference in New Issue
Block a user