Skip to content

Instantly share code, notes, and snippets.

@jeremyorme
Created June 20, 2022 14:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jeremyorme/ed8d9dc61c91cea40704981f04dbfa0d to your computer and use it in GitHub Desktop.
Save jeremyorme/ed8d9dc61c91cea40704981f04dbfa0d to your computer and use it in GitHub Desktop.
DbStoreUpdater.init method delegate validation to helpers
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