-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
class Corestore extends ReadyResource {
constructor (storage, opts = {}) {
super()
this.root = opts.root || null
this.storage = this.root ? this.root.storage : Hypercore.defaultStorage(storage, { id: opts.id, allowBackup: opts.allowBackup })
this.streamTracker = this.root ? this.root.streamTracker : new StreamTracker()
this.cores = this.root ? this.root.cores : new CoreTracker()
this.sessions = new SessionTracker()
this.corestores = this.root ? this.root.corestores : new Set()
this.readOnly = opts.writable === false
this.globalCache = this.root ? this.root.globalCache : (opts.globalCache || null)
this.primaryKey = this.root ? this.root.primaryKey : (opts.primaryKey || null)
this.ns = opts.namespace || DEFAULT_NAMESPACE
this.manifestVersion = opts.manifestVersion || 1
this.watchers = null
this.watchIndex = -1
this._findingPeers = null // here for legacy
this._ongcBound = this._ongc.bind(this)
if (this.root) this.corestores.add(this)
this.ready().catch(noop)
}The corestore allows to overwrite the actual storage among other things including the components that use RockDB. I tried to use a mock system to mock that stuff but it grew quick in complexity due to issues related to node modules, sdm etc. The easiest solution is to re-pass arguments to the CoreStorage like a goodboi. Wiht that I can even use mafi's best kept secret: test-tmp.
This scenario is more aggravated because the constructor is already invoking the method that will trigger the whole ReadyResource lifecycle. Even dirty solutions are a bit more involved.
Metadata
Metadata
Assignees
Labels
No labels