mirror of
https://github.com/XRPLF/rippled.git
synced 2026-07-30 10:30:22 +00:00
Remove dead PubKeyCache code.
This commit is contained in:
@@ -146,7 +146,6 @@
|
||||
<ClCompile Include="src\cpp\ripple\PeerDoor.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\PlatRand.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\ProofOfWork.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\PubKeyCache.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\RangeSet.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\RegularKeySetTransactor.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\rfc1751.cpp" />
|
||||
@@ -253,7 +252,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\Peer.h" />
|
||||
<ClInclude Include="src\cpp\ripple\PeerDoor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ProofOfWork.h" />
|
||||
<ClInclude Include="src\cpp\ripple\PubKeyCache.h" />
|
||||
<ClInclude Include="src\cpp\ripple\RangeSet.h" />
|
||||
<ClInclude Include="src\cpp\ripple\RegularKeySetTransactor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\rfc1751.h" />
|
||||
|
||||
@@ -174,9 +174,6 @@
|
||||
<ClCompile Include="src\cpp\ripple\PlatRand.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\PubKeyCache.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\RangeSet.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -509,9 +506,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\ProofOfWork.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\PubKeyCache.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\RangeSet.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -144,7 +144,6 @@
|
||||
<ClCompile Include="src\cpp\ripple\PeerDoor.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\PlatRand.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\ProofOfWork.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\PubKeyCache.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\RangeSet.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\RegularKeySetTransactor.cpp" />
|
||||
<ClCompile Include="src\cpp\ripple\rfc1751.cpp" />
|
||||
@@ -244,7 +243,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\Peer.h" />
|
||||
<ClInclude Include="src\cpp\ripple\PeerDoor.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ProofOfWork.h" />
|
||||
<ClInclude Include="src\cpp\ripple\PubKeyCache.h" />
|
||||
<ClInclude Include="src\cpp\ripple\RangeSet.h" />
|
||||
<ClInclude Include="src\cpp\ripple\rfc1751.h" />
|
||||
<ClInclude Include="src\cpp\ripple\ripple.pb.h" />
|
||||
|
||||
@@ -171,9 +171,6 @@
|
||||
<ClCompile Include="src\cpp\ripple\PlatRand.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\PubKeyCache.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\cpp\ripple\RangeSet.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
@@ -503,9 +500,6 @@
|
||||
<ClInclude Include="src\cpp\ripple\ProofOfWork.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\PubKeyCache.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\cpp\ripple\RangeSet.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
|
||||
@@ -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), \
|
||||
|
||||
@@ -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<RippleAddress, CKey::pointer>::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<unsigned char> 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<std::map<RippleAddress,CKey::pointer>::iterator, bool> pit(mCache.insert(std::make_pair(id, key)));
|
||||
if(!pit.second) // there was an existing key
|
||||
return pit.first->second;
|
||||
}
|
||||
|
||||
std::vector<unsigned char> 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
|
||||
@@ -1,25 +0,0 @@
|
||||
#ifndef __PUBKEYCACHE__
|
||||
#define __PUBKEYCACHE__
|
||||
|
||||
#include <map>
|
||||
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include "RippleAddress.h"
|
||||
#include "key.h"
|
||||
|
||||
class PubKeyCache
|
||||
{
|
||||
private:
|
||||
boost::mutex mLock;
|
||||
std::map<RippleAddress, CKey::pointer> mCache;
|
||||
|
||||
public:
|
||||
PubKeyCache() { ; }
|
||||
|
||||
CKey::pointer locate(const RippleAddress& id);
|
||||
CKey::pointer store(const RippleAddress& id, const CKey::pointer& key);
|
||||
void clear();
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user