mirror of
https://github.com/XRPLF/rippled.git
synced 2026-04-29 15:37:57 +00:00
Merge branch 'develop' of github.com:jedmccaleb/NewCoin into develop
This commit is contained in:
@@ -251,7 +251,7 @@
|
||||
# When searching for paths, the maximum number of nodes allowed. This can take
|
||||
# exponentially more resources as the size is increased.
|
||||
#
|
||||
# The default is: 5
|
||||
# The default is: 4
|
||||
#
|
||||
# [rpc_startup]
|
||||
# Specify a list of RPC commands to run at startup.
|
||||
|
||||
@@ -271,9 +271,6 @@ STAmount STAmount::divRound(const STAmount& num, const STAmount& den,
|
||||
--denOffset;
|
||||
}
|
||||
|
||||
cLog(lsINFO) << "num: " << numVal << " " << numOffset;
|
||||
cLog(lsINFO) << "den: " << denVal << " " << denOffset;
|
||||
|
||||
bool resultNegative = num.mIsNegative != num.mIsNegative;
|
||||
// Compute (numerator * 10^17) / denominator
|
||||
CBigNum v;
|
||||
|
||||
@@ -149,6 +149,13 @@ public:
|
||||
void run();
|
||||
void stop();
|
||||
void sweep();
|
||||
|
||||
#ifdef DEBUG
|
||||
void mustHaveMasterLock() { bool tl = mMasterLock.try_lock(); assert(tl); mMasterLock.unlock(); }
|
||||
#else
|
||||
void mustHaveMasterLock() { ; }
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
extern Application* theApp;
|
||||
|
||||
@@ -82,7 +82,7 @@ public:
|
||||
}
|
||||
int getCount()
|
||||
{
|
||||
boost::mutex::scoped_lock(mLock);
|
||||
boost::mutex::scoped_lock sl(mLock);
|
||||
return mInstances;
|
||||
}
|
||||
const std::string& getName()
|
||||
|
||||
@@ -600,7 +600,7 @@ void NetworkOPs::checkState(const boost::system::error_code& result)
|
||||
}
|
||||
|
||||
{
|
||||
ScopedLock(theApp->getMasterLock());
|
||||
ScopedLock sl(theApp->getMasterLock());
|
||||
|
||||
std::vector<Peer::pointer> peerList = theApp->getConnectionPool().getPeerVector();
|
||||
|
||||
|
||||
@@ -118,7 +118,7 @@ bool Pathfinder::bDefaultPath(const STPath& spPath)
|
||||
}
|
||||
|
||||
typedef std::pair<int, uint160> candidate_t;
|
||||
bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||
static bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||
{
|
||||
if (first.first < second.first)
|
||||
return false;
|
||||
@@ -127,6 +127,17 @@ bool candCmp(uint32 seq, const candidate_t& first, const candidate_t& second)
|
||||
return (first.first ^ seq) < (second.first ^ seq);
|
||||
}
|
||||
|
||||
static int getEffectiveLength(const STPath& spPath)
|
||||
{ // don't count exchanges to non-XRP currencies twice (only count the forced issuer account node)
|
||||
int length = 0;
|
||||
for (std::vector<STPathElement>::const_iterator it = spPath.begin(); it != spPath.end(); ++it)
|
||||
{
|
||||
if (it->isAccount() || it->getCurrency().isZero())
|
||||
++length;
|
||||
}
|
||||
return length;
|
||||
}
|
||||
|
||||
Pathfinder::Pathfinder(Ledger::ref ledger,
|
||||
const RippleAddress& uSrcAccountID, const RippleAddress& uDstAccountID,
|
||||
const uint160& uSrcCurrencyID, const uint160& uSrcIssuerID, const STAmount& saDstAmount, bool& bValid)
|
||||
@@ -360,7 +371,8 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
% STAmount::createHumanCurrency(speEnd.mCurrencyID)
|
||||
% RippleAddress::createHumanAccountID(speEnd.mIssuerID));
|
||||
|
||||
if (spPath.mPath.size() >= iMaxSteps)
|
||||
int length = getEffectiveLength(spPath.mPath);
|
||||
if (length >= iMaxSteps)
|
||||
{
|
||||
// Path is at maximum size. Don't want to add more.
|
||||
|
||||
@@ -369,10 +381,10 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (!speEnd.mCurrencyID)
|
||||
{
|
||||
// XXX Might restrict the number of times bridging through XRP.
|
||||
bool isLast = (length == (iMaxSteps - 1));
|
||||
|
||||
if (!speEnd.mCurrencyID)
|
||||
{
|
||||
// Cursor is for XRP, continue with qualifying books: XRP -> non-XRP
|
||||
std::vector<OrderBook::pointer> xrpBooks;
|
||||
theApp->getOrderBookDB().getBooksByTakerPays(ACCOUNT_XRP, CURRENCY_XRP, xrpBooks);
|
||||
@@ -381,7 +393,10 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
// New end is an order book with the currency and issuer.
|
||||
|
||||
if (!spPath.hasSeen(ACCOUNT_XRP, book->getCurrencyOut(), book->getIssuerOut()) &&
|
||||
!matchesOrigin(book->getCurrencyOut(), book->getIssuerOut()))
|
||||
!matchesOrigin(book->getCurrencyOut(), book->getIssuerOut()) &&
|
||||
(!isLast ||
|
||||
(book->getCurrencyOut() == mDstAmount.getCurrency() &&
|
||||
book->getIssuerOut() == mDstAccountID)))
|
||||
{
|
||||
// Not a order book already in path.
|
||||
STPath spNew(spPath);
|
||||
@@ -453,6 +468,10 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
% RippleAddress::createHumanAccountID(uPeerID)
|
||||
% STAmount::createHumanCurrency(speEnd.mCurrencyID));
|
||||
}
|
||||
else if (isLast && (!dstCurrency || (uPeerID != mDstAccountID)))
|
||||
{
|
||||
nothing();
|
||||
}
|
||||
else if (!rspEntry->getBalance().isPositive() // No IOUs to send.
|
||||
&& (!rspEntry->getLimitPeer() // Peer does not extend credit.
|
||||
|| -rspEntry->getBalance() >= rspEntry->getLimitPeer() // No credit left.
|
||||
@@ -522,7 +541,10 @@ bool Pathfinder::findPaths(const unsigned int iMaxSteps, const unsigned int iMax
|
||||
BOOST_FOREACH(OrderBook::ref book, books)
|
||||
{
|
||||
if (!spPath.hasSeen(ACCOUNT_XRP, book->getCurrencyOut(), book->getIssuerOut()) &&
|
||||
!matchesOrigin(book->getCurrencyOut(), book->getIssuerOut()))
|
||||
!matchesOrigin(book->getCurrencyOut(), book->getIssuerOut()) &&
|
||||
(!isLast ||
|
||||
(book->getCurrencyOut() == mDstAmount.getCurrency() &&
|
||||
book->getIssuerOut() == mDstAccountID)))
|
||||
{
|
||||
// A book we haven't seen before. Add it.
|
||||
STPath spNew(spPath);
|
||||
|
||||
@@ -1242,6 +1242,7 @@ Json::Value RPCHandler::doRipplePathFind(Json::Value jvRequest, int& cost)
|
||||
jvDestCur.append(STAmount::createHumanCurrency(uCurrency));
|
||||
|
||||
jvResult["destination_currencies"] = jvDestCur;
|
||||
jvResult["destination_account"] = raDst.humanAccountID();
|
||||
|
||||
Json::Value jvArray(Json::arrayValue);
|
||||
|
||||
|
||||
@@ -1440,7 +1440,7 @@ TER RippleCalc::calcNodeDeliverFwd(
|
||||
|
||||
STAmount saOutFunded = std::min(saOfferFunds, saTakerGets); // Offer maximum out - If there are no out fees.
|
||||
STAmount saInFunded = STAmount::mulRound(saOutFunded, saOfrRate, saTakerPays, true); // Offer maximum in - Limited by by payout.
|
||||
STAmount saInTotal = STAmount::mulRound(saInFunded, saInTransRate, true); // Offer maximum in with fees.
|
||||
STAmount saInTotal = STAmount::mulRound(saInFunded, saInFeeRate, true); // Offer maximum in with fees.
|
||||
STAmount saInSum = std::min(saInTotal, saInReq-saInAct-saInFees); // In limited by remaining.
|
||||
STAmount saInPassAct = STAmount::divRound(saInSum, saInFeeRate, true); // In without fees.
|
||||
STAmount saOutPassMax = STAmount::divRound(saInPassAct, saOfrRate, saTakerGets, true); // Out limited by in remaining.
|
||||
|
||||
Reference in New Issue
Block a user