Commit dc708ae1 authored by Mahesh Uligade's avatar Mahesh Uligade

Add Database path argumrnt in LevelDB funcions Close #318

parent 47695b37
Pipeline #31976847 failed with stage
in 0 seconds
......@@ -32,38 +32,38 @@ getDBPath :: String
getDBPath = "/tmp/lvlbloomtest"
-- | Returns Value from database corresponding to given key
getValue :: (MonadUnliftIO m) => ByteString -> m (Maybe ByteString)
getValue key =
getValue :: (MonadUnliftIO m) => ByteString -> String -> m (Maybe ByteString)
getValue key dbPath =
runResourceT $ do
bloom <- bloomFilter 10
db <-
open
getDBPath
dbPath
defaultOptions
{createIfMissing = True, filterPolicy = Just . Left $ bloom}
get db def key
-- | Stores given (Key,Value) pair in database
putValue :: (MonadUnliftIO m) => ByteString -> ByteString -> m ()
putValue key value =
putValue :: (MonadUnliftIO m) => ByteString -> ByteString -> String -> m ()
putValue key value dbPath =
runResourceT $ do
bloom <- bloomFilter 10
db <-
open
getDBPath
dbPath
defaultOptions
{createIfMissing = True, filterPolicy = Just . Left $ bloom}
put db def key value
return ()
-- | Deletes Value from database corresponding to given key
deleteValue :: (MonadUnliftIO m) => ByteString -> m ()
deleteValue key =
deleteValue :: (MonadUnliftIO m) => ByteString -> String -> m ()
deleteValue key dbPath =
runResourceT $ do
bloom <- bloomFilter 10
db <-
open
getDBPath
dbPath
defaultOptions
{createIfMissing = True, filterPolicy = Just . Left $ bloom}
delete db def key
......
......@@ -296,6 +296,7 @@ savePRTHMtoDBPeriodically timeInterval = do
LevelDB.putValue
"PeerReputationHistoryTable"
(Char8.pack $ show listofAllPeersHistory)
"prtDatabase"
savePRTHMtoDBPeriodically timeInterval
-- | Loads the maybeMapOfAllPeersHistory from datbase to
......@@ -303,7 +304,8 @@ savePRTHMtoDBPeriodically timeInterval = do
loadPeerReputationHistoryTable :: (MonadUnliftIO m, HasPRT m) => m ()
loadPeerReputationHistoryTable = do
mapOfAllPeersHistoryTVar <- getPeerReputationHistoryTableTVar
maybeMapOfAllPeersHistory <- LevelDB.getValue "PeerReputationHistoryTable"
maybeMapOfAllPeersHistory <-
LevelDB.getValue "PeerReputationHistoryTable" "prtDatabase"
case maybeMapOfAllPeersHistory of
Nothing -> return ()
Just mapPHty -> do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment