mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-20 10:35:50 +00:00
Remove conditionals for featureSortedDirectories enabled 14Nov2017
This commit is contained in:
@@ -712,107 +712,13 @@ dirAdd (ApplyView& view,
|
||||
bool strictOrder,
|
||||
std::function<void (SLE::ref)> fDescriber,
|
||||
beast::Journal j)
|
||||
{
|
||||
if (view.rules().enabled(featureSortedDirectories))
|
||||
{
|
||||
if (strictOrder)
|
||||
return view.dirAppend(dir, uLedgerIndex, fDescriber);
|
||||
else
|
||||
|
||||
return view.dirInsert(dir, uLedgerIndex, fDescriber);
|
||||
}
|
||||
|
||||
JLOG (j.trace()) << "dirAdd:" <<
|
||||
" dir=" << to_string (dir.key) <<
|
||||
" uLedgerIndex=" << to_string (uLedgerIndex);
|
||||
|
||||
auto sleRoot = view.peek(dir);
|
||||
std::uint64_t uNodeDir = 0;
|
||||
|
||||
if (! sleRoot)
|
||||
{
|
||||
// No root, make it.
|
||||
sleRoot = std::make_shared<SLE>(dir);
|
||||
sleRoot->setFieldH256 (sfRootIndex, dir.key);
|
||||
view.insert (sleRoot);
|
||||
fDescriber (sleRoot);
|
||||
|
||||
STVector256 v;
|
||||
v.push_back (uLedgerIndex);
|
||||
sleRoot->setFieldV256 (sfIndexes, v);
|
||||
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: created root " << to_string (dir.key) <<
|
||||
" for entry " << to_string (uLedgerIndex);
|
||||
|
||||
return uNodeDir;
|
||||
}
|
||||
|
||||
SLE::pointer sleNode;
|
||||
STVector256 svIndexes;
|
||||
|
||||
uNodeDir = sleRoot->getFieldU64 (sfIndexPrevious); // Get index to last directory node.
|
||||
|
||||
if (uNodeDir)
|
||||
{
|
||||
// Try adding to last node.
|
||||
sleNode = view.peek (keylet::page(dir, uNodeDir));
|
||||
assert (sleNode);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Try adding to root. Didn't have a previous set to the last node.
|
||||
sleNode = sleRoot;
|
||||
}
|
||||
|
||||
svIndexes = sleNode->getFieldV256 (sfIndexes);
|
||||
|
||||
if (dirNodeMaxEntries != svIndexes.size ())
|
||||
{
|
||||
// Add to current node.
|
||||
view.update(sleNode);
|
||||
}
|
||||
// Add to new node.
|
||||
else if (!++uNodeDir)
|
||||
{
|
||||
return boost::none;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Have old last point to new node
|
||||
sleNode->setFieldU64 (sfIndexNext, uNodeDir);
|
||||
view.update(sleNode);
|
||||
|
||||
// Have root point to new node.
|
||||
sleRoot->setFieldU64 (sfIndexPrevious, uNodeDir);
|
||||
view.update (sleRoot);
|
||||
|
||||
// Create the new node.
|
||||
sleNode = std::make_shared<SLE>(
|
||||
keylet::page(dir, uNodeDir));
|
||||
sleNode->setFieldH256 (sfRootIndex, dir.key);
|
||||
view.insert (sleNode);
|
||||
|
||||
if (uNodeDir != 1)
|
||||
sleNode->setFieldU64 (sfIndexPrevious, uNodeDir - 1);
|
||||
|
||||
fDescriber (sleNode);
|
||||
|
||||
svIndexes = STVector256 ();
|
||||
}
|
||||
|
||||
svIndexes.push_back (uLedgerIndex); // Append entry.
|
||||
sleNode->setFieldV256 (sfIndexes, svIndexes); // Save entry.
|
||||
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: creating: root: " << to_string (dir.key);
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: appending: Entry: " << to_string (uLedgerIndex);
|
||||
JLOG (j.trace()) <<
|
||||
"dirAdd: appending: Node: " << strHex (uNodeDir);
|
||||
|
||||
return uNodeDir;
|
||||
}
|
||||
|
||||
TER
|
||||
trustCreate (ApplyView& view,
|
||||
const bool bSrcHigh,
|
||||
|
||||
@@ -376,7 +376,7 @@ extern uint256 const retiredEscrow;
|
||||
extern uint256 const featureCryptoConditionsSuite;
|
||||
extern uint256 const retiredFix1373;
|
||||
extern uint256 const retiredEnforceInvariants;
|
||||
extern uint256 const featureSortedDirectories;
|
||||
extern uint256 const retiredSortedDirectories;
|
||||
extern uint256 const fix1201;
|
||||
extern uint256 const fix1512;
|
||||
extern uint256 const fix1513;
|
||||
|
||||
@@ -167,7 +167,7 @@ uint256 const retiredEscrow = *getRegisteredFeature("Escrow");
|
||||
uint256 const featureCryptoConditionsSuite = *getRegisteredFeature("CryptoConditionsSuite");
|
||||
uint256 const retiredFix1373 = *getRegisteredFeature("fix1373");
|
||||
uint256 const retiredEnforceInvariants = *getRegisteredFeature("EnforceInvariants");
|
||||
uint256 const featureSortedDirectories = *getRegisteredFeature("SortedDirectories");
|
||||
uint256 const retiredSortedDirectories = *getRegisteredFeature("SortedDirectories");
|
||||
uint256 const fix1201 = *getRegisteredFeature("fix1201");
|
||||
uint256 const fix1512 = *getRegisteredFeature("fix1512");
|
||||
uint256 const fix1513 = *getRegisteredFeature("fix1513");
|
||||
|
||||
@@ -85,39 +85,7 @@ struct Directory_test : public beast::unit_test::suite
|
||||
auto alice = Account("alice");
|
||||
auto bob = Account("bob");
|
||||
|
||||
{
|
||||
testcase ("Directory Ordering (without 'SortedDirectories' amendment");
|
||||
|
||||
Env env(
|
||||
*this,
|
||||
supported_amendments().reset(featureSortedDirectories));
|
||||
env.fund(XRP(10000000), alice, bob, gw);
|
||||
|
||||
// Insert 400 offers from Alice, then one from Bob:
|
||||
std::uint32_t const firstOfferSeq {env.seq (alice)};
|
||||
for (std::size_t i = 1; i <= 400; ++i)
|
||||
env(offer(alice, USD(10), XRP(10)));
|
||||
|
||||
// Check Alice's directory: it should contain one
|
||||
// entry for each offer she added. Within each
|
||||
// page, the entries should be in sorted order.
|
||||
{
|
||||
auto dir = Dir(*env.current(),
|
||||
keylet::ownerDir(alice));
|
||||
|
||||
std::uint32_t lastSeq = firstOfferSeq - 1;
|
||||
|
||||
// Check that the orders are sequential by checking
|
||||
// that their sequence numbers are:
|
||||
for (auto iter = dir.begin(); iter != std::end(dir); ++iter) {
|
||||
BEAST_EXPECT(++lastSeq == (*iter)->getFieldU32(sfSequence));
|
||||
}
|
||||
BEAST_EXPECT(lastSeq != 1);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
testcase ("Directory Ordering (with 'SortedDirectories' amendment)");
|
||||
testcase ("Directory Ordering");
|
||||
|
||||
Env env(*this);
|
||||
env.fund(XRP(10000000), alice, gw);
|
||||
@@ -174,7 +142,6 @@ struct Directory_test : public beast::unit_test::suite
|
||||
BEAST_EXPECT(offer->getFieldAmount(sfTakerGets) == XRP(count));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
testDirIsEmpty()
|
||||
|
||||
Reference in New Issue
Block a user