Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async _createStore (type, address, options) {
// Get the type -> class mapping
const Store = databaseTypes[type]
if (!Store) { throw new Error(`Invalid database type '${type}'`) }
let accessController
if (options.accessControllerAddress) {
accessController = await AccessControllers.resolve(this, options.accessControllerAddress, options.accessController)
}
const opts = Object.assign({ replicate: true }, options, {
accessController: accessController,
cache: options.cache,
onClose: this._onClose.bind(this),
onDrop: this._onDrop.bind(this),
onLoad: this._onLoad.bind(this)
})
const identity = options.identity || this.identity
const store = new Store(this._ipfs, identity, address, opts)
store.events.on('write', this._onWrite.bind(this))
// ID of the store is the address as a string
const addr = address.toString()