From 65a1d00751728e802952ff26c0017530a18d993e Mon Sep 17 00:00:00 2001 From: JoelKatz Date: Thu, 17 Jan 2013 10:54:37 -0800 Subject: [PATCH] Remove dead PubKeyCache code. --- newcoin.vcxproj | 2 - newcoin.vcxproj.filters | 6 --- ripple2010.vcxproj | 2 - ripple2010.vcxproj.filters | 6 --- src/cpp/ripple/DBInit.cpp | 4 -- src/cpp/ripple/PubKeyCache.cpp | 70 ---------------------------------- src/cpp/ripple/PubKeyCache.h | 25 ------------ 7 files changed, 115 deletions(-) delete mode 100644 src/cpp/ripple/PubKeyCache.cpp delete mode 100644 src/cpp/ripple/PubKeyCache.h diff --git a/newcoin.vcxproj b/newcoin.vcxproj index 737324e65..72e758a47 100644 --- a/newcoin.vcxproj +++ b/newcoin.vcxproj @@ -146,7 +146,6 @@ - @@ -253,7 +252,6 @@ - diff --git a/newcoin.vcxproj.filters b/newcoin.vcxproj.filters index 796adfdd7..365cb7109 100644 --- a/newcoin.vcxproj.filters +++ b/newcoin.vcxproj.filters @@ -174,9 +174,6 @@ Source Files - - Source Files - Source Files @@ -509,9 +506,6 @@ Header Files - - Header Files - Header Files diff --git a/ripple2010.vcxproj b/ripple2010.vcxproj index a7f8d1599..18e3ea1d2 100644 --- a/ripple2010.vcxproj +++ b/ripple2010.vcxproj @@ -144,7 +144,6 @@ - @@ -244,7 +243,6 @@ - diff --git a/ripple2010.vcxproj.filters b/ripple2010.vcxproj.filters index 2ac1549e3..77ef08370 100644 --- a/ripple2010.vcxproj.filters +++ b/ripple2010.vcxproj.filters @@ -171,9 +171,6 @@ Source Files - - Source Files - Source Files @@ -503,9 +500,6 @@ Header Files - - Header Files - Header Files diff --git a/src/cpp/ripple/DBInit.cpp b/src/cpp/ripple/DBInit.cpp index 4365eaad2..b16ba0f41 100644 --- a/src/cpp/ripple/DBInit.cpp +++ b/src/cpp/ripple/DBInit.cpp @@ -19,10 +19,6 @@ const char *TxnDBInit[] = { RawTxn BLOB, \ TxnMeta BLOB \ );", - "CREATE TABLE PubKeys ( \ - ID CHARACTER(35) PRIMARY KEY, \ - PubKey BLOB \ - );", "CREATE TABLE AccountTransactions ( \ TransID CHARACTER(64), \ Account CHARACTER(64), \ diff --git a/src/cpp/ripple/PubKeyCache.cpp b/src/cpp/ripple/PubKeyCache.cpp deleted file mode 100644 index 8b545d51f..000000000 --- a/src/cpp/ripple/PubKeyCache.cpp +++ /dev/null @@ -1,70 +0,0 @@ -#include "PubKeyCache.h" -#include "Application.h" - -CKey::pointer PubKeyCache::locate(const RippleAddress& id) -{ - { // is it in cache - boost::mutex::scoped_lock sl(mLock); - std::map::iterator it(mCache.find(id)); - if(it!=mCache.end()) return it->second; - } - - std::string sql="SELECT * from PubKeys WHERE ID='"; - sql.append(id.humanAccountID()); - sql.append("';'"); - std::vector data; - data.resize(66); // our public keys are actually 33 bytes - int pkSize; - - { // is it in the database - ScopedLock sl(theApp->getTxnDB()->getDBLock()); - Database* db=theApp->getTxnDB()->getDB(); - if(!db->executeSQL(sql) || !db->startIterRows()) - return CKey::pointer(); - pkSize = db->getBinary("PubKey", &(data.front()), data.size()); - db->endIterRows(); - } - data.resize(pkSize); - CKey::pointer ckp(new CKey()); - if(!ckp->SetPubKey(data)) - { - assert(false); // bad data in DB - return CKey::pointer(); - } - - { // put it in cache (okay if we race with another retriever) - boost::mutex::scoped_lock sl(mLock); - mCache.insert(std::make_pair(id, ckp)); - } - return ckp; -} - -CKey::pointer PubKeyCache::store(const RippleAddress& id, const CKey::pointer& key) -{ // stored if needed, returns cached copy (possibly the original) - { - boost::mutex::scoped_lock sl(mLock); - std::pair::iterator, bool> pit(mCache.insert(std::make_pair(id, key))); - if(!pit.second) // there was an existing key - return pit.first->second; - } - - std::vector pk = key->GetPubKey(); - - std::string sql = "INSERT INTO PubKeys (ID,PubKey) VALUES ('"; - sql += id.humanAccountID(); - sql += "',"; - sql += sqlEscape(pk); - sql.append(");"); - - ScopedLock dbl(theApp->getTxnDB()->getDBLock()); - theApp->getTxnDB()->getDB()->executeSQL(sql, true); - - return key; -} - -void PubKeyCache::clear() -{ - boost::mutex::scoped_lock sl(mLock); - mCache.clear(); -} -// vim:ts=4 diff --git a/src/cpp/ripple/PubKeyCache.h b/src/cpp/ripple/PubKeyCache.h deleted file mode 100644 index 91023cfe9..000000000 --- a/src/cpp/ripple/PubKeyCache.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef __PUBKEYCACHE__ -#define __PUBKEYCACHE__ - -#include - -#include - -#include "RippleAddress.h" -#include "key.h" - -class PubKeyCache -{ -private: - boost::mutex mLock; - std::map mCache; - -public: - PubKeyCache() { ; } - - CKey::pointer locate(const RippleAddress& id); - CKey::pointer store(const RippleAddress& id, const CKey::pointer& key); - void clear(); -}; - -#endif