Allow a lot more commands to take advantage of the immutable SLE acceleration.

Allow faster operations on the open ledger by using many smaller freezes rather than one big one.
This commit is contained in:
JoelKatz
2013-02-21 09:57:42 -08:00
parent 53b622db75
commit 2e12ffac57
4 changed files with 23 additions and 45 deletions

View File

@@ -24,11 +24,9 @@ void AccountItems::fillItems(const uint160& accountID, Ledger::ref ledger)
uint256 rootIndex = Ledger::getOwnerDirIndex(accountID); uint256 rootIndex = Ledger::getOwnerDirIndex(accountID);
uint256 currentIndex = rootIndex; uint256 currentIndex = rootIndex;
LedgerStateParms lspNode = lepNONE;
while (1) while (1)
{ {
SLE::pointer ownerDir = ledger->getDirNode(lspNode, currentIndex); SLE::pointer ownerDir = ledger->getDirNode(currentIndex);
if (!ownerDir) return; if (!ownerDir) return;
STVector256 svOwnerNodes = ownerDir->getFieldV256(sfIndexes); STVector256 svOwnerNodes = ownerDir->getFieldV256(sfIndexes);

View File

@@ -1068,27 +1068,27 @@ SLE::pointer Ledger::getAccountRoot(const RippleAddress& naAccountID)
// Directory // Directory
// //
SLE::pointer Ledger::getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex) SLE::pointer Ledger::getDirNode(const uint256& uNodeIndex)
{ {
return getASNode(parms, uNodeIndex, ltDIR_NODE); return getASNodeI(uNodeIndex, ltDIR_NODE);
} }
// //
// Generator Map // Generator Map
// //
SLE::pointer Ledger::getGenerator(LedgerStateParms& parms, const uint160& uGeneratorID) SLE::pointer Ledger::getGenerator(const uint160& uGeneratorID)
{ {
return getASNode(parms, getGeneratorIndex(uGeneratorID), ltGENERATOR_MAP); return getASNodeI(getGeneratorIndex(uGeneratorID), ltGENERATOR_MAP);
} }
// //
// Nickname // Nickname
// //
SLE::pointer Ledger::getNickname(LedgerStateParms& parms, const uint256& uNickname) SLE::pointer Ledger::getNickname(const uint256& uNickname)
{ {
return getASNode(parms, uNickname, ltNICKNAME); return getASNodeI(uNickname, ltNICKNAME);
} }
// //
@@ -1096,18 +1096,18 @@ SLE::pointer Ledger::getNickname(LedgerStateParms& parms, const uint256& uNickna
// //
SLE::pointer Ledger::getOffer(LedgerStateParms& parms, const uint256& uIndex) SLE::pointer Ledger::getOffer(const uint256& uIndex)
{ {
return getASNode(parms, uIndex, ltOFFER); return getASNodeI(uIndex, ltOFFER);
} }
// //
// Ripple State // Ripple State
// //
SLE::pointer Ledger::getRippleState(LedgerStateParms& parms, const uint256& uNode) SLE::pointer Ledger::getRippleState(const uint256& uNode)
{ {
return getASNode(parms, uNode, ltRIPPLE_STATE); return getASNodeI(uNode, ltRIPPLE_STATE);
} }
// For an entry put in the 64 bit index or quality. // For an entry put in the 64 bit index or quality.

View File

@@ -234,7 +234,7 @@ public:
// Generator Map functions // Generator Map functions
// //
SLE::pointer getGenerator(LedgerStateParms& parms, const uint160& uGeneratorID); SLE::pointer getGenerator(const uint160& uGeneratorID);
static uint256 getGeneratorIndex(const uint160& uGeneratorID); static uint256 getGeneratorIndex(const uint160& uGeneratorID);
@@ -249,9 +249,8 @@ public:
NicknameState::pointer getNicknameState(const std::string& strNickname) NicknameState::pointer getNicknameState(const std::string& strNickname)
{ return getNicknameState(getNicknameHash(strNickname)); } { return getNicknameState(getNicknameHash(strNickname)); }
SLE::pointer getNickname(LedgerStateParms& parms, const uint256& uNickname); SLE::pointer getNickname(const uint256& uNickname);
SLE::pointer getNickname(LedgerStateParms& parms, const std::string& strNickname) SLE::pointer getNickname(const std::string& strNickname) { return getNickname(getNicknameHash(strNickname)); }
{ return getNickname(parms, getNicknameHash(strNickname)); }
static uint256 getNicknameIndex(const uint256& uNickname); static uint256 getNicknameIndex(const uint256& uNickname);
@@ -267,16 +266,10 @@ public:
// Offer functions // Offer functions
// //
SLE::pointer getOffer(LedgerStateParms& parms, const uint256& uIndex); SLE::pointer getOffer(const uint256& uIndex);
SLE::pointer getOffer(const uint256& uIndex) SLE::pointer getOffer(const uint160& uAccountID, uint32 uSequence)
{ { return getOffer(getOfferIndex(uAccountID, uSequence)); }
LedgerStateParms qry = lepNONE;
return getOffer(qry, uIndex);
}
SLE::pointer getOffer(LedgerStateParms& parms, const uint160& uAccountID, uint32 uSequence)
{ return getOffer(parms, getOfferIndex(uAccountID, uSequence)); }
// The index of an offer. // The index of an offer.
static uint256 getOfferIndex(const uint160& uAccountID, uint32 uSequence); static uint256 getOfferIndex(const uint160& uAccountID, uint32 uSequence);
@@ -297,7 +290,7 @@ public:
static void ownerDirDescriber(SLE::ref, const uint160& owner); static void ownerDirDescriber(SLE::ref, const uint160& owner);
// Return a node: root or normal // Return a node: root or normal
SLE::pointer getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex); SLE::pointer getDirNode(const uint256& uNodeIndex);
// //
// Quality // Quality
@@ -320,13 +313,7 @@ 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(RippleAddress::createAccountID(uiA), RippleAddress::createAccountID(uiB), uCurrency); } { return getRippleStateIndex(RippleAddress::createAccountID(uiA), RippleAddress::createAccountID(uiB), uCurrency); }
SLE::pointer getRippleState(LedgerStateParms& parms, const uint256& uNode); SLE::pointer getRippleState(const uint256& uNode);
SLE::pointer getRippleState(const uint256& uNode)
{
LedgerStateParms qry = lepNONE;
return getRippleState(qry, uNode);
}
SLE::pointer getRippleState(const RippleAddress& naA, const RippleAddress& naB, const uint160& uCurrency) SLE::pointer getRippleState(const RippleAddress& naA, const RippleAddress& naB, const uint160& uCurrency)
{ return getRippleState(getRippleStateIndex(naA, naB, uCurrency)); } { return getRippleState(getRippleStateIndex(naA, naB, uCurrency)); }

