feat: Configurable heads and entry storage. (#42)

* feat: Configurable heads and entry storage.

* fix: Linting.

* test: Re-enable all tests.

* test: Custom entry storage.

* test: Check for heads paths.

* fix: Check for path using fs.
This commit is contained in:
Hayden Young
2023-03-14 05:42:05 +08:00
committed by GitHub
parent a40bc8bdcf
commit aabfd4e2bc
3 changed files with 227 additions and 103 deletions

View File

@@ -7,19 +7,19 @@ import { ComposedStorage, LRUStorage, IPFSBlockStorage, LevelStorage } from './s
const defaultPointerCount = 0
const defaultCacheSize = 1000
const Database = async ({ OpLog, ipfs, identity, address, name, accessController, directory, storage, meta, headsStorage, pointerCount }) => {
const Database = async ({ OpLog, ipfs, identity, address, name, accessController, directory, meta, headsStorage, entryStorage, pointerCount }) => {
const { Log, Entry } = OpLog
directory = Path.join(directory || './orbitdb', `./${address}/`)
meta = meta || {}
pointerCount = pointerCount || defaultPointerCount
const entryStorage = await ComposedStorage(
entryStorage = entryStorage || await ComposedStorage(
await LRUStorage({ size: defaultCacheSize }),
await IPFSBlockStorage({ ipfs, pin: true })
)
headsStorage = await ComposedStorage(
headsStorage = headsStorage || await ComposedStorage(
await LRUStorage({ size: defaultCacheSize }),
await LevelStorage({ path: Path.join(directory, '/log/_heads/') })
)