mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-20 14:23:08 +00:00
Wires up selecting of repostore kind from config.
This commit is contained in:
parent
3599b471c2
commit
ee88b6ce35
@ -183,7 +183,8 @@ proc new*(T: type CodexServer, config: CodexConf, privateKey: CodexPrivateKey):
|
||||
blockTtlSeconds: config.blockTtlSeconds,
|
||||
blockMaintenanceIntervalSeconds: config.blockMaintenanceIntervalSeconds,
|
||||
blockMaintenanceNumberOfBlocks: config.blockMaintenanceNumberOfBlocks,
|
||||
cacheSize: config.cacheSize))
|
||||
cacheSize: config.cacheSize,
|
||||
repoKind: config.repoKind))
|
||||
blockStore = blockStoreManager.getBlockStore()
|
||||
|
||||
peerStore = PeerCtxStore.new()
|
||||
|
||||
@ -32,6 +32,7 @@ import pkg/ethers
|
||||
|
||||
import ./discovery
|
||||
import ./stores
|
||||
import ./consts
|
||||
|
||||
export DefaultCacheSizeMiB, net, DefaultQuotaBytes, DefaultBlockTtl, DefaultBlockMaintenanceInterval, DefaultNumberOfBlocksToMaintainPerInterval
|
||||
|
||||
@ -47,10 +48,6 @@ type
|
||||
Json = "json"
|
||||
None = "none"
|
||||
|
||||
RepoKind* = enum
|
||||
repoFS = "fs"
|
||||
repoSQLite = "sqlite"
|
||||
|
||||
CodexConf* = object
|
||||
configFile* {.
|
||||
desc: "Loads the configuration from a TOML file"
|
||||
|
||||
@ -1,2 +1,8 @@
|
||||
|
||||
type
|
||||
RepoKind* = enum
|
||||
repoFS = "fs"
|
||||
repoSQLite = "sqlite"
|
||||
|
||||
const
|
||||
MiB* = 1024 * 1024
|
||||
|
||||
@ -33,6 +33,7 @@ type
|
||||
blockMaintenanceIntervalSeconds*: int
|
||||
blockMaintenanceNumberOfBlocks*: int
|
||||
cacheSize*: Natural
|
||||
repoKind*: RepoKind
|
||||
|
||||
proc start*(self: BlockStoreManager): Future[void] {.async.} =
|
||||
await self.repoStore.start()
|
||||
@ -45,9 +46,17 @@ proc stop*(self: BlockStoreManager): Future[void] {.async.} =
|
||||
proc getBlockStore*(self: BlockStoreManager): BlockStore =
|
||||
self.blockStore
|
||||
|
||||
proc getRepoDatastore(config: BlockStoreManagerConfig): Datastore =
|
||||
case config.repoKind
|
||||
of repoFS:
|
||||
return Datastore(FSDatastore.new($config.dataDir, depth = 5).expect("Should create repo file data store!"))
|
||||
of repoSQLite:
|
||||
return Datastore(SQLiteDatastore.new($config.dataDir).expect("Should create repo SQLite data store!"))
|
||||
raise newException(Defect, "Unknown repoKind: " & $config.repoKind)
|
||||
|
||||
proc createRepoStore(config: BlockStoreManagerConfig): RepoStore =
|
||||
RepoStore.new(
|
||||
repoDs = Datastore(FSDatastore.new($config.dataDir, depth = 5).expect("Should create repo data store!")),
|
||||
repoDs = getRepoDatastore(config),
|
||||
metaDs = SQLiteDatastore.new(config.dataDir / CodexMetaNamespace).expect("Should create meta data store!"),
|
||||
quotaMaxBytes = config.storageQuota.uint,
|
||||
blockTtl = config.blockTtlSeconds.seconds)
|
||||
|
||||
@ -16,11 +16,7 @@ import pkg/questionable
|
||||
import pkg/questionable/results
|
||||
import pkg/codex/blocktype as bt
|
||||
import pkg/codex/stores/repostore
|
||||
import pkg/codex/clock
|
||||
|
||||
import ../helpers/mocktimer
|
||||
import ../helpers/mockrepostore
|
||||
import ../helpers/mockclock
|
||||
import ../examples
|
||||
|
||||
import codex/namespaces
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user