mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-05 16:57:56 +00:00
Complete public key cache logic and tie to application object.
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
#include "ConnectionPool.h"
|
||||
#include "KnownNodeList.h"
|
||||
#include "TimingService.h"
|
||||
#include "PubKeyCache.h"
|
||||
#include "ScopedLock.h"
|
||||
#include "Wallet.h"
|
||||
#include "database/database.h"
|
||||
@@ -21,6 +22,7 @@ class Application
|
||||
UniqueNodeList mUNL;
|
||||
KnownNodeList mKnownNodes;
|
||||
Wallet mWallet;
|
||||
PubKeyCache mPKCache;
|
||||
Database* mDatabase;
|
||||
|
||||
|
||||
@@ -36,13 +38,14 @@ class Application
|
||||
public:
|
||||
Application();
|
||||
|
||||
ConnectionPool& getConnectionPool(){ return(mConnectionPool); }
|
||||
UniqueNodeList& getUNL(){ return(mUNL); }
|
||||
Wallet& getWallet(){ return(mWallet); }
|
||||
Database* getDB(){ return(mDatabase); }
|
||||
ConnectionPool& getConnectionPool() { return(mConnectionPool); }
|
||||
UniqueNodeList& getUNL() { return(mUNL); }
|
||||
Wallet& getWallet() { return(mWallet); }
|
||||
PubKeyCache& getPubKeyCache() { return mPKCache; }
|
||||
Database* getDB() { return(mDatabase); }
|
||||
ScopedLock getDBLock() { return ScopedLock(dbLock); }
|
||||
|
||||
void setDB(Database* db){ mDatabase=db; }
|
||||
void setDB(Database* db) { mDatabase=db; }
|
||||
|
||||
//Serializer* getSerializer(){ return(mSerializer); }
|
||||
//void setSerializer(Serializer* ser){ mSerializer=ser; }
|
||||
|
||||
@@ -43,12 +43,13 @@ CKey::pointer PubKeyCache::locate(const uint160& id)
|
||||
return ckp;
|
||||
}
|
||||
|
||||
void PubKeyCache::store(const uint160& id, CKey::pointer key)
|
||||
{
|
||||
CKey::pointer PubKeyCache::store(const uint160& id, CKey::pointer key)
|
||||
{ // stored if needed, returns cached copy (possibly the original)
|
||||
if(1)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mLock);
|
||||
if(mCache[id]) return;
|
||||
CKey::pointer cached(mCache[id]);
|
||||
if(cached) return cached;
|
||||
mCache[id]=key;
|
||||
}
|
||||
std::string sql="INSERT INTO PubKeys (ID, PubKey) VALUES ('";
|
||||
@@ -62,6 +63,7 @@ void PubKeyCache::store(const uint160& id, CKey::pointer key)
|
||||
sql.append(";");
|
||||
ScopedLock sl(theApp->getDBLock());
|
||||
theApp->getDB()->executeSQL(sql.c_str());
|
||||
return key;
|
||||
}
|
||||
|
||||
void PubKeyCache::clear()
|
||||
|
||||
@@ -18,7 +18,7 @@ public:
|
||||
PubKeyCache() { ; }
|
||||
|
||||
CKey::pointer locate(const uint160& id);
|
||||
void store(const uint160& id, CKey::pointer key);
|
||||
CKey::pointer store(const uint160& id, CKey::pointer key);
|
||||
void clear(void);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user