Freeze enforcing: (RIPD-399)

* Set enforce date: September 15, 2014
 * Enforce in stand alone mode
 * Enforce at source
 * Enforce intermediary nodes
 * Enforce global freeze in get paths out
 * Enforce global freeze in create offer
 * Don't consider frozen links a path out
 * Handle in getBookPage
 * Enforce in new offer transactors
This commit is contained in:
David Schwartz
2014-05-27 12:57:49 -07:00
committed by Nik Bougalis
parent 9eb34f542c
commit 7b936de32c
17 changed files with 258 additions and 51 deletions

View File

@@ -602,6 +602,67 @@ TER PathState::expandPath (
return terStatus;
}
/** Check if an expanded path violates freeze rules */
void PathState::checkFreeze()
{
assert (nodes_.size() >= 2);
// A path with no intermediaries -- pure issue/redeem
// cannot be frozen.
if (nodes_.size() == 2)
return;
SLE::pointer sle;
for (std::size_t i = 0; i < (nodes_.size() - 1); ++i)
{
// Check each order book for a global freeze
if (nodes_[i].uFlags & STPathElement::typeIssuer)
{
sle = lesEntries.entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (nodes_[i].issue_.account));
if (sle && sle->isFlag (lsfGlobalFreeze))
{
terStatus = terNO_LINE;
return;
}
}
// Check each account change to make sure funds can leave
if (nodes_[i].uFlags & STPathElement::typeAccount)
{
Currency const& currencyID = nodes_[i].issue_.currency;
Account const& inAccount = nodes_[i].account_;
Account const& outAccount = nodes_[i+1].account_;
if (inAccount != outAccount)
{
sle = lesEntries.entryCache (ltACCOUNT_ROOT,
Ledger::getAccountRootIndex (outAccount));
if (sle && sle->isFlag (lsfGlobalFreeze))
{
terStatus = terNO_LINE;
return;
}
sle = lesEntries.entryCache (ltRIPPLE_STATE,
Ledger::getRippleStateIndex (inAccount,
outAccount, currencyID));
if (sle && sle->isFlag (
(outAccount > inAccount) ? lsfHighFreeze : lsfLowFreeze))
{
terStatus = terNO_LINE;
return;
}
}
}
}
}
/** Check if a sequence of three accounts violates the no ripple constrains
[first] -> [second] -> [third]
Disallowed if 'second' set no ripple on [first]->[second] and
@@ -716,8 +777,8 @@ TER PathState::checkNoRipple (
}
// Loop through all nodes that have a prior node and successor nodes
// These are the nodes whose no ripple constratints could be violated
for (auto i = 1; i < nodes_.size() - 1; ++i)
// These are the nodes whose no ripple constraints could be violated
for (int i = 1; i < nodes_.size() - 1; ++i)
{
if (nodes_[i - 1].isAccount() &&
nodes_[i].isAccount() &&