mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Merge ripple dirs with owner dirs and RPC fixes for setting quality.
This commit is contained in:
@@ -265,9 +265,6 @@ public:
|
|||||||
static uint256 getRippleStateIndex(const uint160& uiA, const uint160& uiB, const uint160& uCurrency)
|
static uint256 getRippleStateIndex(const uint160& uiA, const uint160& uiB, const uint160& uCurrency)
|
||||||
{ return getRippleStateIndex(NewcoinAddress::createAccountID(uiA), NewcoinAddress::createAccountID(uiB), uCurrency); }
|
{ return getRippleStateIndex(NewcoinAddress::createAccountID(uiA), NewcoinAddress::createAccountID(uiB), uCurrency); }
|
||||||
|
|
||||||
// Directory of lines indexed by an account (not all lines are indexed)
|
|
||||||
static uint256 getRippleDirIndex(const uint160& uAccountID);
|
|
||||||
|
|
||||||
RippleState::pointer accessRippleState(const uint256& uNode);
|
RippleState::pointer accessRippleState(const uint256& uNode);
|
||||||
|
|
||||||
SLE::pointer getRippleState(LedgerStateParms& parms, const uint256& uNode);
|
SLE::pointer getRippleState(LedgerStateParms& parms, const uint256& uNode);
|
||||||
|
|||||||
@@ -23,7 +23,6 @@ enum LedgerNameSpace
|
|||||||
spaceGenerator = 'g',
|
spaceGenerator = 'g',
|
||||||
spaceNickname = 'n',
|
spaceNickname = 'n',
|
||||||
spaceRipple = 'r',
|
spaceRipple = 'r',
|
||||||
spaceRippleDir = 'R',
|
|
||||||
spaceOffer = 'o', // Entry for an offer.
|
spaceOffer = 'o', // Entry for an offer.
|
||||||
spaceOwnerDir = 'O', // Directory of things owned by an account.
|
spaceOwnerDir = 'O', // Directory of things owned by an account.
|
||||||
spaceBookDir = 'B', // Directory of order books.
|
spaceBookDir = 'B', // Directory of order books.
|
||||||
@@ -38,10 +37,6 @@ enum LedgerSpecificFlags
|
|||||||
|
|
||||||
// ltOFFER
|
// ltOFFER
|
||||||
lsfPassive = 0x00010000,
|
lsfPassive = 0x00010000,
|
||||||
|
|
||||||
// ltRIPPLE_STATE
|
|
||||||
lsfLowIndexed = 0x00010000,
|
|
||||||
lsfHighIndexed = 0x00020000,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct LedgerEntryFormat
|
struct LedgerEntryFormat
|
||||||
|
|||||||
@@ -126,16 +126,6 @@ uint256 Ledger::getOwnerDirIndex(const uint160& uAccountID)
|
|||||||
return s.getSHA512Half();
|
return s.getSHA512Half();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint256 Ledger::getRippleDirIndex(const uint160& uAccountID)
|
|
||||||
{
|
|
||||||
Serializer s(22);
|
|
||||||
|
|
||||||
s.add16(spaceRippleDir); // 2
|
|
||||||
s.add160(uAccountID); // 20
|
|
||||||
|
|
||||||
return s.getSHA512Half();
|
|
||||||
}
|
|
||||||
|
|
||||||
uint256 Ledger::getRippleStateIndex(const NewcoinAddress& naA, const NewcoinAddress& naB, const uint160& uCurrency)
|
uint256 Ledger::getRippleStateIndex(const NewcoinAddress& naA, const NewcoinAddress& naB, const uint160& uCurrency)
|
||||||
{
|
{
|
||||||
uint160 uAID = naA.getAccountID();
|
uint160 uAID = naA.getAccountID();
|
||||||
|
|||||||
@@ -254,7 +254,7 @@ Json::Value NetworkOPs::getOwnerInfo(const uint256& uLedger, const NewcoinAddres
|
|||||||
|
|
||||||
Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddress& naAccount)
|
Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddress& naAccount)
|
||||||
{
|
{
|
||||||
Json::Value jvObjects(Json::arrayValue);
|
Json::Value jvObjects(Json::objectValue);
|
||||||
|
|
||||||
uint256 uRootIndex = lpLedger->getOwnerDirIndex(naAccount.getAccountID());
|
uint256 uRootIndex = lpLedger->getOwnerDirIndex(naAccount.getAccountID());
|
||||||
|
|
||||||
@@ -267,15 +267,37 @@ Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const NewcoinAddr
|
|||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||||
const std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
const std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||||
|
|
||||||
BOOST_FOREACH(const uint256& uDirEntry, vuiIndexes)
|
BOOST_FOREACH(const uint256& uDirEntry, vuiIndexes)
|
||||||
{
|
{
|
||||||
LedgerStateParms lspOffer = lepNONE;
|
SLE::pointer sleCur = lpLedger->getSLE(uDirEntry);
|
||||||
SLE::pointer sleOffer = lpLedger->getOffer(lspOffer, uDirEntry);
|
|
||||||
|
|
||||||
jvObjects.append(sleOffer->getJson(0));
|
switch (sleCur->getType())
|
||||||
|
{
|
||||||
|
case ltOFFER:
|
||||||
|
if (!jvObjects.isMember("offers"))
|
||||||
|
jvObjects["offers"] = Json::Value(Json::arrayValue);
|
||||||
|
|
||||||
|
jvObjects["offers"].append(sleCur->getJson(0));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ltRIPPLE_STATE:
|
||||||
|
if (!jvObjects.isMember("ripple_lines"))
|
||||||
|
jvObjects["ripple_lines"] = Json::Value(Json::arrayValue);
|
||||||
|
|
||||||
|
jvObjects["ripple_lines"].append(sleCur->getJson(0));
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ltACCOUNT_ROOT:
|
||||||
|
case ltDIR_NODE:
|
||||||
|
case ltGENERATOR_MAP:
|
||||||
|
case ltNICKNAME:
|
||||||
|
default:
|
||||||
|
assert(false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uNodeDir = sleNode->getIFieldU64(sfIndexNext);
|
uNodeDir = sleNode->getIFieldU64(sfIndexNext);
|
||||||
|
|||||||
@@ -1151,22 +1151,12 @@ Json::Value RPCServer::doOwnerInfo(const Json::Value& params)
|
|||||||
uint256 uAccepted = mNetOps->getClosedLedger();
|
uint256 uAccepted = mNetOps->getClosedLedger();
|
||||||
Json::Value jAccepted = accountFromString(uAccepted, naAccount, bIndex, strIdent, iIndex);
|
Json::Value jAccepted = accountFromString(uAccepted, naAccount, bIndex, strIdent, iIndex);
|
||||||
|
|
||||||
if (jAccepted.empty())
|
ret["accepted"] = jAccepted.empty() ? mNetOps->getOwnerInfo(uAccepted, naAccount) : jAccepted;
|
||||||
{
|
|
||||||
jAccepted["offers"] = mNetOps->getOwnerInfo(uAccepted, naAccount);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret["accepted"] = jAccepted;
|
|
||||||
|
|
||||||
uint256 uCurrent = mNetOps->getCurrentLedger();
|
uint256 uCurrent = mNetOps->getCurrentLedger();
|
||||||
Json::Value jCurrent = accountFromString(uCurrent, naAccount, bIndex, strIdent, iIndex);
|
Json::Value jCurrent = accountFromString(uCurrent, naAccount, bIndex, strIdent, iIndex);
|
||||||
|
|
||||||
if (jCurrent.empty())
|
ret["current"] = jCurrent.empty() ? mNetOps->getOwnerInfo(uCurrent, naAccount) : jCurrent;
|
||||||
{
|
|
||||||
jCurrent["offers"] = mNetOps->getOwnerInfo(uCurrent, naAccount);
|
|
||||||
}
|
|
||||||
|
|
||||||
ret["current"] = jCurrent;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1660,7 +1650,7 @@ Json::Value RPCServer::doRippleLinesGet(const Json::Value ¶ms)
|
|||||||
// We access a committed ledger and need not worry about changes.
|
// We access a committed ledger and need not worry about changes.
|
||||||
|
|
||||||
RippleLines rippleLines(naAccount.getAccountID());
|
RippleLines rippleLines(naAccount.getAccountID());
|
||||||
BOOST_FOREACH(RippleState::pointer line,rippleLines.getLines())
|
BOOST_FOREACH(RippleState::pointer line, rippleLines.getLines())
|
||||||
{
|
{
|
||||||
STAmount saBalance = line->getBalance();
|
STAmount saBalance = line->getBalance();
|
||||||
STAmount saLimit = line->getLimit();
|
STAmount saLimit = line->getLimit();
|
||||||
@@ -1668,15 +1658,17 @@ Json::Value RPCServer::doRippleLinesGet(const Json::Value ¶ms)
|
|||||||
|
|
||||||
Json::Value jPeer = Json::Value(Json::objectValue);
|
Json::Value jPeer = Json::Value(Json::objectValue);
|
||||||
|
|
||||||
//jPeer["node"] = uNode.ToString();
|
//jPeer["node"] = uNode.ToString();
|
||||||
|
|
||||||
jPeer["account"] = line->getAccountIDPeer().humanAccountID();
|
jPeer["account"] = line->getAccountIDPeer().humanAccountID();
|
||||||
// Amount reported is positive if current account holds other account's IOUs.
|
// Amount reported is positive if current account holds other account's IOUs.
|
||||||
// Amount reported is negative if other account holds current account's IOUs.
|
// Amount reported is negative if other account holds current account's IOUs.
|
||||||
jPeer["balance"] = saBalance.getText();
|
jPeer["balance"] = saBalance.getText();
|
||||||
jPeer["currency"] = saBalance.getHumanCurrency();
|
jPeer["currency"] = saBalance.getHumanCurrency();
|
||||||
jPeer["limit"] = saLimit.getText();
|
jPeer["limit"] = saLimit.getText();
|
||||||
jPeer["limit_peer"] = saLimitPeer.getText();
|
jPeer["limit_peer"] = saLimitPeer.getText();
|
||||||
|
jPeer["quality_in"] = static_cast<Json::UInt>(line->getQualityIn());
|
||||||
|
jPeer["quality_out"] = static_cast<Json::UInt>(line->getQualityOut());
|
||||||
|
|
||||||
jsonLines.append(jPeer);
|
jsonLines.append(jPeer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,34 +15,40 @@ RippleLines::RippleLines(const uint160& accountID )
|
|||||||
|
|
||||||
void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger)
|
void RippleLines::fillLines(const uint160& accountID, Ledger::pointer ledger)
|
||||||
{
|
{
|
||||||
uint256 rootIndex = Ledger::getRippleDirIndex(accountID);
|
uint256 rootIndex = Ledger::getOwnerDirIndex(accountID);
|
||||||
uint256 currentIndex=rootIndex;
|
uint256 currentIndex = rootIndex;
|
||||||
|
|
||||||
LedgerStateParms lspNode = lepNONE;
|
LedgerStateParms lspNode = lepNONE;
|
||||||
|
|
||||||
while(1)
|
while (1)
|
||||||
{
|
{
|
||||||
SerializedLedgerEntry::pointer rippleDir=ledger->getDirNode(lspNode,currentIndex);
|
SLE::pointer rippleDir=ledger->getDirNode(lspNode, currentIndex);
|
||||||
if(!rippleDir) return;
|
if (!rippleDir) return;
|
||||||
|
|
||||||
STVector256 svRippleNodes = rippleDir->getIFieldV256(sfIndexes);
|
STVector256 svOwnerNodes = rippleDir->getIFieldV256(sfIndexes);
|
||||||
BOOST_FOREACH(uint256& uNode, svRippleNodes.peekValue())
|
BOOST_FOREACH(uint256& uNode, svOwnerNodes.peekValue())
|
||||||
{
|
{
|
||||||
RippleState::pointer rsLine = ledger->accessRippleState(uNode);
|
SLE::pointer sleCur = ledger->getSLE(uNode);
|
||||||
if (rsLine)
|
|
||||||
|
if (ltRIPPLE_STATE == sleCur->getType())
|
||||||
{
|
{
|
||||||
rsLine->setViewAccount(accountID);
|
RippleState::pointer rsLine = ledger->accessRippleState(uNode);
|
||||||
mLines.push_back(rsLine);
|
if (rsLine)
|
||||||
}
|
{
|
||||||
else
|
rsLine->setViewAccount(accountID);
|
||||||
{
|
mLines.push_back(rsLine);
|
||||||
Log(lsWARNING) << "doRippleLinesGet: Bad index: " << uNode.ToString();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Log(lsWARNING) << "doRippleLinesGet: Bad index: " << uNode.ToString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 uNodeNext = rippleDir->getIFieldU64(sfIndexNext);
|
uint64 uNodeNext = rippleDir->getIFieldU64(sfIndexNext);
|
||||||
if(!uNodeNext) return;
|
if (!uNodeNext) return;
|
||||||
|
|
||||||
currentIndex = Ledger::getDirNodeIndex(rootIndex, uNodeNext);
|
currentIndex = Ledger::getDirNodeIndex(rootIndex, uNodeNext);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -7,11 +7,17 @@ RippleState::RippleState(SerializedLedgerEntry::pointer ledgerEntry) :
|
|||||||
{
|
{
|
||||||
if (!mLedgerEntry || mLedgerEntry->getType() != ltRIPPLE_STATE) return;
|
if (!mLedgerEntry || mLedgerEntry->getType() != ltRIPPLE_STATE) return;
|
||||||
|
|
||||||
mLowID = mLedgerEntry->getIValueFieldAccount(sfLowID);
|
mLowID = mLedgerEntry->getIValueFieldAccount(sfLowID);
|
||||||
mHighID = mLedgerEntry->getIValueFieldAccount(sfHighID);
|
mHighID = mLedgerEntry->getIValueFieldAccount(sfHighID);
|
||||||
|
|
||||||
mLowLimit = mLedgerEntry->getIValueFieldAmount(sfLowLimit);
|
mLowLimit = mLedgerEntry->getIValueFieldAmount(sfLowLimit);
|
||||||
mHighLimit = mLedgerEntry->getIValueFieldAmount(sfHighLimit);
|
mHighLimit = mLedgerEntry->getIValueFieldAmount(sfHighLimit);
|
||||||
|
|
||||||
|
mLowQualityIn = mLedgerEntry->getIFieldU32(sfLowQualityIn);
|
||||||
|
mLowQualityOut = mLedgerEntry->getIFieldU32(sfLowQualityOut);
|
||||||
|
|
||||||
|
mHighQualityIn = mLedgerEntry->getIFieldU32(sfHighQualityIn);
|
||||||
|
mHighQualityOut = mLedgerEntry->getIFieldU32(sfHighQualityOut);
|
||||||
|
|
||||||
mBalance = mLedgerEntry->getIValueFieldAmount(sfBalance);
|
mBalance = mLedgerEntry->getIValueFieldAmount(sfBalance);
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,11 @@ private:
|
|||||||
STAmount mLowLimit;
|
STAmount mLowLimit;
|
||||||
STAmount mHighLimit;
|
STAmount mHighLimit;
|
||||||
|
|
||||||
|
uint64 mLowQualityIn;
|
||||||
|
uint64 mLowQualityOut;
|
||||||
|
uint64 mHighQualityIn;
|
||||||
|
uint64 mHighQualityOut;
|
||||||
|
|
||||||
STAmount mBalance;
|
STAmount mBalance;
|
||||||
|
|
||||||
bool mValid;
|
bool mValid;
|
||||||
@@ -42,6 +47,9 @@ public:
|
|||||||
STAmount getLimit() const { return mViewLowest ? mLowLimit : mHighLimit; }
|
STAmount getLimit() const { return mViewLowest ? mLowLimit : mHighLimit; }
|
||||||
STAmount getLimitPeer() const { return mViewLowest ? mHighLimit : mLowLimit; }
|
STAmount getLimitPeer() const { return mViewLowest ? mHighLimit : mLowLimit; }
|
||||||
|
|
||||||
|
uint32 getQualityIn() const { return mViewLowest ? mLowQualityIn : mHighQualityIn; }
|
||||||
|
uint32 getQualityOut() const { return mViewLowest ? mLowQualityOut : mHighQualityOut; }
|
||||||
|
|
||||||
SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; }
|
SerializedLedgerEntry::pointer getSLE() { return mLedgerEntry; }
|
||||||
const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; }
|
const SerializedLedgerEntry& peekSLE() const { return *mLedgerEntry; }
|
||||||
SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; }
|
SerializedLedgerEntry& peekSLE() { return *mLedgerEntry; }
|
||||||
|
|||||||
@@ -270,10 +270,10 @@ Transaction::pointer Transaction::setCreditSet(
|
|||||||
mTransaction->setITFieldAmount(sfLimitAmount, saLimitAmount);
|
mTransaction->setITFieldAmount(sfLimitAmount, saLimitAmount);
|
||||||
|
|
||||||
if (bQualityIn)
|
if (bQualityIn)
|
||||||
mTransaction->setITFieldU32(sfAcceptRate, uQualityIn);
|
mTransaction->setITFieldU32(sfQualityIn, uQualityIn);
|
||||||
|
|
||||||
if (bQualityOut)
|
if (bQualityOut)
|
||||||
mTransaction->setITFieldU32(sfAcceptRate, uQualityOut);
|
mTransaction->setITFieldU32(sfQualityOut, uQualityOut);
|
||||||
|
|
||||||
sign(naPrivateKey);
|
sign(naPrivateKey);
|
||||||
|
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ STAmount TransactionEngine::rippleLimit(const uint160& uToAccountID, const uint1
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 TransactionEngine::rippleTransfer(const uint160& uIssuerID)
|
uint32 TransactionEngine::rippleTransferRate(const uint160& uIssuerID)
|
||||||
{
|
{
|
||||||
SLE::pointer sleAccount = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uIssuerID));
|
SLE::pointer sleAccount = entryCache(ltACCOUNT_ROOT, Ledger::getAccountRootIndex(uIssuerID));
|
||||||
|
|
||||||
@@ -298,13 +298,13 @@ STAmount TransactionEngine::accountFunds(const uint160& uAccountID, const STAmou
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Calculate transit fee.
|
// Calculate transit fee.
|
||||||
STAmount TransactionEngine::rippleTransfer(const uint160& uSenderID, const uint160& uReceiverID, const uint160& uIssuerID, const STAmount& saAmount)
|
STAmount TransactionEngine::rippleTransferFee(const uint160& uSenderID, const uint160& uReceiverID, const uint160& uIssuerID, const STAmount& saAmount)
|
||||||
{
|
{
|
||||||
STAmount saTransitFee;
|
STAmount saTransitFee;
|
||||||
|
|
||||||
if (uSenderID != uIssuerID && uReceiverID != uIssuerID)
|
if (uSenderID != uIssuerID && uReceiverID != uIssuerID)
|
||||||
{
|
{
|
||||||
uint32 uTransitRate = rippleTransfer(uIssuerID);
|
uint32 uTransitRate = rippleTransferRate(uIssuerID);
|
||||||
|
|
||||||
if (QUALITY_ONE != uTransitRate)
|
if (QUALITY_ONE != uTransitRate)
|
||||||
{
|
{
|
||||||
@@ -380,7 +380,7 @@ STAmount TransactionEngine::rippleSend(const uint160& uSenderID, const uint160&
|
|||||||
{
|
{
|
||||||
// Sending 3rd party IOUs: transit.
|
// Sending 3rd party IOUs: transit.
|
||||||
|
|
||||||
STAmount saTransitFee = rippleTransfer(uSenderID, uReceiverID, uIssuerID, saAmount);
|
STAmount saTransitFee = rippleTransferFee(uSenderID, uReceiverID, uIssuerID, saAmount);
|
||||||
|
|
||||||
saActual = saTransitFee.isZero() ? saAmount : saAmount+saTransitFee;
|
saActual = saTransitFee.isZero() ? saAmount : saAmount+saTransitFee;
|
||||||
|
|
||||||
@@ -1505,7 +1505,6 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool bFlipped = mTxnAccountID > uDstAccountID;
|
bool bFlipped = mTxnAccountID > uDstAccountID;
|
||||||
uint32 uFlags = bFlipped ? lsfLowIndexed : lsfHighIndexed;
|
|
||||||
bool bLimitAmount = txn.getITFieldPresent(sfLimitAmount);
|
bool bLimitAmount = txn.getITFieldPresent(sfLimitAmount);
|
||||||
STAmount saLimitAmount = bLimitAmount ? txn.getITFieldAmount(sfLimitAmount) : STAmount();
|
STAmount saLimitAmount = bLimitAmount ? txn.getITFieldAmount(sfLimitAmount) : STAmount();
|
||||||
bool bQualityIn = txn.getITFieldPresent(sfQualityIn);
|
bool bQualityIn = txn.getITFieldPresent(sfQualityIn);
|
||||||
@@ -1514,7 +1513,6 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
uint32 uQualityOut = bQualityIn ? txn.getITFieldU32(sfQualityOut) : 0;
|
uint32 uQualityOut = bQualityIn ? txn.getITFieldU32(sfQualityOut) : 0;
|
||||||
uint160 uCurrencyID = saLimitAmount.getCurrency();
|
uint160 uCurrencyID = saLimitAmount.getCurrency();
|
||||||
STAmount saBalance(uCurrencyID);
|
STAmount saBalance(uCurrencyID);
|
||||||
bool bAddIndex = false;
|
|
||||||
bool bDelIndex = false;
|
bool bDelIndex = false;
|
||||||
|
|
||||||
SLE::pointer sleRippleState = entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
|
SLE::pointer sleRippleState = entryCache(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
|
||||||
@@ -1540,7 +1538,7 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
// Zero balance and eliminating last limit.
|
// Zero balance and eliminating last limit.
|
||||||
|
|
||||||
bDelIndex = true;
|
bDelIndex = true;
|
||||||
terResult = dirDelete(false, uSrcRef, Ledger::getRippleDirIndex(mTxnAccountID), sleRippleState->getIndex());
|
terResult = dirDelete(false, uSrcRef, Ledger::getOwnerDirIndex(mTxnAccountID), sleRippleState->getIndex());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -1576,15 +1574,10 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
sleRippleState->makeIFieldAbsent(bFlipped ? sfLowQualityOut : sfHighQualityOut);
|
sleRippleState->makeIFieldAbsent(bFlipped ? sfLowQualityOut : sfHighQualityOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
bAddIndex = !(sleRippleState->getFlags() & uFlags);
|
|
||||||
|
|
||||||
if (bAddIndex)
|
|
||||||
sleRippleState->setFlag(uFlags);
|
|
||||||
|
|
||||||
entryModify(sleRippleState);
|
entryModify(sleRippleState);
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(lsINFO) << "doCreditSet: Modifying ripple line: bAddIndex=" << bAddIndex << " bDelIndex=" << bDelIndex;
|
Log(lsINFO) << "doCreditSet: Modifying ripple line: bDelIndex=" << bDelIndex;
|
||||||
}
|
}
|
||||||
// Line does not exist.
|
// Line does not exist.
|
||||||
else if (saLimitAmount.isZero())
|
else if (saLimitAmount.isZero())
|
||||||
@@ -1598,12 +1591,10 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
// Create a new ripple line.
|
// Create a new ripple line.
|
||||||
STAmount saZero(uCurrencyID);
|
STAmount saZero(uCurrencyID);
|
||||||
|
|
||||||
bAddIndex = true;
|
|
||||||
sleRippleState = entryCreate(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
|
sleRippleState = entryCreate(ltRIPPLE_STATE, Ledger::getRippleStateIndex(mTxnAccountID, uDstAccountID, uCurrencyID));
|
||||||
|
|
||||||
Log(lsINFO) << "doCreditSet: Creating ripple line: " << sleRippleState->getIndex().ToString();
|
Log(lsINFO) << "doCreditSet: Creating ripple line: " << sleRippleState->getIndex().ToString();
|
||||||
|
|
||||||
sleRippleState->setFlag(uFlags);
|
|
||||||
sleRippleState->setIFieldAmount(sfBalance, saZero); // Zero balance in currency.
|
sleRippleState->setIFieldAmount(sfBalance, saZero); // Zero balance in currency.
|
||||||
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAmount);
|
sleRippleState->setIFieldAmount(bFlipped ? sfHighLimit : sfLowLimit, saLimitAmount);
|
||||||
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, saZero);
|
sleRippleState->setIFieldAmount(bFlipped ? sfLowLimit : sfHighLimit, saZero);
|
||||||
@@ -1613,14 +1604,13 @@ TransactionEngineResult TransactionEngine::doCreditSet(const SerializedTransacti
|
|||||||
sleRippleState->setIFieldU32(bFlipped ? sfLowQualityIn : sfHighQualityIn, uQualityIn);
|
sleRippleState->setIFieldU32(bFlipped ? sfLowQualityIn : sfHighQualityIn, uQualityIn);
|
||||||
if (uQualityOut)
|
if (uQualityOut)
|
||||||
sleRippleState->setIFieldU32(bFlipped ? sfLowQualityOut : sfHighQualityOut, uQualityOut);
|
sleRippleState->setIFieldU32(bFlipped ? sfLowQualityOut : sfHighQualityOut, uQualityOut);
|
||||||
}
|
|
||||||
|
|
||||||
if (bAddIndex)
|
uint64 uSrcRef; // Ignored, dirs never delete.
|
||||||
{
|
|
||||||
uint64 uSrcRef; // Ignored, ripple_state dirs never delete.
|
|
||||||
|
|
||||||
// XXX Make dirAdd more flexiable to take vector.
|
terResult = dirAdd(uSrcRef, Ledger::getOwnerDirIndex(mTxnAccountID), sleRippleState->getIndex());
|
||||||
terResult = dirAdd(uSrcRef, Ledger::getRippleDirIndex(mTxnAccountID), sleRippleState->getIndex());
|
|
||||||
|
if (terSUCCESS == terResult)
|
||||||
|
terResult = dirAdd(uSrcRef, Ledger::getOwnerDirIndex(uDstAccountID), sleRippleState->getIndex());
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(lsINFO) << "doCreditSet<";
|
Log(lsINFO) << "doCreditSet<";
|
||||||
@@ -1927,16 +1917,16 @@ bool TransactionEngine::calcNodeOfferRev(
|
|||||||
uint160& uNxtIssuerID = nxtPN.uIssuerID;
|
uint160& uNxtIssuerID = nxtPN.uIssuerID;
|
||||||
uint160& uNxtAccountID = nxtPN.uAccountID;
|
uint160& uNxtAccountID = nxtPN.uAccountID;
|
||||||
|
|
||||||
STAmount saTransferRate = STAmount(CURRENCY_ONE, rippleTransfer(uCurIssuerID), -9);
|
STAmount saTransferRate = STAmount(CURRENCY_ONE, rippleTransferRate(uCurIssuerID), -9);
|
||||||
|
|
||||||
uint256 uDirectTip = Ledger::getBookBase(uPrvCurrencyID, uPrvIssuerID, uCurCurrencyID, uCurIssuerID);
|
uint256 uDirectTip = Ledger::getBookBase(uPrvCurrencyID, uPrvIssuerID, uCurCurrencyID, uCurIssuerID);
|
||||||
uint256 uDirectEnd = Ledger::getQualityNext(uDirectTip);
|
uint256 uDirectEnd = Ledger::getQualityNext(uDirectTip);
|
||||||
bool bAdvance = !entryCache(ltDIR_NODE, uDirectTip);
|
bool bAdvance = !entryCache(ltDIR_NODE, uDirectTip);
|
||||||
|
|
||||||
STAmount& saPrvDlvReq = prvPN.saRevDeliver;
|
STAmount& saPrvDlvReq = prvPN.saRevDeliver; // To be adjusted.
|
||||||
STAmount saPrvDlvAct;
|
STAmount saPrvDlvAct;
|
||||||
|
|
||||||
STAmount& saCurDlvReq = curPN.saRevDeliver; // Reverse driver.
|
const STAmount& saCurDlvReq = curPN.saRevDeliver; // Reverse driver.
|
||||||
STAmount saCurDlvAct;
|
STAmount saCurDlvAct;
|
||||||
|
|
||||||
while (!!uDirectTip // Have a quality.
|
while (!!uDirectTip // Have a quality.
|
||||||
@@ -2119,7 +2109,7 @@ bool TransactionEngine::calcNodeOfferFwd(
|
|||||||
uint160& uNxtIssuerID = nxtPN.uIssuerID;
|
uint160& uNxtIssuerID = nxtPN.uIssuerID;
|
||||||
|
|
||||||
uint160& uNxtAccountID = nxtPN.uAccountID;
|
uint160& uNxtAccountID = nxtPN.uAccountID;
|
||||||
STAmount saTransferRate = STAmount(CURRENCY_ONE, rippleTransfer(uCurIssuerID), -9);
|
STAmount saTransferRate = STAmount(CURRENCY_ONE, rippleTransferRate(uCurIssuerID), -9);
|
||||||
|
|
||||||
uint256 uDirectTip = Ledger::getBookBase(uPrvCurrencyID, uPrvIssuerID, uCurCurrencyID, uCurIssuerID);
|
uint256 uDirectTip = Ledger::getBookBase(uPrvCurrencyID, uPrvIssuerID, uCurCurrencyID, uCurIssuerID);
|
||||||
uint256 uDirectEnd = Ledger::getQualityNext(uDirectTip);
|
uint256 uDirectEnd = Ledger::getQualityNext(uDirectTip);
|
||||||
@@ -2730,7 +2720,7 @@ bool TransactionEngine::calcNodeAccountRev(unsigned int uIndex, PathState::point
|
|||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
Log(lsINFO) << str(boost::format("calcNodeAccountRev: Rate : 1.0 : transfer_rate"));
|
Log(lsINFO) << str(boost::format("calcNodeAccountRev: Rate : 1.0 : transfer_rate"));
|
||||||
|
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvRedeemReq, saCurIssueReq, saPrvRedeemAct, saCurIssueAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvRedeemReq, saCurIssueReq, saPrvRedeemAct, saCurIssueAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// issue (part 1)-> redeem
|
// issue (part 1)-> redeem
|
||||||
@@ -2789,7 +2779,7 @@ bool TransactionEngine::calcNodeAccountRev(unsigned int uIndex, PathState::point
|
|||||||
&& saCurDeliverReq) // Need some issued.
|
&& saCurDeliverReq) // Need some issued.
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvRedeemReq, saCurDeliverReq, saPrvRedeemAct, saCurDeliverAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvRedeemReq, saCurDeliverReq, saPrvRedeemAct, saCurDeliverAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// issue -> deliver/issue
|
// issue -> deliver/issue
|
||||||
@@ -2848,7 +2838,7 @@ bool TransactionEngine::calcNodeAccountRev(unsigned int uIndex, PathState::point
|
|||||||
&& saCurIssueReq) // Need some issued.
|
&& saCurIssueReq) // Need some issued.
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvDeliverReq, saCurIssueReq, saPrvDeliverAct, saCurIssueAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvDeliverReq, saCurIssueReq, saPrvDeliverAct, saCurIssueAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saCurDeliverAct && !saCurIssueAct)
|
if (!saCurDeliverAct && !saCurIssueAct)
|
||||||
@@ -2869,7 +2859,7 @@ bool TransactionEngine::calcNodeAccountRev(unsigned int uIndex, PathState::point
|
|||||||
&& saCurDeliverReq != saCurDeliverAct) // Can only if issue if more can not be redeemed.
|
&& saCurDeliverReq != saCurDeliverAct) // Can only if issue if more can not be redeemed.
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvDeliverReq, saCurDeliverReq, saPrvDeliverAct, saCurDeliverAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvDeliverReq, saCurDeliverReq, saPrvDeliverAct, saCurDeliverAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!saCurDeliverAct)
|
if (!saCurDeliverAct)
|
||||||
@@ -3041,7 +3031,7 @@ bool TransactionEngine::calcNodeAccountFwd(unsigned int uIndex, PathState::point
|
|||||||
&& saCurIssueReq)
|
&& saCurIssueReq)
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvRedeemReq, saCurIssueReq, saPrvRedeemAct, saCurIssueAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvRedeemReq, saCurIssueReq, saPrvRedeemAct, saCurIssueAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Previous issue part 1: issue -> redeem
|
// Previous issue part 1: issue -> redeem
|
||||||
@@ -3077,7 +3067,7 @@ bool TransactionEngine::calcNodeAccountFwd(unsigned int uIndex, PathState::point
|
|||||||
if (saPrvRedeemReq) // Previous wants to redeem.
|
if (saPrvRedeemReq) // Previous wants to redeem.
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvRedeemReq, saCurDeliverReq, saPrvRedeemAct, saCurDeliverAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvRedeemReq, saCurDeliverReq, saPrvRedeemAct, saCurDeliverAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// issue -> issue
|
// issue -> issue
|
||||||
@@ -3125,7 +3115,7 @@ bool TransactionEngine::calcNodeAccountFwd(unsigned int uIndex, PathState::point
|
|||||||
&& saCurIssueReq) // Current wants issue.
|
&& saCurIssueReq) // Current wants issue.
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvRedeemReq, saCurIssueReq, saPrvRedeemAct, saCurIssueAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvRedeemReq, saCurIssueReq, saPrvRedeemAct, saCurIssueAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No income balance adjustments necessary. The paying side inside the offer paid and the next link will receive.
|
// No income balance adjustments necessary. The paying side inside the offer paid and the next link will receive.
|
||||||
@@ -3142,7 +3132,7 @@ bool TransactionEngine::calcNodeAccountFwd(unsigned int uIndex, PathState::point
|
|||||||
&& saCurIssueReq) // Current wants issue.
|
&& saCurIssueReq) // Current wants issue.
|
||||||
{
|
{
|
||||||
// Rate : 1.0 : transfer_rate
|
// Rate : 1.0 : transfer_rate
|
||||||
calcNodeRipple(QUALITY_ONE, rippleTransfer(uCurAccountID), saPrvDeliverReq, saCurDeliverReq, saPrvDeliverAct, saCurDeliverAct);
|
calcNodeRipple(QUALITY_ONE, rippleTransferRate(uCurAccountID), saPrvDeliverReq, saCurDeliverReq, saPrvDeliverAct, saCurDeliverAct);
|
||||||
}
|
}
|
||||||
|
|
||||||
// No income balance adjustments necessary. The paying side inside the offer paid and the next link will receive.
|
// No income balance adjustments necessary. The paying side inside the offer paid and the next link will receive.
|
||||||
@@ -3742,7 +3732,7 @@ TransactionEngineResult TransactionEngine::doPayment(const SerializedTransaction
|
|||||||
|
|
||||||
terResult = dirAdd(
|
terResult = dirAdd(
|
||||||
uSrcRef,
|
uSrcRef,
|
||||||
Ledger::getRippleDirIndex(mTxnAccountID), // The source ended up owing.
|
Ledger::getOwnerDirIndex(mTxnAccountID), // The source ended up owing.
|
||||||
sleRippleState->getIndex()); // Adding current entry.
|
sleRippleState->getIndex()); // Adding current entry.
|
||||||
|
|
||||||
if (terSUCCESS != terResult)
|
if (terSUCCESS != terResult)
|
||||||
|
|||||||
@@ -221,14 +221,14 @@ protected:
|
|||||||
void entryDelete(SLE::pointer sleEntry, bool unfunded = false);
|
void entryDelete(SLE::pointer sleEntry, bool unfunded = false);
|
||||||
void entryModify(SLE::pointer sleEntry);
|
void entryModify(SLE::pointer sleEntry);
|
||||||
|
|
||||||
uint32 rippleTransfer(const uint160& uIssuerID);
|
uint32 rippleTransferRate(const uint160& uIssuerID);
|
||||||
STAmount rippleBalance(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
STAmount rippleBalance(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||||
STAmount rippleLimit(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
STAmount rippleLimit(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||||
uint32 rippleQualityIn(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
uint32 rippleQualityIn(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||||
uint32 rippleQualityOut(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
uint32 rippleQualityOut(const uint160& uToAccountID, const uint160& uFromAccountID, const uint160& uCurrencyID);
|
||||||
|
|
||||||
STAmount rippleHolds(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID);
|
STAmount rippleHolds(const uint160& uAccountID, const uint160& uCurrencyID, const uint160& uIssuerID);
|
||||||
STAmount rippleTransfer(const uint160& uSenderID, const uint160& uReceiverID, const uint160& uIssuerID, const STAmount& saAmount);
|
STAmount rippleTransferFee(const uint160& uSenderID, const uint160& uReceiverID, const uint160& uIssuerID, const STAmount& saAmount);
|
||||||
void rippleCredit(const uint160& uSenderID, const uint160& uReceiverID, const STAmount& saAmount, bool bCheckIssuer=true);
|
void rippleCredit(const uint160& uSenderID, const uint160& uReceiverID, const STAmount& saAmount, bool bCheckIssuer=true);
|
||||||
STAmount rippleSend(const uint160& uSenderID, const uint160& uReceiverID, const STAmount& saAmount);
|
STAmount rippleSend(const uint160& uSenderID, const uint160& uReceiverID, const STAmount& saAmount);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user