Move to new directory format.

This commit is contained in:
Arthur Britto
2012-07-07 17:46:47 -07:00
parent 4b20162e7f
commit e5ad771708
11 changed files with 368 additions and 295 deletions

View File

@@ -29,7 +29,8 @@ LedgerStateParms Ledger::writeBack(LedgerStateParms parms, SLE::pointer entry)
if (create)
{
assert(!mAccountStateMap->hasItem(entry->getIndex()));
if(!mAccountStateMap->addGiveItem(item, false))
if (!mAccountStateMap->addGiveItem(item, false))
{
assert(false);
return lepERROR;
@@ -68,7 +69,7 @@ SLE::pointer Ledger::getASNode(LedgerStateParms& parms, const uint256& nodeID,
SLE::pointer sle =
boost::make_shared<SLE>(account->peekSerializer(), nodeID);
if(sle->getType() != let)
if (sle->getType() != let)
{ // maybe it's a currency or something
parms = parms | lepWRONGTYPE;
return SLE::pointer();
@@ -92,6 +93,17 @@ SLE::pointer Ledger::getAccountRoot(LedgerStateParms& parms, const NewcoinAddres
return getAccountRoot(parms, naAccountID.getAccountID());
}
//
// Directory
//
SLE::pointer Ledger::getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex)
{
ScopedLock l(mAccountStateMap->Lock());
return getASNode(parms, uNodeIndex, ltDIR_NODE);
}
//
// Generator Map
//
@@ -137,36 +149,4 @@ SLE::pointer Ledger::getRippleState(LedgerStateParms& parms, const uint256& uNod
return getASNode(parms, uNode, ltRIPPLE_STATE);
}
//
// Directory
//
// For a directory entry put in the 64 bit index or quality.
uint256 Ledger::getDirIndex(const uint256& uBase, const uint64 uNodeDir)
{
// Indexes are stored in big endian format: they print as hex as stored.
// Most significant bytes are first. Least significant bytes repesent adjcent entries.
// We place uNodeDir in the 8 right most bytes to be adjcent.
// Want uNodeDir in big endian format so ++ goes to the next entry for indexes.
uint256 uNode(uBase);
((uint64*) uNode.end())[-1] = htobe64(uNodeDir);
return uNode;
}
SLE::pointer Ledger::getDirRoot(LedgerStateParms& parms, const uint256& uRootIndex)
{
ScopedLock l(mAccountStateMap->Lock());
return getASNode(parms, uRootIndex, ltDIR_ROOT);
}
SLE::pointer Ledger::getDirNode(LedgerStateParms& parms, const uint256& uNodeIndex)
{
ScopedLock l(mAccountStateMap->Lock());
return getASNode(parms, uNodeIndex, ltDIR_NODE);
}
// vim:ts=4