Created
June 20, 2022 14:41
-
-
Save jeremyorme/ed8d9dc61c91cea40704981f04dbfa0d to your computer and use it in GitHub Desktop.
DbStoreUpdater.init method delegate validation to helpers
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async init(name: string) { | |
var manifest; | |
if (this._options.address) { | |
this._address = this._options.address; | |
manifest = await ipfsGet<IStoreManifest>(this._ipfs, this._address); | |
if (!this._isStoreManifestValid(manifest)) | |
return; | |
this._ownerIdentity = manifest.ownerIdentity; | |
} | |
else { | |
this._ownerIdentity = this._options.isPublic ? '*' : this._identity.id; | |
manifest = {name, ownerIdentity: this._ownerIdentity}; | |
this._address = await ipfsPut(this._ipfs, manifest); | |
} | |
const storeCid = window.localStorage.getItem('/db/' + this._address); | |
if (storeCid) { | |
const store = await ipfsGet<IStore>(this._ipfs, storeCid); | |
if (!this._isStoreValid(store) || !store) | |
return; | |
this._addCount = store.addCount; | |
await this.merge(store.entryBlockLists); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment