Allow LevelDB and SQLite to co-exist in the build and have the backing

store for hashed nodes selectable in the config.
This commit is contained in:
JoelKatz
2013-05-07 15:04:23 -07:00
parent a417640c9d
commit e086fa5a5d
10 changed files with 131 additions and 59 deletions

View File

@@ -58,15 +58,42 @@ protected:
std::vector< boost::shared_ptr<HashedObject> > mWriteSet;
bool mWritePending;
bool mLevelDB;
public:
HashedObjectStore(int cacheSize, int cacheAge);
bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
const uint256& hash);
bool isLevelDB() { return mLevelDB; }
HashedObject::pointer retrieve(const uint256& hash);
bool store(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
const uint256& hash)
{
#ifdef USE_LEVELDB
if (mLevelDB)
return storeLevelDB(type, index, data, hash);
#endif
return storeSQLite(type, index, data, hash);
}
HashedObject::pointer retrieve(const uint256& hash)
{
#ifdef USE_LEVELDB
if (mLevelDB)
return retrieveLevelDB(hash);
#endif
return retrieveSQLite(hash);
}
bool storeSQLite(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
const uint256& hash);
HashedObject::pointer retrieveSQLite(const uint256& hash);
#ifdef USE_LEVELDB
bool storeLevelDB(HashedObjectType type, uint32 index, const std::vector<unsigned char>& data,
const uint256& hash);
HashedObject::pointer retrieveLevelDB(const uint256& hash);
#endif
void bulkWrite();
void waitWrite();