From 7cdd4f79e3fa75918c80ef2b7ae81376747f7152 Mon Sep 17 00:00:00 2001 From: c-blake Date: Tue, 14 Mar 2023 18:32:15 -0400 Subject: [PATCH] Resuscitate https://github.com/status-im/nim-codex/pull/251 except for (#358) A) renaming to --repo-kind which makes more sense in the current code and B) without a working cacheStore (yet) Tagging related https://github.com/status-im/nim-codex/issues/357 --- README.md | 1 + codex/codex.nim | 9 +++++++-- codex/conf.nim | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d627362d..2ff0a2fb 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,7 @@ The following options are available: --max-peers The maximum number of peers to connect to [=160]. --agent-string Node agent string which is used as identifier in network [=Codex]. -p, --api-port The REST Api port [=8080]. + --repo-kind backend for main repo store (fs, sqlite) [=fs]. -q, --storage-quota The size of the total storage quota dedicated to the node [=8589934592]. -t, --block-ttl Default block timeout in seconds - 0 disables the ttl [=86400]. -c, --cache-size The size in MiB of the block cache, 0 disables the cache - might help on slow diff --git a/codex/codex.nim b/codex/codex.nim index e43dadb7..48a13de5 100644 --- a/codex/codex.nim +++ b/codex/codex.nim @@ -158,9 +158,14 @@ proc new*(T: type CodexServer, config: CodexConf, privateKey: CodexPrivateKey): wallet = WalletRef.new(EthPrivateKey.random()) network = BlockExcNetwork.new(switch) + repoData = case config.repoKind + of repoFS: Datastore(FSDatastore.new($config.dataDir, depth = 5) + .expect("Should create repo file data store!")) + of repoSQLite: Datastore(SQLiteDatastore.new($config.dataDir) + .expect("Should create repo SQLite data store!")) + repoStore = RepoStore.new( - repoDs = Datastore(FSDatastore.new($config.dataDir, depth = 5) - .expect("Should create repo data store!")), + repoDs = repoData, metaDs = SQLiteDatastore.new(config.dataDir / CodexMetaNamespace) .expect("Should create meta data store!"), quotaMaxBytes = config.storageQuota.uint, diff --git a/codex/conf.nim b/codex/conf.nim index 1daf8070..11cd8446 100644 --- a/codex/conf.nim +++ b/codex/conf.nim @@ -46,6 +46,10 @@ type Json = "json" None = "none" + RepoKind* = enum + repoFS = "fs" + repoSQLite = "sqlite" + CodexConf* = object logLevel* {. defaultValue: "INFO" @@ -151,6 +155,12 @@ type name: "api-port" abbr: "p" }: int + repoKind* {. + desc: "backend for main repo store (fs, sqlite)" + defaultValueDesc: "fs" + defaultValue: repoFS + name: "repo-kind" }: RepoKind + storageQuota* {. desc: "The size of the total storage quota dedicated to the node" defaultValue: DefaultQuotaBytes