mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-27 06:25:51 +00:00
Pathfinding performance improvements.
This commit is contained in:
@@ -169,7 +169,11 @@ void Application::setup()
|
|||||||
{
|
{
|
||||||
cLog(lsINFO) << "Loading specified Ledger";
|
cLog(lsINFO) << "Loading specified Ledger";
|
||||||
|
|
||||||
loadOldLedger(theConfig.START_LEDGER);
|
if (!loadOldLedger(theConfig.START_LEDGER))
|
||||||
|
{
|
||||||
|
theApp->stop();
|
||||||
|
exit(-1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (theConfig.START_UP == Config::NETWORK)
|
else if (theConfig.START_UP == Config::NETWORK)
|
||||||
{ // This should probably become the default once we have a stable network
|
{ // This should probably become the default once we have a stable network
|
||||||
@@ -389,7 +393,7 @@ void Application::startNewLedger()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::loadOldLedger(const std::string& l)
|
bool Application::loadOldLedger(const std::string& l)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -408,7 +412,7 @@ void Application::loadOldLedger(const std::string& l)
|
|||||||
if (!loadLedger)
|
if (!loadLedger)
|
||||||
{
|
{
|
||||||
cLog(lsFATAL) << "No Ledger found?" << std::endl;
|
cLog(lsFATAL) << "No Ledger found?" << std::endl;
|
||||||
exit(-1);
|
return false;
|
||||||
}
|
}
|
||||||
loadLedger->setClosed();
|
loadLedger->setClosed();
|
||||||
|
|
||||||
@@ -418,19 +422,19 @@ void Application::loadOldLedger(const std::string& l)
|
|||||||
{
|
{
|
||||||
cLog(lsFATAL) << "Ledger is empty.";
|
cLog(lsFATAL) << "Ledger is empty.";
|
||||||
assert(false);
|
assert(false);
|
||||||
exit(-1);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadLedger->walkLedger())
|
if (!loadLedger->walkLedger())
|
||||||
{
|
{
|
||||||
cLog(lsFATAL) << "Ledger is missing nodes.";
|
cLog(lsFATAL) << "Ledger is missing nodes.";
|
||||||
exit(-1);
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!loadLedger->assertSane())
|
if (!loadLedger->assertSane())
|
||||||
{
|
{
|
||||||
cLog(lsFATAL) << "Ledger is not sane.";
|
cLog(lsFATAL) << "Ledger is not sane.";
|
||||||
exit(-1);
|
return false;
|
||||||
}
|
}
|
||||||
mLedgerMaster.setLedgerRangePresent(loadLedger->getLedgerSeq(), loadLedger->getLedgerSeq());
|
mLedgerMaster.setLedgerRangePresent(loadLedger->getLedgerSeq(), loadLedger->getLedgerSeq());
|
||||||
|
|
||||||
@@ -441,13 +445,14 @@ void Application::loadOldLedger(const std::string& l)
|
|||||||
catch (SHAMapMissingNode&)
|
catch (SHAMapMissingNode&)
|
||||||
{
|
{
|
||||||
cLog(lsFATAL) << "Data is missing for selected ledger";
|
cLog(lsFATAL) << "Data is missing for selected ledger";
|
||||||
exit(-1);
|
return false;
|
||||||
}
|
}
|
||||||
catch (boost::bad_lexical_cast&)
|
catch (boost::bad_lexical_cast&)
|
||||||
{
|
{
|
||||||
cLog(lsFATAL) << "Ledger specified '" << l << "' is not valid";
|
cLog(lsFATAL) << "Ledger specified '" << l << "' is not valid";
|
||||||
exit(-1);
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ class Application
|
|||||||
|
|
||||||
void updateTables();
|
void updateTables();
|
||||||
void startNewLedger();
|
void startNewLedger();
|
||||||
void loadOldLedger(const std::string&);
|
bool loadOldLedger(const std::string&);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Application();
|
Application();
|
||||||
|
|||||||
@@ -184,17 +184,16 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
|
|||||||
|
|
||||||
#ifndef NO_SQLITE3_PREPARE
|
#ifndef NO_SQLITE3_PREPARE
|
||||||
{
|
{
|
||||||
std::string sql = "SELECT ObjType,LedgerIndex,Object FROM CommittedObjects WHERE Hash = '";
|
|
||||||
sql.append(hash.GetHex());
|
|
||||||
sql.append("';");
|
|
||||||
|
|
||||||
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
||||||
|
static SqliteStatement pSt(theApp->getHashNodeDB()->getDB()->getSqliteDB(),
|
||||||
|
"SELECT ObjType,LedgerIndex,Object FROM CommittedObjects WHERE Hash = ?;");
|
||||||
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK, "HOS::retrieve"));
|
LoadEvent::autoptr event(theApp->getJobQueue().getLoadEventAP(jtDISK, "HOS::retrieve"));
|
||||||
SqliteStatement pSt(theApp->getHashNodeDB()->getDB()->getSqliteDB(), sql.c_str());
|
|
||||||
|
|
||||||
|
pSt.bind(1, hash.GetHex());
|
||||||
int ret = pSt.step();
|
int ret = pSt.step();
|
||||||
if (pSt.isDone(ret))
|
if (pSt.isDone(ret))
|
||||||
{
|
{
|
||||||
|
pSt.reset();
|
||||||
mNegativeCache.add(hash);
|
mNegativeCache.add(hash);
|
||||||
cLog(lsTRACE) << "HOS: " << hash <<" fetch: not in db";
|
cLog(lsTRACE) << "HOS: " << hash <<" fetch: not in db";
|
||||||
return obj;
|
return obj;
|
||||||
@@ -203,6 +202,7 @@ HashedObject::pointer HashedObjectStore::retrieve(const uint256& hash)
|
|||||||
type = pSt.peekString(0);
|
type = pSt.peekString(0);
|
||||||
index = pSt.getUInt32(1);
|
index = pSt.getUInt32(1);
|
||||||
pSt.getBlob(2).swap(data);
|
pSt.getBlob(2).swap(data);
|
||||||
|
pSt.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|||||||
@@ -3,33 +3,34 @@
|
|||||||
|
|
||||||
AccountItem::pointer RippleState::makeItem(const uint160& accountID, SerializedLedgerEntry::ref ledgerEntry)
|
AccountItem::pointer RippleState::makeItem(const uint160& accountID, SerializedLedgerEntry::ref ledgerEntry)
|
||||||
{
|
{
|
||||||
if (!ledgerEntry || ledgerEntry->getType() != ltRIPPLE_STATE) return(AccountItem::pointer());
|
if (!ledgerEntry || ledgerEntry->getType() != ltRIPPLE_STATE)
|
||||||
RippleState* rs=new RippleState(ledgerEntry);
|
return AccountItem::pointer();
|
||||||
|
RippleState* rs = new RippleState(ledgerEntry);
|
||||||
rs->setViewAccount(accountID);
|
rs->setViewAccount(accountID);
|
||||||
|
|
||||||
return(AccountItem::pointer(rs));
|
return AccountItem::pointer(rs);
|
||||||
}
|
}
|
||||||
|
|
||||||
RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(ledgerEntry),
|
RippleState::RippleState(SerializedLedgerEntry::ref ledgerEntry) : AccountItem(ledgerEntry),
|
||||||
mValid(false),
|
mValid(false),
|
||||||
mViewLowest(true)
|
mViewLowest(true),
|
||||||
|
|
||||||
|
mLowLimit(ledgerEntry->getFieldAmount(sfLowLimit)),
|
||||||
|
mHighLimit(ledgerEntry->getFieldAmount(sfHighLimit)),
|
||||||
|
|
||||||
|
mLowID(mLowLimit.getIssuer()),
|
||||||
|
mHighID(mHighLimit.getIssuer()),
|
||||||
|
|
||||||
|
mBalance(ledgerEntry->getFieldAmount(sfBalance))
|
||||||
{
|
{
|
||||||
mFlags = mLedgerEntry->getFieldU32(sfFlags);
|
mFlags = mLedgerEntry->getFieldU32(sfFlags);
|
||||||
|
|
||||||
mLowLimit = mLedgerEntry->getFieldAmount(sfLowLimit);
|
|
||||||
mHighLimit = mLedgerEntry->getFieldAmount(sfHighLimit);
|
|
||||||
|
|
||||||
mLowID = mLowLimit.getIssuer();
|
|
||||||
mHighID = mHighLimit.getIssuer();
|
|
||||||
|
|
||||||
mLowQualityIn = mLedgerEntry->getFieldU32(sfLowQualityIn);
|
mLowQualityIn = mLedgerEntry->getFieldU32(sfLowQualityIn);
|
||||||
mLowQualityOut = mLedgerEntry->getFieldU32(sfLowQualityOut);
|
mLowQualityOut = mLedgerEntry->getFieldU32(sfLowQualityOut);
|
||||||
|
|
||||||
mHighQualityIn = mLedgerEntry->getFieldU32(sfHighQualityIn);
|
mHighQualityIn = mLedgerEntry->getFieldU32(sfHighQualityIn);
|
||||||
mHighQualityOut = mLedgerEntry->getFieldU32(sfHighQualityOut);
|
mHighQualityOut = mLedgerEntry->getFieldU32(sfHighQualityOut);
|
||||||
|
|
||||||
mBalance = mLedgerEntry->getFieldAmount(sfBalance);
|
|
||||||
|
|
||||||
mValid = true;
|
mValid = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,14 +17,17 @@ public:
|
|||||||
typedef boost::shared_ptr<RippleState> pointer;
|
typedef boost::shared_ptr<RippleState> pointer;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
uint32 mFlags;
|
bool mValid;
|
||||||
|
bool mViewLowest;
|
||||||
|
|
||||||
uint160 mLowID;
|
uint32 mFlags;
|
||||||
uint160 mHighID;
|
|
||||||
|
|
||||||
STAmount mLowLimit;
|
STAmount mLowLimit;
|
||||||
STAmount mHighLimit;
|
STAmount mHighLimit;
|
||||||
|
|
||||||
|
uint160 mLowID;
|
||||||
|
uint160 mHighID;
|
||||||
|
|
||||||
uint64 mLowQualityIn;
|
uint64 mLowQualityIn;
|
||||||
uint64 mLowQualityOut;
|
uint64 mLowQualityOut;
|
||||||
uint64 mHighQualityIn;
|
uint64 mHighQualityIn;
|
||||||
@@ -32,9 +35,6 @@ private:
|
|||||||
|
|
||||||
STAmount mBalance;
|
STAmount mBalance;
|
||||||
|
|
||||||
bool mValid;
|
|
||||||
bool mViewLowest;
|
|
||||||
|
|
||||||
RippleState(SerializedLedgerEntry::ref ledgerEntry); // For accounts in a ledger
|
RippleState(SerializedLedgerEntry::ref ledgerEntry); // For accounts in a ledger
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
@@ -124,8 +124,8 @@ SHAMapNode SHAMapNode::getChildNodeID(int m) const
|
|||||||
|
|
||||||
int SHAMapNode::selectBranch(const uint256& hash) const
|
int SHAMapNode::selectBranch(const uint256& hash) const
|
||||||
{ // Which branch would contain the specified hash
|
{ // Which branch would contain the specified hash
|
||||||
#ifdef DEBUG
|
#ifdef PARANOID
|
||||||
if (mDepth == 64)
|
if (mDepth >= 64)
|
||||||
{
|
{
|
||||||
assert(false);
|
assert(false);
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -639,14 +639,18 @@ std::vector<unsigned char> STObject::getFieldVL(SField::ref field) const
|
|||||||
return cf->getValue();
|
return cf->getValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
STAmount STObject::getFieldAmount(SField::ref field) const
|
static const STAmount defaultAmount;
|
||||||
|
const STAmount& STObject::getFieldAmount(SField::ref field) const
|
||||||
{
|
{
|
||||||
const SerializedType* rf = peekAtPField(field);
|
const SerializedType* rf = peekAtPField(field);
|
||||||
if (!rf) throw std::runtime_error("Field not found");
|
if (!rf)
|
||||||
|
throw std::runtime_error("Field not found");
|
||||||
SerializedTypeID id = rf->getSType();
|
SerializedTypeID id = rf->getSType();
|
||||||
if (id == STI_NOTPRESENT) return STAmount(); // optional field not present
|
if (id == STI_NOTPRESENT)
|
||||||
|
return defaultAmount; // optional field not present
|
||||||
const STAmount *cf = dynamic_cast<const STAmount *>(rf);
|
const STAmount *cf = dynamic_cast<const STAmount *>(rf);
|
||||||
if (!cf) throw std::runtime_error("Wrong field type");
|
if (!cf)
|
||||||
|
throw std::runtime_error("Wrong field type");
|
||||||
return *cf;
|
return *cf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ public:
|
|||||||
RippleAddress getFieldAccount(SField::ref field) const;
|
RippleAddress getFieldAccount(SField::ref field) const;
|
||||||
uint160 getFieldAccount160(SField::ref field) const;
|
uint160 getFieldAccount160(SField::ref field) const;
|
||||||
std::vector<unsigned char> getFieldVL(SField::ref field) const;
|
std::vector<unsigned char> getFieldVL(SField::ref field) const;
|
||||||
STAmount getFieldAmount(SField::ref field) const;
|
const STAmount& getFieldAmount(SField::ref field) const;
|
||||||
STPathSet getFieldPathSet(SField::ref field) const;
|
STPathSet getFieldPathSet(SField::ref field) const;
|
||||||
STVector256 getFieldV256(SField::ref field) const;
|
STVector256 getFieldV256(SField::ref field) const;
|
||||||
|
|
||||||
|
|||||||
@@ -14,10 +14,9 @@
|
|||||||
#include "TransactionErr.h"
|
#include "TransactionErr.h"
|
||||||
|
|
||||||
SETUP_LOG();
|
SETUP_LOG();
|
||||||
DECLARE_INSTANCE(SerializedValue);
|
|
||||||
|
|
||||||
STAmount saZero(CURRENCY_ONE, ACCOUNT_ONE, 0);
|
const STAmount saZero(CURRENCY_ONE, ACCOUNT_ONE, 0);
|
||||||
STAmount saOne(CURRENCY_ONE, ACCOUNT_ONE, 1);
|
const STAmount saOne(CURRENCY_ONE, ACCOUNT_ONE, 1);
|
||||||
|
|
||||||
SerializedType& SerializedType::operator=(const SerializedType& t)
|
SerializedType& SerializedType::operator=(const SerializedType& t)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -44,9 +44,7 @@ static inline const uint160& get_u160_one() { return u160_one; }
|
|||||||
#define ACCOUNT_XRP get_u160_zero()
|
#define ACCOUNT_XRP get_u160_zero()
|
||||||
#define ACCOUNT_ONE get_u160_one() // Used as a place holder.
|
#define ACCOUNT_ONE get_u160_one() // Used as a place holder.
|
||||||
|
|
||||||
DEFINE_INSTANCE(SerializedValue);
|
class SerializedType
|
||||||
|
|
||||||
class SerializedType : private IS_INSTANCE(SerializedValue)
|
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
SField::ptr fName;
|
SField::ptr fName;
|
||||||
@@ -475,8 +473,8 @@ public:
|
|||||||
void roundSelf();
|
void roundSelf();
|
||||||
};
|
};
|
||||||
|
|
||||||
extern STAmount saZero;
|
extern const STAmount saZero;
|
||||||
extern STAmount saOne;
|
extern const STAmount saOne;
|
||||||
|
|
||||||
class STHash128 : public SerializedType
|
class STHash128 : public SerializedType
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -221,6 +221,7 @@ int main(int argc, char* argv[])
|
|||||||
{
|
{
|
||||||
unit_test_main(init_unit_test, argc, argv);
|
unit_test_main(init_unit_test, argc, argv);
|
||||||
|
|
||||||
|
InstanceType::shutdown();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -279,6 +280,7 @@ int main(int argc, char* argv[])
|
|||||||
if (1 == iResult && !vm.count("quiet"))
|
if (1 == iResult && !vm.count("quiet"))
|
||||||
printHelp(desc);
|
printHelp(desc);
|
||||||
|
|
||||||
|
InstanceType::shutdown();
|
||||||
return iResult;
|
return iResult;
|
||||||
}
|
}
|
||||||
// vim:ts=4
|
// vim:ts=4
|
||||||
|
|||||||
Reference in New Issue
Block a user