From e9d405302c044fabbd174e0a5033cb2a3438cdea Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Mon, 28 Jan 2013 07:05:49 -0800 Subject: [PATCH] Use the new code. --- src/cpp/ripple/HashedObject.cpp | 44 +++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/cpp/ripple/HashedObject.cpp b/src/cpp/ripple/HashedObject.cpp index a7d3cb4d4..84e46da1e 100644 --- a/src/cpp/ripple/HashedObject.cpp +++ b/src/cpp/ripple/HashedObject.cpp @@ -90,6 +90,48 @@ void HashedObjectStore::bulkWrite() } // cLog(lsTRACE) << "HOS: writing " << set.size(); +#ifndef NO_SQLITE3_PREPARE + + { + Database* db = theApp->getHashNodeDB()->getDB(); + ScopedLock sl(theApp->getHashNodeDB()->getDBLock()); + static SqliteStatement pSt(db->getSqliteDB(), + "INSERT OR IGNORE INTO CommittedObjects " + "(Hash,ObjType,LedgerIndex,Object) VALUES (?, ?, ?, ?);"); + + db->executeSQL("BEGIN TRANSACTION;"); + + BOOST_FOREACH(const boost::shared_ptr& it, set) + { + const char* type; + + switch (it->getType()) + { + case hotLEDGER: type = "L"; break; + case hotTRANSACTION: type = "T"; break; + case hotACCOUNT_NODE: type = "A"; break; + case hotTRANSACTION_NODE: type = "N"; break; + default: type = "U"; + } + + pSt.reset(); + pSt.bind(1, it->getHash().GetHex()); + pSt.bind(2, type); + pSt.bind(3, it->getIndex()); + pSt.bindStatic(4, it->getData()); + int ret = pSt.step(); + if (!pSt.isDone(ret)) + { + cLog(lsFATAL) << "Error saving hashed object " << ret; + assert(false); + } + } + + db->executeSQL("END TRANSACTION;"); + } + +#else + static boost::format fAdd("INSERT OR IGNORE INTO CommittedObjects " "(Hash,ObjType,LedgerIndex,Object) VALUES ('%s','%c','%u',%s);"); @@ -117,6 +159,8 @@ void HashedObjectStore::bulkWrite() db->executeSQL("END TRANSACTION;"); } +#endif + } }