diff --git a/modules/ripple_db/ripple_db.cpp b/modules/ripple_db/ripple_db.cpp new file mode 100644 index 0000000000..4384a965e6 --- /dev/null +++ b/modules/ripple_db/ripple_db.cpp @@ -0,0 +1,41 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +/** Add this to get the @ref ripple_db module. + + @file ripple_db.cpp + @ingroup ripple_db +*/ + +#include "ripple_db.h" + +// VFALCO: TODO, fix these warnings! +#ifdef _MSC_VER +//#pragma warning (push) // Causes spurious C4503 "decorated name exceeds maximum length" +//#pragma warning (disable: 4018) // signed/unsigned mismatch +//#pragma warning (disable: 4244) // conversion, possible loss of data +#endif + +#include "src/cpp/database/database.cpp" +#include "src/cpp/database/SqliteDatabase.cpp" +#include "src/cpp/ripple/DBInit.cpp" + + +#ifdef _MSC_VER +//#pragma warning (pop) +#endif diff --git a/modules/ripple_db/ripple_db.h b/modules/ripple_db/ripple_db.h new file mode 100644 index 0000000000..983743e5ff --- /dev/null +++ b/modules/ripple_db/ripple_db.h @@ -0,0 +1,37 @@ +//------------------------------------------------------------------------------ +/* + Copyright (c) 2011-2013, OpenCoin, Inc. + + Permission to use, copy, modify, and/or distribute this software for any + purpose with or without fee is hereby granted, provided that the above + copyright notice and this permission notice appear in all copies. + + THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +*/ +//============================================================================== + +/** Include this to get the @ref ripple_db module. + + @file ripple_db.h + @ingroup ripple_db +*/ + +/** Basic classes. + + This module provides persistent storage facilities. + + @defgroup ripple_db +*/ + +#ifndef RIPPLE_DB_H +#define RIPPLE_DB_H + + + +#endif diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 43a43a47bb..7d8a4f1cb7 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -169,10 +169,21 @@ + - + + true + true + true + true + - + + true + true + true + true + true true @@ -580,7 +591,12 @@ true true - + + true + true + true + true + true true @@ -1015,6 +1031,7 @@ + diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index 0445c9dcc4..a7e5a5a2e3 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -98,6 +98,9 @@ {3f351c55-360d-40bc-a136-4944ce572efd} + + {6097a179-ddad-4c69-9a34-2e3fc2c9fa1d} + @@ -421,12 +424,6 @@ Unsorted Sources - - 1. Modules\ripple_db - - - 1. Modules\ripple_db - 0. Third Party Code\websocket @@ -520,9 +517,6 @@ 1. Modules\ripple_ledger\contracts - - 1. Modules\ripple_db - 1. Modules\ripple_net @@ -703,6 +697,18 @@ 1. Modules\ripple_main + + 1. Modules\ripple_db + + + 1. Modules\ripple_db\storage + + + 1. Modules\ripple_db\storage + + + 1. Modules\ripple_db\storage + @@ -1056,12 +1062,6 @@ Unsorted Sources - - 1. Modules\ripple_db - - - 1. Modules\ripple_db - protoc_generated @@ -1335,6 +1335,15 @@ 1. Modules\ripple_main + + 1. Modules\ripple_db + + + 1. Modules\ripple_db\storage + + + 1. Modules\ripple_db\storage + diff --git a/src/cpp/database/SqliteDatabase.cpp b/src/cpp/database/SqliteDatabase.cpp index c921449d7d..dd644f24bf 100644 --- a/src/cpp/database/SqliteDatabase.cpp +++ b/src/cpp/database/SqliteDatabase.cpp @@ -12,8 +12,6 @@ #include "../ripple/JobQueue.h" #include "../ripple/Log.h" -SETUP_NLOG("DataBase"); - using namespace std; SqliteDatabase::SqliteDatabase(const char* host) : Database(host,"",""), mWalQ(NULL), walRunning(false) @@ -28,7 +26,7 @@ void SqliteDatabase::connect() int rc = sqlite3_open(mHost.c_str(), &mConnection); if (rc) { - cLog(lsFATAL) << "Can't open " << mHost << " " << rc; + WriteLog (lsFATAL, SqliteDatabase) << "Can't open " << mHost << " " << rc; sqlite3_close(mConnection); assert((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED)); } @@ -42,7 +40,7 @@ sqlite3* SqliteDatabase::getAuxConnection() int rc = sqlite3_open(mHost.c_str(), &mAuxConnection); if (rc) { - cLog(lsFATAL) << "Can't aux open " << mHost << " " << rc; + WriteLog (lsFATAL, SqliteDatabase) << "Can't aux open " << mHost << " " << rc; assert((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED)); if (mAuxConnection != NULL) { @@ -78,9 +76,9 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok) if (!fail_ok) { #ifdef DEBUG - cLog(lsWARNING) << "Perror:" << mHost << ": " << rc; - cLog(lsWARNING) << "Statement: " << sql; - cLog(lsWARNING) << "Error: " << sqlite3_errmsg(mConnection); + WriteLog (lsWARNING, SqliteDatabase) << "Perror:" << mHost << ": " << rc; + WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql; + WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg(mConnection); #endif } endIterRows(); @@ -100,7 +98,7 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok) { if ((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED)) { - cLog(lsFATAL) << mHost << " returns error " << rc << ": " << sqlite3_errmsg(mConnection); + WriteLog (lsFATAL, SqliteDatabase) << mHost << " returns error " << rc << ": " << sqlite3_errmsg(mConnection); assert(false); } mMoreRows = false; @@ -108,9 +106,9 @@ bool SqliteDatabase::executeSQL(const char* sql, bool fail_ok) if (!fail_ok) { #ifdef DEBUG - cLog(lsWARNING) << "SQL Serror:" << mHost << ": " << rc; - cLog(lsWARNING) << "Statement: " << sql; - cLog(lsWARNING) << "Error: " << sqlite3_errmsg(mConnection); + WriteLog (lsWARNING, SqliteDatabase) << "SQL Serror:" << mHost << ": " << rc; + WriteLog (lsWARNING, SqliteDatabase) << "Statement: " << sql; + WriteLog (lsWARNING, SqliteDatabase) << "Error: " << sqlite3_errmsg(mConnection); #endif } endIterRows(); @@ -127,6 +125,7 @@ int SqliteDatabase::getNumRowsAffected() return(0); } +// VFALCO: TODO, This must be fixed!!! return value needs to be int64 int SqliteDatabase::getLastInsertID() { return(sqlite3_last_insert_rowid(mConnection)); @@ -164,7 +163,7 @@ bool SqliteDatabase::getNextRow(bool finalize) if (rc==SQLITE_ROW) return(true); assert((rc != SQLITE_BUSY) && (rc != SQLITE_LOCKED)); - tLog((rc != SQLITE_DONE), lsWARNING) << "Rerror: " << mHost << ": " << rc; + CondLog ((rc != SQLITE_DONE), lsWARNING, SqliteDatabase) << "Rerror: " << mHost << ": " << rc; } if (finalize) @@ -272,11 +271,11 @@ void SqliteDatabase::runWal() int ret = sqlite3_wal_checkpoint_v2(mConnection, NULL, SQLITE_CHECKPOINT_PASSIVE, &log, &ckpt); if (ret != SQLITE_OK) { - cLog((ret == SQLITE_LOCKED) ? lsTRACE : lsWARNING) << "WAL(" + WriteLog ((ret == SQLITE_LOCKED) ? lsTRACE : lsWARNING, SqliteDatabase) << "WAL(" << sqlite3_db_filename(mConnection, "main") << "): error " << ret; } else - cLog(lsTRACE) << "WAL(" << sqlite3_db_filename(mConnection, "main") << + WriteLog (lsTRACE, SqliteDatabase) << "WAL(" << sqlite3_db_filename(mConnection, "main") << "): frames=" << log << ", written=" << ckpt; {