<commit_before>-- | Higher-level DB functionality.

module Pos.Modern.DB.DB
       ( openNodeDBs
       , getTipBlock
       ) where

import           Control.Lens                 ((^.))
import           Control.Monad.Trans.Resource (MonadResource)
import           System.Directory             (createDirectoryIfMissing)
import           System.FilePath              ((</>))
import           Universum

import           Pos.Modern.DB.Block          (getBlock)
import           Pos.Modern.DB.Class          (MonadDB)
import           Pos.Modern.DB.Error          (DBError (DBMalformed))
import           Pos.Modern.DB.Functions      (openDB)
import           Pos.Modern.DB.Holder         (runDBHolder)
import           Pos.Modern.DB.Types          (NodeDBs (..))
import           Pos.Modern.DB.Utxo           (getTip, prepareUtxoDB)
import           Pos.Ssc.Class.Types          (Ssc)
import           Pos.Types                    (Block, prevBlockL)

-- | Open all DBs stored on disk.
openNodeDBs :: MonadResource m => FilePath -> m (NodeDBs ssc)
openNodeDBs fp = do
    let blockPath = fp </> "blocks"
    let utxoPath = fp </> "utxo"
    let miscPath = fp </> "misc"
    mapM_ ensureDirectoryExists [blockPath, utxoPath, miscPath]<commit_msg>Cosmetic: remove unnecessary imports in Pos.Modern.DB.DB<commit_after>-- | Higher-level DB functionality.

module Pos.Modern.DB.DB
       ( openNodeDBs
       , getTipBlock
       ) where

import           Control.Monad.Trans.Resource (MonadResource)
import           System.Directory             (createDirectoryIfMissing)
import           System.FilePath              ((</>))
import           Universum

import           Pos.Modern.DB.Block          (getBlock)
import           Pos.Modern.DB.Class          (MonadDB)
import           Pos.Modern.DB.Error          (DBError (DBMalformed))
import           Pos.Modern.DB.Functions      (openDB)
import           Pos.Modern.DB.Holder         (runDBHolder)
import           Pos.Modern.DB.Types          (NodeDBs (..))
import           Pos.Modern.DB.Utxo           (getTip, prepareUtxoDB)
import           Pos.Ssc.Class.Types          (Ssc)
import           Pos.Types                    (Block)

-- | Open all DBs stored on disk.
openNodeDBs :: MonadResource m => FilePath -> m (NodeDBs ssc)
openNodeDBs fp = do
    let blockPath = fp </> "blocks"
    let utxoPath = fp </> "utxo"
    let miscPath = fp </> "misc"
    mapM_ ensureDirectoryExists [blockPath, utxoPath, miscPath]
{'fraction_non_alphanumeric': 0.09805510534846029, 'fraction_numerical': 0.0, 'mean_word_length': 1.7525083612040133, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1646019', 'n_tokens_mistral': 737, 'n_tokens_neox': 710, 'n_words': 169}