| 1 | package config |
| 2 | |
| 3 | import ( |
| 4 | "encoding/json" |
| 5 | ) |
| 6 | |
| 7 | const ( |
| 8 | // DefaultDataStoreDirectory is the directory to store all the local IPFS data. |
| 9 | DefaultDataStoreDirectory = "datastore" |
| 10 | |
| 11 | // DefaultBlockKeyCacheSize is the size for the blockstore two-queue |
| 12 | // cache which caches block keys and sizes. |
| 13 | DefaultBlockKeyCacheSize = 64 << 10 |
| 14 | |
| 15 | // DefaultWriteThrough specifies whether to use a "write-through" |
| 16 | // Blockstore and Blockservice. This means that they will write |
| 17 | // without performing any reads to check if the incoming blocks are |
| 18 | // already present in the datastore. Enable for datastores with fast |
| 19 | // writes and slower reads. |
| 20 | DefaultWriteThrough bool = true |
| 21 | ) |
| 22 | |
| 23 | // Datastore tracks the configuration of the datastore. |
| 24 | type Datastore struct { |
| 25 | StorageMax string // in B, kB, kiB, MB, ... |
| 26 | StorageGCWatermark int64 // in percentage to multiply on StorageMax |
| 27 | GCPeriod string // in ns, us, ms, s, m, h |
| 28 | |
| 29 | // deprecated fields, use Spec |
| 30 | Type string `json:",omitempty"` |
| 31 | Path string `json:",omitempty"` |
| 32 | NoSync bool `json:",omitempty"` |
| 33 | Params *json.RawMessage `json:",omitempty"` |
| 34 | |
| 35 | Spec map[string]any |
| 36 | |
| 37 | HashOnRead bool |
| 38 | BloomFilterSize int |
| 39 | BlockKeyCacheSize OptionalInteger |
| 40 | WriteThrough Flag `json:",omitempty"` |
| 41 | } |
| 42 | |
| 43 | // DataStorePath returns the default data store path given a configuration root |
| 44 | // (set an empty string to have the default configuration root). |
| 45 | func DataStorePath(configroot string) (string, error) { |
| 46 | return Path(configroot, DefaultDataStoreDirectory) |
| 47 | } |