mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
Cosmetic SQL clean up.
This commit is contained in:
@@ -64,7 +64,7 @@ bool HashedObject::store(HashedObjectType type, uint32 index, const std::vector<
|
|||||||
|
|
||||||
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
||||||
Database* db=theApp->getHashNodeDB()->getDB();
|
Database* db=theApp->getHashNodeDB()->getDB();
|
||||||
return db->executeSQL(sql.c_str());
|
return db->executeSQL(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HashedObject::store() const
|
bool HashedObject::store() const
|
||||||
@@ -91,7 +91,7 @@ HashedObject::pointer HashedObject::retrieve(const uint256& hash)
|
|||||||
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
||||||
Database* db=theApp->getHashNodeDB()->getDB();
|
Database* db=theApp->getHashNodeDB()->getDB();
|
||||||
|
|
||||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows())
|
if(!db->executeSQL(sql) || !db->startIterRows())
|
||||||
return HashedObject::pointer();
|
return HashedObject::pointer();
|
||||||
|
|
||||||
std::string type;
|
std::string type;
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ bool Ledger::unitTest()
|
|||||||
uint256 Ledger::getHash()
|
uint256 Ledger::getHash()
|
||||||
{
|
{
|
||||||
if(!mValidHash) updateHash();
|
if(!mValidHash) updateHash();
|
||||||
return(mHash);
|
return(mHash);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Ledger::saveAcceptedLedger(Ledger::pointer ledger)
|
void Ledger::saveAcceptedLedger(Ledger::pointer ledger)
|
||||||
@@ -248,7 +248,7 @@ void Ledger::saveAcceptedLedger(Ledger::pointer ledger)
|
|||||||
sql.append("');");
|
sql.append("');");
|
||||||
|
|
||||||
ScopedLock sl(theApp->getLedgerDB()->getDBLock());
|
ScopedLock sl(theApp->getLedgerDB()->getDBLock());
|
||||||
theApp->getLedgerDB()->getDB()->executeSQL(sql.c_str());
|
theApp->getLedgerDB()->getDB()->executeSQL(sql);
|
||||||
|
|
||||||
// write out dirty nodes
|
// write out dirty nodes
|
||||||
while(ledger->mTransactionMap->flushDirty(64, TRANSACTION_NODE, ledger->mLedgerSeq))
|
while(ledger->mTransactionMap->flushDirty(64, TRANSACTION_NODE, ledger->mLedgerSeq))
|
||||||
|
|||||||
@@ -35,13 +35,13 @@ protected:
|
|||||||
public:
|
public:
|
||||||
LedgerAcquire(const uint256& hash);
|
LedgerAcquire(const uint256& hash);
|
||||||
|
|
||||||
const uint256& getHash() const { return mHash; }
|
const uint256& getHash() const { return mHash; }
|
||||||
bool isComplete() const { return mComplete; }
|
bool isComplete() const { return mComplete; }
|
||||||
bool isFailed() const { return mFailed; }
|
bool isFailed() const { return mFailed; }
|
||||||
bool isBase() const { return mHaveBase; }
|
bool isBase() const { return mHaveBase; }
|
||||||
bool isAcctStComplete() const { return mHaveState; }
|
bool isAcctStComplete() const { return mHaveState; }
|
||||||
bool isTransComplete() const { return mHaveTransactions; }
|
bool isTransComplete() const { return mHaveTransactions; }
|
||||||
Ledger::pointer getLedger() { return mLedger; }
|
Ledger::pointer getLedger() { return mLedger; }
|
||||||
|
|
||||||
void addOnComplete(boost::function<void (LedgerAcquire::pointer)>);
|
void addOnComplete(boost::function<void (LedgerAcquire::pointer)>);
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ protected:
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
LedgerAcquireMaster() { ; }
|
LedgerAcquireMaster() { ; }
|
||||||
|
|
||||||
LedgerAcquire::pointer findCreate(const uint256& hash);
|
LedgerAcquire::pointer findCreate(const uint256& hash);
|
||||||
LedgerAcquire::pointer find(const uint256& hash);
|
LedgerAcquire::pointer find(const uint256& hash);
|
||||||
bool hasLedger(const uint256& ledgerHash);
|
bool hasLedger(const uint256& ledgerHash);
|
||||||
@@ -69,3 +69,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -21,3 +21,4 @@ struct LedgerEntryFormat
|
|||||||
extern LedgerEntryFormat LedgerFormats[];
|
extern LedgerEntryFormat LedgerFormats[];
|
||||||
extern LedgerEntryFormat* getLgrFormat(LedgerEntryType t);
|
extern LedgerEntryFormat* getLgrFormat(LedgerEntryType t);
|
||||||
#endif
|
#endif
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -77,10 +77,11 @@ Ledger::pointer LedgerHistory::canonicalizeLedger(Ledger::pointer ledger, bool s
|
|||||||
if(ret) return ret;
|
if(ret) return ret;
|
||||||
return ledger;
|
return ledger;
|
||||||
}
|
}
|
||||||
|
|
||||||
// save input ledger in map if not in map, otherwise return corresponding map ledger
|
// save input ledger in map if not in map, otherwise return corresponding map ledger
|
||||||
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
|
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
|
||||||
mLedgersByHash.canonicalize(h, ledger);
|
mLedgersByHash.canonicalize(h, ledger);
|
||||||
if(ledger->isAccepted()) mLedgersByIndex[ledger->getLedgerSeq()]=ledger;
|
if(ledger->isAccepted()) mLedgersByIndex[ledger->getLedgerSeq()]=ledger;
|
||||||
return ledger;
|
return ledger;
|
||||||
}
|
}
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ class LedgerHistory
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
LedgerHistory();
|
LedgerHistory();
|
||||||
|
|
||||||
void addLedger(Ledger::pointer ledger);
|
void addLedger(Ledger::pointer ledger);
|
||||||
void addAcceptedLedger(Ledger::pointer ledger);
|
void addAcceptedLedger(Ledger::pointer ledger);
|
||||||
|
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ uint256 Ledger::getRippleIndex(const uint160& accountID, const uint160& extendTo
|
|||||||
memcpy(base.begin() + (160/8), (accountID^currency).begin(), (256/8)-(160/8));
|
memcpy(base.begin() + (160/8), (accountID^currency).begin(), (256/8)-(160/8));
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -67,3 +67,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -109,3 +109,4 @@ SerializedLedgerEntry::pointer Ledger::getNickname(LedgerStateParms& parms, cons
|
|||||||
return SerializedLedgerEntry::pointer();
|
return SerializedLedgerEntry::pointer();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ CKey::pointer PubKeyCache::locate(const NewcoinAddress& id)
|
|||||||
{ // is it in the database
|
{ // is it in the database
|
||||||
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
||||||
Database* db=theApp->getTxnDB()->getDB();
|
Database* db=theApp->getTxnDB()->getDB();
|
||||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows())
|
if(!db->executeSQL(sql) || !db->startIterRows())
|
||||||
return CKey::pointer();
|
return CKey::pointer();
|
||||||
pkSize=db->getBinary("PubKey", &(data.front()), data.size());
|
pkSize=db->getBinary("PubKey", &(data.front()), data.size());
|
||||||
db->endIterRows();
|
db->endIterRows();
|
||||||
@@ -63,7 +63,7 @@ CKey::pointer PubKeyCache::store(const NewcoinAddress& id, CKey::pointer key)
|
|||||||
sql.append(");");
|
sql.append(");");
|
||||||
|
|
||||||
ScopedLock dbl(theApp->getTxnDB()->getDBLock());
|
ScopedLock dbl(theApp->getTxnDB()->getDBLock());
|
||||||
theApp->getTxnDB()->getDB()->executeSQL(sql.c_str(), true);
|
theApp->getTxnDB()->getDB()->executeSQL(sql, true);
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -342,7 +342,7 @@ SHAMapItem::pointer SHAMap::peekItem(const uint256& id)
|
|||||||
|
|
||||||
bool SHAMap::hasItem(const uint256& id)
|
bool SHAMap::hasItem(const uint256& id)
|
||||||
{ // does the tree have an item with this ID
|
{ // does the tree have an item with this ID
|
||||||
boost::recursive_mutex::scoped_lock sl(mLock);
|
boost::recursive_mutex::scoped_lock sl(mLock);
|
||||||
SHAMapTreeNode::pointer leaf=walkTo(id, false);
|
SHAMapTreeNode::pointer leaf=walkTo(id, false);
|
||||||
if(!leaf) return false;
|
if(!leaf) return false;
|
||||||
SHAMapItem::pointer item=leaf->peekItem();
|
SHAMapItem::pointer item=leaf->peekItem();
|
||||||
@@ -472,7 +472,7 @@ bool SHAMap::addGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
|||||||
node->makeInner();
|
node->makeInner();
|
||||||
|
|
||||||
int b1, b2;
|
int b1, b2;
|
||||||
|
|
||||||
while( (b1=node->selectBranch(tag)) == (b2=node->selectBranch(otherItem->getTag())) )
|
while( (b1=node->selectBranch(tag)) == (b2=node->selectBranch(otherItem->getTag())) )
|
||||||
{ // we need a new inner node, since both go on same branch at this level
|
{ // we need a new inner node, since both go on same branch at this level
|
||||||
#ifdef ST_DEBUG
|
#ifdef ST_DEBUG
|
||||||
@@ -675,4 +675,4 @@ bool SHAMap::TestSHAMap()
|
|||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -251,7 +251,7 @@ protected:
|
|||||||
|
|
||||||
bool walkBranch(SHAMapTreeNode::pointer node, SHAMapItem::pointer otherMapItem, bool isFirstMap,
|
bool walkBranch(SHAMapTreeNode::pointer node, SHAMapItem::pointer otherMapItem, bool isFirstMap,
|
||||||
SHAMapDiff& differences, int& maxCount);
|
SHAMapDiff& differences, int& maxCount);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
// build new map
|
// build new map
|
||||||
@@ -327,3 +327,4 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -368,3 +368,4 @@ const uint256& SHAMapTreeNode::getChildHash(int m) const
|
|||||||
assert( (m>=0) && (m<16) && (mType==tnINNER) );
|
assert( (m>=0) && (m<16) && (mType==tnINNER) );
|
||||||
return mHashes[m];
|
return mHashes[m];
|
||||||
}
|
}
|
||||||
|
// vim:ts=4
|
||||||
|
|||||||
@@ -228,7 +228,7 @@ bool Transaction::save() const
|
|||||||
|
|
||||||
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
||||||
Database* db = theApp->getTxnDB()->getDB();
|
Database* db = theApp->getTxnDB()->getDB();
|
||||||
return db->executeSQL(sql.c_str());
|
return db->executeSQL(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction::pointer Transaction::transactionFromSQL(const std::string& sql)
|
Transaction::pointer Transaction::transactionFromSQL(const std::string& sql)
|
||||||
@@ -339,7 +339,7 @@ static bool isHex(char j)
|
|||||||
if ((j >= 'a') && (j <= 'f')) return true;
|
if ((j >= 'a') && (j <= 'f')) return true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Transaction::isHexTxID(const std::string& txid)
|
bool Transaction::isHexTxID(const std::string& txid)
|
||||||
{
|
{
|
||||||
if (txid.size() != 64) return false;
|
if (txid.size() != 64) return false;
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ void ValidationCollection::addToDB(newcoin::Validation& valid,int weCare)
|
|||||||
db->escape(hanko.begin(),hanko.GetSerializeSize(),hankoStr);
|
db->escape(hanko.begin(),hanko.GetSerializeSize(),hankoStr);
|
||||||
db->escape(sig.begin(),sig.GetSerializeSize(),sigStr);
|
db->escape(sig.begin(),sig.GetSerializeSize(),sigStr);
|
||||||
string sql=strprintf("INSERT INTO Validations (LedgerIndex,Hash,Hanko,SeqNum,Sig,WeCare) values (%d,%s,%s,%d,%s,%d)",valid.ledgerindex(),hashStr.c_str(),hankoStr.c_str(),valid.seqnum(),sigStr.c_str(),weCare);
|
string sql=strprintf("INSERT INTO Validations (LedgerIndex,Hash,Hanko,SeqNum,Sig,WeCare) values (%d,%s,%s,%d,%s,%d)",valid.ledgerindex(),hashStr.c_str(),hankoStr.c_str(),valid.seqnum(),sigStr.c_str(),weCare);
|
||||||
db->executeSQL(sql.c_str());
|
db->executeSQL(sql);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -190,7 +190,7 @@ LocalAccountFamily::pointer LocalAccountFamily::readFamily(const NewcoinAddress&
|
|||||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||||
Database *db=theApp->getWalletDB()->getDB();
|
Database *db=theApp->getWalletDB()->getDB();
|
||||||
|
|
||||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows())
|
if(!db->executeSQL(sql) || !db->startIterRows())
|
||||||
return LocalAccountFamily::pointer();
|
return LocalAccountFamily::pointer();
|
||||||
|
|
||||||
db->getStr("Comment", comment);
|
db->getStr("Comment", comment);
|
||||||
@@ -223,7 +223,7 @@ void LocalAccountFamily::write(bool is_new)
|
|||||||
sql.append(");");
|
sql.append(");");
|
||||||
|
|
||||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||||
theApp->getWalletDB()->getDB()->executeSQL(sql.c_str());
|
theApp->getWalletDB()->getDB()->executeSQL(sql);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string LocalAccountFamily::getSQLFields()
|
std::string LocalAccountFamily::getSQLFields()
|
||||||
@@ -446,7 +446,7 @@ void Wallet::load()
|
|||||||
|
|
||||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||||
Database *db=theApp->getWalletDB()->getDB();
|
Database *db=theApp->getWalletDB()->getDB();
|
||||||
if(!db->executeSQL(sql.c_str()))
|
if(!db->executeSQL(sql))
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
std::cerr << "Unable to load wallet" << std::endl;
|
std::cerr << "Unable to load wallet" << std::endl;
|
||||||
|
|||||||
Reference in New Issue
Block a user