View File

@@ -455,12 +455,9 @@ AccountState::pointer NetworkOPs::getAccountState(Ledger::ref lrLedger, const Ri
SLE::pointer NetworkOPs::getGenerator(Ledger::ref lrLedger, const uint160& uGeneratorID) SLE::pointer NetworkOPs::getGenerator(Ledger::ref lrLedger, const uint160& uGeneratorID)
{ {
LedgerStateParms qry = lepNONE;
if (!lrLedger) if (!lrLedger)
return SLE::pointer(); return SLE::pointer();
else return lrLedger->getGenerator(uGeneratorID);
return lrLedger->getGenerator(qry, uGeneratorID);
} }
// //
@@ -475,8 +472,7 @@ STVector256 NetworkOPs::getDirNodeInfo(
uint64& uNodeNext) uint64& uNodeNext)
{ {
STVector256 svIndexes; STVector256 svIndexes;
LedgerStateParms lspNode = lepNONE; SLE::pointer sleNode = lrLedger->getDirNode(uNodeIndex);
SLE::pointer sleNode = lrLedger->getDirNode(lspNode, uNodeIndex);
if (sleNode) if (sleNode)
{ {
@@ -524,8 +520,7 @@ Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const RippleAddre
uint256 uRootIndex = lpLedger->getOwnerDirIndex(naAccount.getAccountID()); uint256 uRootIndex = lpLedger->getOwnerDirIndex(naAccount.getAccountID());
LedgerStateParms lspNode = lepNONE; SLE::pointer sleNode = lpLedger->getDirNode(uRootIndex);
SLE::pointer sleNode = lpLedger->getDirNode(lspNode, uRootIndex);
if (sleNode) if (sleNode)
{ {
@@ -569,9 +564,7 @@ Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const RippleAddre
uNodeDir = sleNode->getFieldU64(sfIndexNext); uNodeDir = sleNode->getFieldU64(sfIndexNext);
if (uNodeDir) if (uNodeDir)
{ {
lspNode = lepNONE; sleNode = lpLedger->getDirNode(Ledger::getDirNodeIndex(uRootIndex, uNodeDir));
sleNode = lpLedger->getDirNode(lspNode, Ledger::getDirNodeIndex(uRootIndex, uNodeDir));
assert(sleNode); assert(sleNode);
} }
} while (uNodeDir); } while (uNodeDir);