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());
|
||||
Database* db=theApp->getHashNodeDB()->getDB();
|
||||
return db->executeSQL(sql.c_str());
|
||||
return db->executeSQL(sql);
|
||||
}
|
||||
|
||||
bool HashedObject::store() const
|
||||
@@ -91,7 +91,7 @@ HashedObject::pointer HashedObject::retrieve(const uint256& hash)
|
||||
ScopedLock sl(theApp->getHashNodeDB()->getDBLock());
|
||||
Database* db=theApp->getHashNodeDB()->getDB();
|
||||
|
||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows())
|
||||
if(!db->executeSQL(sql) || !db->startIterRows())
|
||||
return HashedObject::pointer();
|
||||
|
||||
std::string type;
|
||||
|
||||
@@ -225,7 +225,7 @@ bool Ledger::unitTest()
|
||||
uint256 Ledger::getHash()
|
||||
{
|
||||
if(!mValidHash) updateHash();
|
||||
return(mHash);
|
||||
return(mHash);
|
||||
}
|
||||
|
||||
void Ledger::saveAcceptedLedger(Ledger::pointer ledger)
|
||||
@@ -248,7 +248,7 @@ void Ledger::saveAcceptedLedger(Ledger::pointer ledger)
|
||||
sql.append("');");
|
||||
|
||||
ScopedLock sl(theApp->getLedgerDB()->getDBLock());
|
||||
theApp->getLedgerDB()->getDB()->executeSQL(sql.c_str());
|
||||
theApp->getLedgerDB()->getDB()->executeSQL(sql);
|
||||
|
||||
// write out dirty nodes
|
||||
while(ledger->mTransactionMap->flushDirty(64, TRANSACTION_NODE, ledger->mLedgerSeq))
|
||||
|
||||
@@ -35,13 +35,13 @@ protected:
|
||||
public:
|
||||
LedgerAcquire(const uint256& hash);
|
||||
|
||||
const uint256& getHash() const { return mHash; }
|
||||
bool isComplete() const { return mComplete; }
|
||||
bool isFailed() const { return mFailed; }
|
||||
bool isBase() const { return mHaveBase; }
|
||||
bool isAcctStComplete() const { return mHaveState; }
|
||||
bool isTransComplete() const { return mHaveTransactions; }
|
||||
Ledger::pointer getLedger() { return mLedger; }
|
||||
const uint256& getHash() const { return mHash; }
|
||||
bool isComplete() const { return mComplete; }
|
||||
bool isFailed() const { return mFailed; }
|
||||
bool isBase() const { return mHaveBase; }
|
||||
bool isAcctStComplete() const { return mHaveState; }
|
||||
bool isTransComplete() const { return mHaveTransactions; }
|
||||
Ledger::pointer getLedger() { return mLedger; }
|
||||
|
||||
void addOnComplete(boost::function<void (LedgerAcquire::pointer)>);
|
||||
|
||||
@@ -60,7 +60,7 @@ protected:
|
||||
|
||||
public:
|
||||
LedgerAcquireMaster() { ; }
|
||||
|
||||
|
||||
LedgerAcquire::pointer findCreate(const uint256& hash);
|
||||
LedgerAcquire::pointer find(const uint256& hash);
|
||||
bool hasLedger(const uint256& ledgerHash);
|
||||
@@ -69,3 +69,4 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -21,3 +21,4 @@ struct LedgerEntryFormat
|
||||
extern LedgerEntryFormat LedgerFormats[];
|
||||
extern LedgerEntryFormat* getLgrFormat(LedgerEntryType t);
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -77,10 +77,11 @@ Ledger::pointer LedgerHistory::canonicalizeLedger(Ledger::pointer ledger, bool s
|
||||
if(ret) return ret;
|
||||
return ledger;
|
||||
}
|
||||
|
||||
|
||||
// save input ledger in map if not in map, otherwise return corresponding map ledger
|
||||
boost::recursive_mutex::scoped_lock sl(mLedgersByHash.peekMutex());
|
||||
mLedgersByHash.canonicalize(h, ledger);
|
||||
if(ledger->isAccepted()) mLedgersByIndex[ledger->getLedgerSeq()]=ledger;
|
||||
return ledger;
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
@@ -11,7 +11,7 @@ class LedgerHistory
|
||||
|
||||
public:
|
||||
LedgerHistory();
|
||||
|
||||
|
||||
void addLedger(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));
|
||||
return base;
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
@@ -67,3 +67,4 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -109,3 +109,4 @@ SerializedLedgerEntry::pointer Ledger::getNickname(LedgerStateParms& parms, cons
|
||||
return SerializedLedgerEntry::pointer();
|
||||
}
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
@@ -23,7 +23,7 @@ CKey::pointer PubKeyCache::locate(const NewcoinAddress& id)
|
||||
{ // is it in the database
|
||||
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
||||
Database* db=theApp->getTxnDB()->getDB();
|
||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows())
|
||||
if(!db->executeSQL(sql) || !db->startIterRows())
|
||||
return CKey::pointer();
|
||||
pkSize=db->getBinary("PubKey", &(data.front()), data.size());
|
||||
db->endIterRows();
|
||||
@@ -63,7 +63,7 @@ CKey::pointer PubKeyCache::store(const NewcoinAddress& id, CKey::pointer key)
|
||||
sql.append(");");
|
||||
|
||||
ScopedLock dbl(theApp->getTxnDB()->getDBLock());
|
||||
theApp->getTxnDB()->getDB()->executeSQL(sql.c_str(), true);
|
||||
theApp->getTxnDB()->getDB()->executeSQL(sql, true);
|
||||
return key;
|
||||
}
|
||||
|
||||
|
||||
@@ -342,7 +342,7 @@ SHAMapItem::pointer SHAMap::peekItem(const uint256& id)
|
||||
|
||||
bool SHAMap::hasItem(const uint256& 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);
|
||||
if(!leaf) return false;
|
||||
SHAMapItem::pointer item=leaf->peekItem();
|
||||
@@ -472,7 +472,7 @@ bool SHAMap::addGiveItem(SHAMapItem::pointer item, bool isTransaction)
|
||||
node->makeInner();
|
||||
|
||||
int b1, b2;
|
||||
|
||||
|
||||
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
|
||||
#ifdef ST_DEBUG
|
||||
@@ -675,4 +675,4 @@ bool SHAMap::TestSHAMap()
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// vim:ts=4
|
||||
|
||||
@@ -251,7 +251,7 @@ protected:
|
||||
|
||||
bool walkBranch(SHAMapTreeNode::pointer node, SHAMapItem::pointer otherMapItem, bool isFirstMap,
|
||||
SHAMapDiff& differences, int& maxCount);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// build new map
|
||||
@@ -327,3 +327,4 @@ public:
|
||||
};
|
||||
|
||||
#endif
|
||||
// vim:ts=4
|
||||
|
||||
@@ -368,3 +368,4 @@ const uint256& SHAMapTreeNode::getChildHash(int m) const
|
||||
assert( (m>=0) && (m<16) && (mType==tnINNER) );
|
||||
return mHashes[m];
|
||||
}
|
||||
// vim:ts=4
|
||||
|
||||
@@ -228,7 +228,7 @@ bool Transaction::save() const
|
||||
|
||||
ScopedLock sl(theApp->getTxnDB()->getDBLock());
|
||||
Database* db = theApp->getTxnDB()->getDB();
|
||||
return db->executeSQL(sql.c_str());
|
||||
return db->executeSQL(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;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Transaction::isHexTxID(const std::string& txid)
|
||||
{
|
||||
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(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);
|
||||
db->executeSQL(sql.c_str());
|
||||
db->executeSQL(sql);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ LocalAccountFamily::pointer LocalAccountFamily::readFamily(const NewcoinAddress&
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
Database *db=theApp->getWalletDB()->getDB();
|
||||
|
||||
if(!db->executeSQL(sql.c_str()) || !db->startIterRows())
|
||||
if(!db->executeSQL(sql) || !db->startIterRows())
|
||||
return LocalAccountFamily::pointer();
|
||||
|
||||
db->getStr("Comment", comment);
|
||||
@@ -223,7 +223,7 @@ void LocalAccountFamily::write(bool is_new)
|
||||
sql.append(");");
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
theApp->getWalletDB()->getDB()->executeSQL(sql.c_str());
|
||||
theApp->getWalletDB()->getDB()->executeSQL(sql);
|
||||
}
|
||||
|
||||
std::string LocalAccountFamily::getSQLFields()
|
||||
@@ -446,7 +446,7 @@ void Wallet::load()
|
||||
|
||||
ScopedLock sl(theApp->getWalletDB()->getDBLock());
|
||||
Database *db=theApp->getWalletDB()->getDB();
|
||||
if(!db->executeSQL(sql.c_str()))
|
||||
if(!db->executeSQL(sql))
|
||||
{
|
||||
#ifdef DEBUG
|
||||
std::cerr << "Unable to load wallet" << std::endl;
|
||||
|
||||
Reference in New Issue
Block a user