Block Storage.md
1 --- 2 tags: 3 - codex/block-storage 4 related: 5 - "[[Uploading and downloading content in Codex]]" 6 - "[[Codex Blocks]]" 7 - "[[Codex Block Exchange Protocol]]" 8 --- 9 #codex/block-storage 10 11 | related | [[Uploading and downloading content in Codex]], [[Codex Blocks]], [[Codex Block Exchange Protocol]] | 12 | ------- | --------------------------------------------------------------------------------------------------- | 13 14 To store blocks and the corresponding metadata, we use `RepoStore`. 15 16 `RepoStore` is a proxy to two underlying stores: 17 18 - `repoDS` - to store the blocks themselves - by default it is `FSDatastore` as indicated by option `repoKind` in `CodexConf` (`codex/conf.nim`). Other types of storage are also available: `SQLiteDatastore`, `LevelDbDatastore`. 19 - `metaDS` - to store the blocks' metadata - `LevelDbDatastore` (`vendor/nim-datastore/datastore/leveldb/leveldbds.nim`). 20 21 The stores are initialized in `CodexServer.new` (`codex/codex.nim`) and injected into `repoStore` (type `RepoStore` defined in `codex/stores/repostore/types.nim`): 22 23 ```nim 24 repoStore = RepoStore.new( 25 repoDs = repoData, 26 metaDs = LevelDbDatastore.new(config.dataDir / CodexMetaNamespace).expect( 27 "Should create metadata store!" 28 ), 29 quotaMaxBytes = config.storageQuota, 30 blockTtl = config.blockTtl, 31 ) 32 ``` 33 34 The default value for `storageQuota` is given by `config.storageQuota` and `config.blockTtl` (`codex/stores/repostore/types.nim`): 35 36 ```nim 37 const 38 DefaultBlockTtl* = 24.hours 39 DefaultQuotaBytes* = 8.GiBs 40 ``` 41 42 `repoStore` together with `engine` (`BlockExcEngine`) are parts of `NetworkStore`, which together with `switch`, `engine`, `discovery`, and `prover` is then provided to `codexNode` (`CodexNodeRef`).