blockstore-core
Advanced tools
Comparing version 4.3.11 to 4.4.0
(function (root, factory) {(typeof module === 'object' && module.exports) ? module.exports = factory() : root.BlockstoreCore = factory()}(typeof self !== 'undefined' ? self : this, function () { | ||
"use strict";var BlockstoreCore=(()=>{var Qe=Object.create;var X=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var Z=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),be=(t,e)=>{for(var r in e)X(t,r,{get:e[r],enumerable:!0})},ye=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ze(e))!Ke.call(t,o)&&o!==r&&X(t,o,{get:()=>e[o],enumerable:!(n=Xe(e,o))||n.enumerable});return t};var we=(t,e,r)=>(r=t!=null?Qe(He(t)):{},ye(e||!t||!t.__esModule?X(r,"default",{value:t,enumerable:!0}):r,t)),We=t=>ye(X({},"__esModule",{value:!0}),t);var Ce=Z((sr,xe)=>{"use strict";function ge(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function Ye(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return ge(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),ge(new o,r)}}xe.exports=Ye});var Te=Z(($r,Pe)=>{var B=1e3,$=B*60,V=$*60,U=V*24,Ut=U*7,Nt=U*365.25;Pe.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Rt(t);if(r==="number"&&isFinite(t))return e.long?Tt(t):Pt(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Rt(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Nt;case"weeks":case"week":case"w":return r*Ut;case"days":case"day":case"d":return r*U;case"hours":case"hour":case"hrs":case"hr":case"h":return r*V;case"minutes":case"minute":case"mins":case"min":case"m":return r*$;case"seconds":case"second":case"secs":case"sec":case"s":return r*B;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Pt(t){var e=Math.abs(t);return e>=U?Math.round(t/U)+"d":e>=V?Math.round(t/V)+"h":e>=$?Math.round(t/$)+"m":e>=B?Math.round(t/B)+"s":t+"ms"}function Tt(t){var e=Math.abs(t);return e>=U?ee(t,e,U,"day"):e>=V?ee(t,e,V,"hour"):e>=$?ee(t,e,$,"minute"):e>=B?ee(t,e,B,"second"):t+" ms"}function ee(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var Be=Z((Vr,je)=>{function jt(t){r.debug=r,r.default=r,r.coerce=y,r.disable=s,r.enable=o,r.enabled=a,r.humanize=Te(),r.destroy=I,Object.keys(t).forEach(i=>{r[i]=t[i]}),r.names=[],r.skips=[],r.formatters={};function e(i){let f=0;for(let h=0;h<i.length;h++)f=(f<<5)-f+i.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(i){let f,h=null,z,d;function l(...c){if(!l.enabled)return;let p=l,m=Number(new Date),b=m-(f||m);p.diff=b,p.prev=f,p.curr=m,f=m,c[0]=r.coerce(c[0]),typeof c[0]!="string"&&c.unshift("%O");let w=0;c[0]=c[0].replace(/%([a-zA-Z%])/g,(A,C)=>{if(A==="%%")return"%";w++;let S=r.formatters[C];if(typeof S=="function"){let N=c[w];A=S.call(p,N),c.splice(w,1),w--}return A}),r.formatArgs.call(p,c),(p.log||r.log).apply(p,c)}return l.namespace=i,l.useColors=r.useColors(),l.color=r.selectColor(i),l.extend=n,l.destroy=r.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(z!==r.namespaces&&(z=r.namespaces,d=r.enabled(i)),d),set:c=>{h=c}}),typeof r.init=="function"&&r.init(l),l}function n(i,f){let h=r(this.namespace+(typeof f>"u"?":":f)+i);return h.log=this.log,h}function o(i){r.save(i),r.namespaces=i,r.names=[],r.skips=[];let f,h=(typeof i=="string"?i:"").split(/[\s,]+/),z=h.length;for(f=0;f<z;f++)h[f]&&(i=h[f].replace(/\*/g,".*?"),i[0]==="-"?r.skips.push(new RegExp("^"+i.slice(1)+"$")):r.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...r.names.map(u),...r.skips.map(u).map(f=>"-"+f)].join(",");return r.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(i))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function y(i){return i instanceof Error?i.stack||i.message:i}function I(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}je.exports=jt});var $e=Z((v,te)=>{v.formatArgs=$t;v.save=Vt;v.load=_t;v.useColors=Bt;v.storage=qt();v.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();v.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Bt(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function $t(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+te.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}v.log=console.debug||console.log||(()=>{});function Vt(t){try{t?v.storage.setItem("debug",t):v.storage.removeItem("debug")}catch{}}function _t(){let t;try{t=v.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function qt(){try{return localStorage}catch{}}te.exports=Be()(v);var{formatters:Jt}=te.exports;Jt.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var nr={};be(nr,{BaseBlockstore:()=>D,BlackHoleBlockstore:()=>Y,Errors:()=>rr,MemoryBlockstore:()=>W,TieredBlockstore:()=>oe});var R={};be(R,{abortedError:()=>ot,closeFailedError:()=>tt,deleteFailedError:()=>ie,getFailedError:()=>rt,hasFailedError:()=>nt,notFoundError:()=>L,openFailedError:()=>et,putFailedError:()=>se});var M=we(Ce(),1);function et(t){return t=t??new Error("Open failed"),(0,M.default)(t,"ERR_OPEN_FAILED")}function tt(t){return t=t??new Error("Close failed"),(0,M.default)(t,"ERR_CLOSE_FAILED")}function se(t){return t=t??new Error("Put failed"),(0,M.default)(t,"ERR_PUT_FAILED")}function rt(t){return t=t??new Error("Get failed"),(0,M.default)(t,"ERR_GET_FAILED")}function ie(t){return t=t??new Error("Delete failed"),(0,M.default)(t,"ERR_DELETE_FAILED")}function nt(t){return t=t??new Error("Has failed"),(0,M.default)(t,"ERR_HAS_FAILED")}function L(t){return t=t??new Error("Not Found"),(0,M.default)(t,"ERR_NOT_FOUND")}function ot(t){return t=t??new Error("Aborted"),(0,M.default)(t,"ERR_ABORTED")}var D=class{has(e,r){return Promise.reject(new Error(".has is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,r){for await(let{cid:n,block:o}of e)await this.put(n,o,r),yield n}get(e,r){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,r){for await(let n of e)yield{cid:n,block:await this.get(n,r)}}async delete(e,r){await Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,r){for await(let n of e)await this.delete(n,r),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};var ar=new Uint8Array(0);function Ee(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function O(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function st(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var u=t.length,y=t.charAt(0),I=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function f(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var l=0,c=0,p=0,m=d.length;p!==m&&d[p]===0;)p++,l++;for(var b=(m-p)*i+1>>>0,w=new Uint8Array(b);p!==m;){for(var x=d[p],A=0,C=b-1;(x!==0||A<c)&&C!==-1;C--,A++)x+=256*w[C]>>>0,w[C]=x%u>>>0,x=x/u>>>0;if(x!==0)throw new Error("Non-zero carry");c=A,p++}for(var S=b-c;S!==b&&w[S]===0;)S++;for(var N=y.repeat(l);S<b;++S)N+=t.charAt(w[S]);return N}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var l=0;if(d[l]!==" "){for(var c=0,p=0;d[l]===y;)c++,l++;for(var m=(d.length-l)*I+1>>>0,b=new Uint8Array(m);d[l];){var w=r[d.charCodeAt(l)];if(w===255)return;for(var x=0,A=m-1;(w!==0||x<p)&&A!==-1;A--,x++)w+=u*b[A]>>>0,b[A]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");p=x,l++}if(d[l]!==" "){for(var C=m-p;C!==m&&b[C]===0;)C++;for(var S=new Uint8Array(c+(m-C)),N=c;C!==m;)S[N++]=b[C++];return S}}}function z(d){var l=h(d);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:z}}var it=st,at=it,ve=at;var ae=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ce=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Fe(this,e)}},ue=class{decoders;constructor(e){this.decoders=e}or(e){return Fe(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Fe(t,e){return new ue({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var fe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ae(e,r,n),this.decoder=new ce(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ae({name:t,prefix:e,encode:r,decode:n}){return new fe(t,e,r,n)}function le({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=ve(r,t);return Ae({prefix:e,name:t,encode:n,decode:s=>O(o(s))})}function ct(t,e,r,n){let o={};for(let i=0;i<e.length;++i)o[e[i]]=i;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),u=0,y=0,I=0;for(let i=0;i<s;++i){let f=o[t[i]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);y=y<<r|f,u+=r,u>=8&&(u-=8,a[I++]=255&y>>u)}if(u>=r||255&y<<8-u)throw new SyntaxError("Unexpected end of data");return a}function ut(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,u=0;for(let y=0;y<t.length;++y)for(u=u<<8|t[y],a+=8;a>r;)a-=r,s+=e[o&u>>a];if(a!==0&&(s+=e[o&u<<r-a]),n)for(;s.length*r&7;)s+="=";return s}function g({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Ae({prefix:e,name:t,encode(o){return ut(o,n,r)},decode(o){return ct(o,n,r,t)}})}var E=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pr=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),br=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yr=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wr=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gr=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cr=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var k=le({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fr=le({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ft=ke,Se=128,lt=127,dt=~lt,ht=Math.pow(2,31);function ke(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ht;)e[r++]=t&255|Se,t/=128;for(;t&dt;)e[r++]=t&255|Se,t>>>=7;return e[r]=t|0,ke.bytes=r-n+1,e}var pt=de,mt=128,Ie=127;function de(t,n){var r=0,n=n||0,o=0,s=n,a,u=t.length;do{if(s>=u)throw de.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&Ie)<<o:(a&Ie)*Math.pow(2,o),o+=7}while(a>=mt);return de.bytes=s-n,r}var bt=Math.pow(2,7),yt=Math.pow(2,14),wt=Math.pow(2,21),gt=Math.pow(2,28),xt=Math.pow(2,35),Ct=Math.pow(2,42),Et=Math.pow(2,49),vt=Math.pow(2,56),Ft=Math.pow(2,63),At=function(t){return t<bt?1:t<yt?2:t<wt?3:t<gt?4:t<xt?5:t<Ct?6:t<Et?7:t<vt?8:t<Ft?9:10},St={encode:ft,decode:pt,encodingLength:At},It=St,q=It;function J(t,e=0){return[q.decode(t,e),q.decode.bytes]}function P(t,e,r=0){return q.encode(t,e,r),e}function T(t){return q.encodingLength(t)}function Me(t,e){let r=e.byteLength,n=T(t),o=n+T(r),s=new Uint8Array(o+r);return P(t,s,0),P(r,s,n),s.set(e,o),new j(t,r,e,s)}function H(t){let e=O(t),[r,n]=J(e),[o,s]=J(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new j(r,o,a,e)}function ze(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ee(t.bytes,r.bytes)}}var j=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Oe(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Dt(r,he(t),e??k.encoder);default:return Mt(r,he(t),e??E.encoder)}}var Ue=new WeakMap;function he(t){let e=Ue.get(t);if(e==null){let r=new Map;return Ue.set(t,r),r}return e}var K=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==G)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Me(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ze(e.multihash,n.multihash)}toString(e){return Oe(this,e)}toJSON(){return{"/":Oe(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new t(n,o,s,a??Ne(n,o,s.bytes))}else if(r[Lt]===!0){let{version:n,multihash:o,code:s}=r,a=H(o);return t.create(n,s,a)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==G)throw new Error(`Version 0 CID must use dag-pb (code: ${G}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ne(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,G,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=O(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new j(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=J(e.subarray(r));return r+=h,f},o=n(),s=G;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),y=n(),I=r+y,i=I-a;return{version:o,codec:s,multihashCode:u,digestSize:y,multihashSize:i,size:I}}static parse(e,r){let[n,o]=kt(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return he(s).set(n,e),s}};function kt(t,e){switch(t[0]){case"Q":{let r=e??k;return[k.prefix,r.decode(`${k.prefix}${t}`)]}case k.prefix:{let r=e??k;return[k.prefix,r.decode(t)]}case E.prefix:{let r=e??E;return[E.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Dt(t,e,r){let{prefix:n}=r;if(n!==k.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function Mt(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var G=112,zt=18;function Ne(t,e,r){let n=T(t),o=n+T(e),s=new Uint8Array(o+r.byteLength);return P(t,s,0),P(e,s,n),s.set(r,o),s}var Lt=Symbol.for("@ipld/js-cid/CID");var Re=85;var W=class extends D{data;constructor(){super(),this.data=new Map}put(e,r){return this.data.set(E.encode(e.multihash.bytes),r),e}get(e){let r=this.data.get(E.encode(e.multihash.bytes));if(r==null)throw L();return r}has(e){return this.data.has(E.encode(e.multihash.bytes))}async delete(e){this.data.delete(E.encode(e.multihash.bytes))}async*getAll(){for(let[e,r]of this.data.entries())yield{cid:K.createV1(Re,H(E.decode(e))),block:r}}};var Y=class extends D{put(e){return e}get(){throw L()}has(){return!1}async delete(){}async*getAll(){}};var F=we($e(),1);var Ve=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qr=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gr=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});F.default.formatters.b=t=>t==null?"undefined":k.baseEncode(t);F.default.formatters.t=t=>t==null?"undefined":E.baseEncode(t);F.default.formatters.m=t=>t==null?"undefined":Ve.baseEncode(t);F.default.formatters.p=t=>t==null?"undefined":t.toString();F.default.formatters.c=t=>t==null?"undefined":t.toString();F.default.formatters.k=t=>t==null?"undefined":t.toString();F.default.formatters.a=t=>t==null?"undefined":t.toString();function Gt(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function _e(t){let e=Gt(`${t}:trace`);return F.default.enabled(`${t}:trace`)&&F.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,F.default)(`${t}:trace`)),Object.assign((0,F.default)(t),{error:(0,F.default)(`${t}:error`),trace:e})}function Qt(t){return t[Symbol.asyncIterator]!=null}function Xt(t){if(Qt(t))return(async()=>{for await(let e of t);})();for(let e of t);}var pe=Xt;function Zt(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var qe=Zt;function Ht(t){return t[Symbol.asyncIterator]!=null}function Kt(t,e){if(Ht(t))return async function*(){for await(let u of t)await e(u)&&(yield u)}();let r=qe(t),{value:n,done:o}=r.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let u of r)await e(u)&&(yield u)}();let a=e;return function*(){s===!0&&(yield n);for(let u of r)a(u)&&(yield u)}()}var Je=Kt;function re(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var ne=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},_=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new ne(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new ne(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var me=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Q(t={}){return Wt(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Wt(t,e){e=e??{};let r=e.onEnd,n=new _,o,s,a,u=re(),y=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((c,p)=>{s=m=>{s=null,n.push(m);try{c(t(n))}catch(b){p(b)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=re()})}},I=c=>s!=null?s(c):(n.push(c),o),i=c=>(n=new _,s!=null?s({error:c}):(n.push({error:c}),o)),f=c=>{if(a)return o;if(e?.objectMode!==!0&&c?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return I({done:!1,value:c})},h=c=>a?o:(a=!0,c!=null?i(c):I({done:!0})),z=()=>(n=new _,h(),{done:!0}),d=c=>(h(c),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:y,return:z,throw:d,push:f,end:h,get readableLength(){return n.size},onEmpty:async c=>{let p=c?.signal;if(p?.throwIfAborted(),n.isEmpty())return;let m,b;p!=null&&(m=new Promise((w,x)=>{b=()=>{x(new me)},p.addEventListener("abort",b)}));try{await Promise.race([u.promise,m])}finally{b!=null&&p!=null&&p?.removeEventListener("abort",b)}}},r==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(c){return l.throw(c),r!=null&&(r(c),r=void 0),{done:!0}},return(){return l.return(),r!=null&&(r(),r=void 0),{done:!0}},push:f,end(c){return l.end(c),r!=null&&(r(c),r=void 0),o},get readableLength(){return l.readableLength},onEmpty:c=>l.onEmpty(c)},o}function Yt(t){return t[Symbol.asyncIterator]!=null}function er(...t){let e=[];for(let r of t)Yt(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=Q({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let o of n)r.push(o)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var Ge=er;var tr=_e("blockstore:core:tiered"),oe=class extends D{stores;constructor(e){super(),this.stores=e.slice()}async put(e,r,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(e,r,n)})),e}catch(o){throw se(o)}}async get(e,r){for(let n of this.stores)try{let o=await n.get(e,r);if(o!=null)return o}catch(o){tr.error(o)}throw L()}async has(e,r){for(let n of this.stores)if(await n.has(e,r))return!0;return!1}async delete(e,r){try{await Promise.all(this.stores.map(async n=>{await n.delete(e,r)}))}catch(n){throw ie(n)}}async*putMany(e,r={}){let n,o=this.stores.map(s=>{let a=Q({objectMode:!0});return pe(s.putMany(a,r)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s.cid}}finally{o.forEach(s=>s.end())}}async*deleteMany(e,r={}){let n,o=this.stores.map(s=>{let a=Q({objectMode:!0});return pe(s.deleteMany(a,r)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s}}finally{o.forEach(s=>s.end())}}async*getAll(e){let r=new Set;yield*Je(Ge(...this.stores.map(n=>n.getAll(e))),n=>{let o=n.cid.toString();return r.has(o)?!1:(r.add(o),!0)})}};var rr={...R};return We(nr);})(); | ||
"use strict";var BlockstoreCore=(()=>{var Qe=Object.create;var X=Object.defineProperty;var Xe=Object.getOwnPropertyDescriptor;var Ze=Object.getOwnPropertyNames;var He=Object.getPrototypeOf,Ke=Object.prototype.hasOwnProperty;var Z=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),be=(t,e)=>{for(var r in e)X(t,r,{get:e[r],enumerable:!0})},ye=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of Ze(e))!Ke.call(t,o)&&o!==r&&X(t,o,{get:()=>e[o],enumerable:!(n=Xe(e,o))||n.enumerable});return t};var we=(t,e,r)=>(r=t!=null?Qe(He(t)):{},ye(e||!t||!t.__esModule?X(r,"default",{value:t,enumerable:!0}):r,t)),We=t=>ye(X({},"__esModule",{value:!0}),t);var Ce=Z((sr,xe)=>{"use strict";function ge(t,e){for(let r in e)Object.defineProperty(t,r,{value:e[r],enumerable:!0,configurable:!0});return t}function Ye(t,e,r){if(!t||typeof t=="string")throw new TypeError("Please pass an Error to err-code");r||(r={}),typeof e=="object"&&(r=e,e=""),e&&(r.code=e);try{return ge(t,r)}catch{r.message=t.message,r.stack=t.stack;let o=function(){};return o.prototype=Object.create(Object.getPrototypeOf(t)),ge(new o,r)}}xe.exports=Ye});var Te=Z(($r,Pe)=>{var B=1e3,$=B*60,V=$*60,U=V*24,Ut=U*7,Nt=U*365.25;Pe.exports=function(t,e){e=e||{};var r=typeof t;if(r==="string"&&t.length>0)return Rt(t);if(r==="number"&&isFinite(t))return e.long?Tt(t):Pt(t);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(t))};function Rt(t){if(t=String(t),!(t.length>100)){var e=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(t);if(e){var r=parseFloat(e[1]),n=(e[2]||"ms").toLowerCase();switch(n){case"years":case"year":case"yrs":case"yr":case"y":return r*Nt;case"weeks":case"week":case"w":return r*Ut;case"days":case"day":case"d":return r*U;case"hours":case"hour":case"hrs":case"hr":case"h":return r*V;case"minutes":case"minute":case"mins":case"min":case"m":return r*$;case"seconds":case"second":case"secs":case"sec":case"s":return r*B;case"milliseconds":case"millisecond":case"msecs":case"msec":case"ms":return r;default:return}}}}function Pt(t){var e=Math.abs(t);return e>=U?Math.round(t/U)+"d":e>=V?Math.round(t/V)+"h":e>=$?Math.round(t/$)+"m":e>=B?Math.round(t/B)+"s":t+"ms"}function Tt(t){var e=Math.abs(t);return e>=U?ee(t,e,U,"day"):e>=V?ee(t,e,V,"hour"):e>=$?ee(t,e,$,"minute"):e>=B?ee(t,e,B,"second"):t+" ms"}function ee(t,e,r,n){var o=e>=r*1.5;return Math.round(t/r)+" "+n+(o?"s":"")}});var Be=Z((Vr,je)=>{function jt(t){r.debug=r,r.default=r,r.coerce=y,r.disable=s,r.enable=o,r.enabled=a,r.humanize=Te(),r.destroy=I,Object.keys(t).forEach(i=>{r[i]=t[i]}),r.names=[],r.skips=[],r.formatters={};function e(i){let f=0;for(let h=0;h<i.length;h++)f=(f<<5)-f+i.charCodeAt(h),f|=0;return r.colors[Math.abs(f)%r.colors.length]}r.selectColor=e;function r(i){let f,h=null,z,d;function l(...c){if(!l.enabled)return;let p=l,m=Number(new Date),b=m-(f||m);p.diff=b,p.prev=f,p.curr=m,f=m,c[0]=r.coerce(c[0]),typeof c[0]!="string"&&c.unshift("%O");let w=0;c[0]=c[0].replace(/%([a-zA-Z%])/g,(A,C)=>{if(A==="%%")return"%";w++;let S=r.formatters[C];if(typeof S=="function"){let N=c[w];A=S.call(p,N),c.splice(w,1),w--}return A}),r.formatArgs.call(p,c),(p.log||r.log).apply(p,c)}return l.namespace=i,l.useColors=r.useColors(),l.color=r.selectColor(i),l.extend=n,l.destroy=r.destroy,Object.defineProperty(l,"enabled",{enumerable:!0,configurable:!1,get:()=>h!==null?h:(z!==r.namespaces&&(z=r.namespaces,d=r.enabled(i)),d),set:c=>{h=c}}),typeof r.init=="function"&&r.init(l),l}function n(i,f){let h=r(this.namespace+(typeof f>"u"?":":f)+i);return h.log=this.log,h}function o(i){r.save(i),r.namespaces=i,r.names=[],r.skips=[];let f,h=(typeof i=="string"?i:"").split(/[\s,]+/),z=h.length;for(f=0;f<z;f++)h[f]&&(i=h[f].replace(/\*/g,".*?"),i[0]==="-"?r.skips.push(new RegExp("^"+i.slice(1)+"$")):r.names.push(new RegExp("^"+i+"$")))}function s(){let i=[...r.names.map(u),...r.skips.map(u).map(f=>"-"+f)].join(",");return r.enable(""),i}function a(i){if(i[i.length-1]==="*")return!0;let f,h;for(f=0,h=r.skips.length;f<h;f++)if(r.skips[f].test(i))return!1;for(f=0,h=r.names.length;f<h;f++)if(r.names[f].test(i))return!0;return!1}function u(i){return i.toString().substring(2,i.toString().length-2).replace(/\.\*\?$/,"*")}function y(i){return i instanceof Error?i.stack||i.message:i}function I(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")}return r.enable(r.load()),r}je.exports=jt});var $e=Z((v,te)=>{v.formatArgs=$t;v.save=Vt;v.load=_t;v.useColors=Bt;v.storage=qt();v.destroy=(()=>{let t=!1;return()=>{t||(t=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})();v.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"];function Bt(){return typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs)?!0:typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)?!1:typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&parseInt(RegExp.$1,10)>=31||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/)}function $t(t){if(t[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+t[0]+(this.useColors?"%c ":" ")+"+"+te.exports.humanize(this.diff),!this.useColors)return;let e="color: "+this.color;t.splice(1,0,e,"color: inherit");let r=0,n=0;t[0].replace(/%[a-zA-Z%]/g,o=>{o!=="%%"&&(r++,o==="%c"&&(n=r))}),t.splice(n,0,e)}v.log=console.debug||console.log||(()=>{});function Vt(t){try{t?v.storage.setItem("debug",t):v.storage.removeItem("debug")}catch{}}function _t(){let t;try{t=v.storage.getItem("debug")}catch{}return!t&&typeof process<"u"&&"env"in process&&(t=process.env.DEBUG),t}function qt(){try{return localStorage}catch{}}te.exports=Be()(v);var{formatters:Jt}=te.exports;Jt.j=function(t){try{return JSON.stringify(t)}catch(e){return"[UnexpectedJSONParseError]: "+e.message}}});var nr={};be(nr,{BaseBlockstore:()=>D,BlackHoleBlockstore:()=>Y,Errors:()=>rr,MemoryBlockstore:()=>W,TieredBlockstore:()=>oe});var R={};be(R,{abortedError:()=>ot,closeFailedError:()=>tt,deleteFailedError:()=>ie,getFailedError:()=>rt,hasFailedError:()=>nt,notFoundError:()=>L,openFailedError:()=>et,putFailedError:()=>se});var M=we(Ce(),1);function et(t){return t=t??new Error("Open failed"),(0,M.default)(t,"ERR_OPEN_FAILED")}function tt(t){return t=t??new Error("Close failed"),(0,M.default)(t,"ERR_CLOSE_FAILED")}function se(t){return t=t??new Error("Put failed"),(0,M.default)(t,"ERR_PUT_FAILED")}function rt(t){return t=t??new Error("Get failed"),(0,M.default)(t,"ERR_GET_FAILED")}function ie(t){return t=t??new Error("Delete failed"),(0,M.default)(t,"ERR_DELETE_FAILED")}function nt(t){return t=t??new Error("Has failed"),(0,M.default)(t,"ERR_HAS_FAILED")}function L(t){return t=t??new Error("Not Found"),(0,M.default)(t,"ERR_NOT_FOUND")}function ot(t){return t=t??new Error("Aborted"),(0,M.default)(t,"ERR_ABORTED")}var D=class{has(e,r){return Promise.reject(new Error(".has is not implemented"))}put(e,r,n){return Promise.reject(new Error(".put is not implemented"))}async*putMany(e,r){for await(let{cid:n,block:o}of e)await this.put(n,o,r),yield n}get(e,r){return Promise.reject(new Error(".get is not implemented"))}async*getMany(e,r){for await(let n of e)yield{cid:n,block:await this.get(n,r)}}delete(e,r){return Promise.reject(new Error(".delete is not implemented"))}async*deleteMany(e,r){for await(let n of e)await this.delete(n,r),yield n}async*getAll(e){throw new Error(".getAll is not implemented")}};var ar=new Uint8Array(0);function Ee(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}function O(t){if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")}function st(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var r=new Uint8Array(256),n=0;n<r.length;n++)r[n]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),a=s.charCodeAt(0);if(r[a]!==255)throw new TypeError(s+" is ambiguous");r[a]=o}var u=t.length,y=t.charAt(0),I=Math.log(u)/Math.log(256),i=Math.log(256)/Math.log(u);function f(d){if(d instanceof Uint8Array||(ArrayBuffer.isView(d)?d=new Uint8Array(d.buffer,d.byteOffset,d.byteLength):Array.isArray(d)&&(d=Uint8Array.from(d))),!(d instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(d.length===0)return"";for(var l=0,c=0,p=0,m=d.length;p!==m&&d[p]===0;)p++,l++;for(var b=(m-p)*i+1>>>0,w=new Uint8Array(b);p!==m;){for(var x=d[p],A=0,C=b-1;(x!==0||A<c)&&C!==-1;C--,A++)x+=256*w[C]>>>0,w[C]=x%u>>>0,x=x/u>>>0;if(x!==0)throw new Error("Non-zero carry");c=A,p++}for(var S=b-c;S!==b&&w[S]===0;)S++;for(var N=y.repeat(l);S<b;++S)N+=t.charAt(w[S]);return N}function h(d){if(typeof d!="string")throw new TypeError("Expected String");if(d.length===0)return new Uint8Array;var l=0;if(d[l]!==" "){for(var c=0,p=0;d[l]===y;)c++,l++;for(var m=(d.length-l)*I+1>>>0,b=new Uint8Array(m);d[l];){var w=r[d.charCodeAt(l)];if(w===255)return;for(var x=0,A=m-1;(w!==0||x<p)&&A!==-1;A--,x++)w+=u*b[A]>>>0,b[A]=w%256>>>0,w=w/256>>>0;if(w!==0)throw new Error("Non-zero carry");p=x,l++}if(d[l]!==" "){for(var C=m-p;C!==m&&b[C]===0;)C++;for(var S=new Uint8Array(c+(m-C)),N=c;C!==m;)S[N++]=b[C++];return S}}}function z(d){var l=h(d);if(l)return l;throw new Error(`Non-${e} character`)}return{encode:f,decodeUnsafe:h,decode:z}}var it=st,at=it,ve=at;var ae=class{name;prefix;baseEncode;constructor(e,r,n){this.name=e,this.prefix=r,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},ce=class{name;prefix;baseDecode;prefixCodePoint;constructor(e,r,n){if(this.name=e,this.prefix=r,r.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=r.codePointAt(0),this.baseDecode=n}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Fe(this,e)}},ue=class{decoders;constructor(e){this.decoders=e}or(e){return Fe(this,e)}decode(e){let r=e[0],n=this.decoders[r];if(n!=null)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};function Fe(t,e){return new ue({...t.decoders??{[t.prefix]:t},...e.decoders??{[e.prefix]:e}})}var fe=class{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(e,r,n,o){this.name=e,this.prefix=r,this.baseEncode=n,this.baseDecode=o,this.encoder=new ae(e,r,n),this.decoder=new ce(e,r,o)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};function Ae({name:t,prefix:e,encode:r,decode:n}){return new fe(t,e,r,n)}function le({name:t,prefix:e,alphabet:r}){let{encode:n,decode:o}=ve(r,t);return Ae({prefix:e,name:t,encode:n,decode:s=>O(o(s))})}function ct(t,e,r,n){let o={};for(let i=0;i<e.length;++i)o[e[i]]=i;let s=t.length;for(;t[s-1]==="=";)--s;let a=new Uint8Array(s*r/8|0),u=0,y=0,I=0;for(let i=0;i<s;++i){let f=o[t[i]];if(f===void 0)throw new SyntaxError(`Non-${n} character`);y=y<<r|f,u+=r,u>=8&&(u-=8,a[I++]=255&y>>u)}if(u>=r||255&y<<8-u)throw new SyntaxError("Unexpected end of data");return a}function ut(t,e,r){let n=e[e.length-1]==="=",o=(1<<r)-1,s="",a=0,u=0;for(let y=0;y<t.length;++y)for(u=u<<8|t[y],a+=8;a>r;)a-=r,s+=e[o&u>>a];if(a!==0&&(s+=e[o&u<<r-a]),n)for(;s.length*r&7;)s+="=";return s}function g({name:t,prefix:e,bitsPerChar:r,alphabet:n}){return Ae({prefix:e,name:t,encode(o){return ut(o,n,r)},decode(o){return ct(o,n,r,t)}})}var E=g({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),pr=g({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),mr=g({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),br=g({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),yr=g({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),wr=g({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gr=g({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),xr=g({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Cr=g({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var k=le({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Fr=le({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var ft=ke,Se=128,lt=127,dt=~lt,ht=Math.pow(2,31);function ke(t,e,r){e=e||[],r=r||0;for(var n=r;t>=ht;)e[r++]=t&255|Se,t/=128;for(;t&dt;)e[r++]=t&255|Se,t>>>=7;return e[r]=t|0,ke.bytes=r-n+1,e}var pt=de,mt=128,Ie=127;function de(t,n){var r=0,n=n||0,o=0,s=n,a,u=t.length;do{if(s>=u)throw de.bytes=0,new RangeError("Could not decode varint");a=t[s++],r+=o<28?(a&Ie)<<o:(a&Ie)*Math.pow(2,o),o+=7}while(a>=mt);return de.bytes=s-n,r}var bt=Math.pow(2,7),yt=Math.pow(2,14),wt=Math.pow(2,21),gt=Math.pow(2,28),xt=Math.pow(2,35),Ct=Math.pow(2,42),Et=Math.pow(2,49),vt=Math.pow(2,56),Ft=Math.pow(2,63),At=function(t){return t<bt?1:t<yt?2:t<wt?3:t<gt?4:t<xt?5:t<Ct?6:t<Et?7:t<vt?8:t<Ft?9:10},St={encode:ft,decode:pt,encodingLength:At},It=St,q=It;function J(t,e=0){return[q.decode(t,e),q.decode.bytes]}function P(t,e,r=0){return q.encode(t,e,r),e}function T(t){return q.encodingLength(t)}function Me(t,e){let r=e.byteLength,n=T(t),o=n+T(r),s=new Uint8Array(o+r);return P(t,s,0),P(r,s,n),s.set(e,o),new j(t,r,e,s)}function H(t){let e=O(t),[r,n]=J(e),[o,s]=J(e.subarray(n)),a=e.subarray(n+s);if(a.byteLength!==o)throw new Error("Incorrect length");return new j(r,o,a,e)}function ze(t,e){if(t===e)return!0;{let r=e;return t.code===r.code&&t.size===r.size&&r.bytes instanceof Uint8Array&&Ee(t.bytes,r.bytes)}}var j=class{code;size;digest;bytes;constructor(e,r,n,o){this.code=e,this.size=r,this.digest=n,this.bytes=o}};function Oe(t,e){let{bytes:r,version:n}=t;switch(n){case 0:return Dt(r,he(t),e??k.encoder);default:return Mt(r,he(t),e??E.encoder)}}var Ue=new WeakMap;function he(t){let e=Ue.get(t);if(e==null){let r=new Map;return Ue.set(t,r),r}return e}var K=class t{code;version;multihash;bytes;"/";constructor(e,r,n,o){this.code=r,this.version=e,this.multihash=n,this.bytes=o,this["/"]=o}get asCID(){return this}get byteOffset(){return this.bytes.byteOffset}get byteLength(){return this.bytes.byteLength}toV0(){switch(this.version){case 0:return this;case 1:{let{code:e,multihash:r}=this;if(e!==G)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(r.code!==zt)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return t.createV0(r)}default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}toV1(){switch(this.version){case 0:{let{code:e,digest:r}=this.multihash,n=Me(e,r);return t.createV1(this.code,n)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 1. This is a bug please report`)}}equals(e){return t.equals(this,e)}static equals(e,r){let n=r;return n!=null&&e.code===n.code&&e.version===n.version&&ze(e.multihash,n.multihash)}toString(e){return Oe(this,e)}toJSON(){return{"/":Oe(this)}}link(){return this}[Symbol.toStringTag]="CID";[Symbol.for("nodejs.util.inspect.custom")](){return`CID(${this.toString()})`}static asCID(e){if(e==null)return null;let r=e;if(r instanceof t)return r;if(r["/"]!=null&&r["/"]===r.bytes||r.asCID===r){let{version:n,code:o,multihash:s,bytes:a}=r;return new t(n,o,s,a??Ne(n,o,s.bytes))}else if(r[Lt]===!0){let{version:n,multihash:o,code:s}=r,a=H(o);return t.create(n,s,a)}else return null}static create(e,r,n){if(typeof r!="number")throw new Error("String codecs are no longer supported");if(!(n.bytes instanceof Uint8Array))throw new Error("Invalid digest");switch(e){case 0:{if(r!==G)throw new Error(`Version 0 CID must use dag-pb (code: ${G}) block encoding`);return new t(e,r,n,n.bytes)}case 1:{let o=Ne(e,r,n.bytes);return new t(e,r,n,o)}default:throw new Error("Invalid version")}}static createV0(e){return t.create(0,G,e)}static createV1(e,r){return t.create(1,e,r)}static decode(e){let[r,n]=t.decodeFirst(e);if(n.length!==0)throw new Error("Incorrect length");return r}static decodeFirst(e){let r=t.inspectBytes(e),n=r.size-r.multihashSize,o=O(e.subarray(n,n+r.multihashSize));if(o.byteLength!==r.multihashSize)throw new Error("Incorrect length");let s=o.subarray(r.multihashSize-r.digestSize),a=new j(r.multihashCode,r.digestSize,s,o);return[r.version===0?t.createV0(a):t.createV1(r.codec,a),e.subarray(r.size)]}static inspectBytes(e){let r=0,n=()=>{let[f,h]=J(e.subarray(r));return r+=h,f},o=n(),s=G;if(o===18?(o=0,r=0):s=n(),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);let a=r,u=n(),y=n(),I=r+y,i=I-a;return{version:o,codec:s,multihashCode:u,digestSize:y,multihashSize:i,size:I}}static parse(e,r){let[n,o]=kt(e,r),s=t.decode(o);if(s.version===0&&e[0]!=="Q")throw Error("Version 0 CID string must not include multibase prefix");return he(s).set(n,e),s}};function kt(t,e){switch(t[0]){case"Q":{let r=e??k;return[k.prefix,r.decode(`${k.prefix}${t}`)]}case k.prefix:{let r=e??k;return[k.prefix,r.decode(t)]}case E.prefix:{let r=e??E;return[E.prefix,r.decode(t)]}default:{if(e==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[t[0],e.decode(t)]}}}function Dt(t,e,r){let{prefix:n}=r;if(n!==k.prefix)throw Error(`Cannot string encode V0 in ${r.name} encoding`);let o=e.get(n);if(o==null){let s=r.encode(t).slice(1);return e.set(n,s),s}else return o}function Mt(t,e,r){let{prefix:n}=r,o=e.get(n);if(o==null){let s=r.encode(t);return e.set(n,s),s}else return o}var G=112,zt=18;function Ne(t,e,r){let n=T(t),o=n+T(e),s=new Uint8Array(o+r.byteLength);return P(t,s,0),P(e,s,n),s.set(r,o),s}var Lt=Symbol.for("@ipld/js-cid/CID");var Re=85;var W=class extends D{data;constructor(){super(),this.data=new Map}put(e,r){return this.data.set(E.encode(e.multihash.bytes),r),e}get(e){let r=this.data.get(E.encode(e.multihash.bytes));if(r==null)throw L();return r}has(e){return this.data.has(E.encode(e.multihash.bytes))}async delete(e){this.data.delete(E.encode(e.multihash.bytes))}async*getAll(){for(let[e,r]of this.data.entries())yield{cid:K.createV1(Re,H(E.decode(e))),block:r}}};var Y=class extends D{put(e){return e}get(){throw L()}has(){return!1}async delete(){}async*getAll(){}};var F=we($e(),1);var Ve=g({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),qr=g({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Jr=g({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),Gr=g({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});F.default.formatters.b=t=>t==null?"undefined":k.baseEncode(t);F.default.formatters.t=t=>t==null?"undefined":E.baseEncode(t);F.default.formatters.m=t=>t==null?"undefined":Ve.baseEncode(t);F.default.formatters.p=t=>t==null?"undefined":t.toString();F.default.formatters.c=t=>t==null?"undefined":t.toString();F.default.formatters.k=t=>t==null?"undefined":t.toString();F.default.formatters.a=t=>t==null?"undefined":t.toString();function Gt(t){let e=()=>{};return e.enabled=!1,e.color="",e.diff=0,e.log=()=>{},e.namespace=t,e.destroy=()=>!0,e.extend=()=>e,e}function _e(t){let e=Gt(`${t}:trace`);return F.default.enabled(`${t}:trace`)&&F.default.names.map(r=>r.toString()).find(r=>r.includes(":trace"))!=null&&(e=(0,F.default)(`${t}:trace`)),Object.assign((0,F.default)(t),{error:(0,F.default)(`${t}:error`),trace:e})}function Qt(t){return t[Symbol.asyncIterator]!=null}function Xt(t){if(Qt(t))return(async()=>{for await(let e of t);})();for(let e of t);}var pe=Xt;function Zt(t){let[e,r]=t[Symbol.asyncIterator]!=null?[t[Symbol.asyncIterator](),Symbol.asyncIterator]:[t[Symbol.iterator](),Symbol.iterator],n=[];return{peek:()=>e.next(),push:o=>{n.push(o)},next:()=>n.length>0?{done:!1,value:n.shift()}:e.next(),[r](){return this}}}var qe=Zt;function Ht(t){return t[Symbol.asyncIterator]!=null}function Kt(t,e){if(Ht(t))return async function*(){for await(let u of t)await e(u)&&(yield u)}();let r=qe(t),{value:n,done:o}=r.next();if(o===!0)return function*(){}();let s=e(n);if(typeof s.then=="function")return async function*(){await s&&(yield n);for await(let u of r)await e(u)&&(yield u)}();let a=e;return function*(){s===!0&&(yield n);for(let u of r)a(u)&&(yield u)}()}var Je=Kt;function re(){let t={};return t.promise=new Promise((e,r)=>{t.resolve=e,t.reject=r}),t}var ne=class{buffer;mask;top;btm;next;constructor(e){if(!(e>0)||e-1&e)throw new Error("Max size for a FixedFIFO should be a power of two");this.buffer=new Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}push(e){return this.buffer[this.top]!==void 0?!1:(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}isEmpty(){return this.buffer[this.btm]===void 0}},_=class{size;hwm;head;tail;constructor(e={}){this.hwm=e.splitLimit??16,this.head=new ne(this.hwm),this.tail=this.head,this.size=0}calculateSize(e){return e?.byteLength!=null?e.byteLength:1}push(e){if(e?.value!=null&&(this.size+=this.calculateSize(e.value)),!this.head.push(e)){let r=this.head;this.head=r.next=new ne(2*this.head.buffer.length),this.head.push(e)}}shift(){let e=this.tail.shift();if(e===void 0&&this.tail.next!=null){let r=this.tail.next;this.tail.next=null,this.tail=r,e=this.tail.shift()}return e?.value!=null&&(this.size-=this.calculateSize(e.value)),e}isEmpty(){return this.head.isEmpty()}};var me=class extends Error{type;code;constructor(e,r){super(e??"The operation was aborted"),this.type="aborted",this.code=r??"ABORT_ERR"}};function Q(t={}){return Wt(r=>{let n=r.shift();if(n==null)return{done:!0};if(n.error!=null)throw n.error;return{done:n.done===!0,value:n.value}},t)}function Wt(t,e){e=e??{};let r=e.onEnd,n=new _,o,s,a,u=re(),y=async()=>{try{return n.isEmpty()?a?{done:!0}:await new Promise((c,p)=>{s=m=>{s=null,n.push(m);try{c(t(n))}catch(b){p(b)}return o}}):t(n)}finally{n.isEmpty()&&queueMicrotask(()=>{u.resolve(),u=re()})}},I=c=>s!=null?s(c):(n.push(c),o),i=c=>(n=new _,s!=null?s({error:c}):(n.push({error:c}),o)),f=c=>{if(a)return o;if(e?.objectMode!==!0&&c?.byteLength==null)throw new Error("objectMode was not true but tried to push non-Uint8Array value");return I({done:!1,value:c})},h=c=>a?o:(a=!0,c!=null?i(c):I({done:!0})),z=()=>(n=new _,h(),{done:!0}),d=c=>(h(c),{done:!0});if(o={[Symbol.asyncIterator](){return this},next:y,return:z,throw:d,push:f,end:h,get readableLength(){return n.size},onEmpty:async c=>{let p=c?.signal;if(p?.throwIfAborted(),n.isEmpty())return;let m,b;p!=null&&(m=new Promise((w,x)=>{b=()=>{x(new me)},p.addEventListener("abort",b)}));try{await Promise.race([u.promise,m])}finally{b!=null&&p!=null&&p?.removeEventListener("abort",b)}}},r==null)return o;let l=o;return o={[Symbol.asyncIterator](){return this},next(){return l.next()},throw(c){return l.throw(c),r!=null&&(r(c),r=void 0),{done:!0}},return(){return l.return(),r!=null&&(r(),r=void 0),{done:!0}},push:f,end(c){return l.end(c),r!=null&&(r(c),r=void 0),o},get readableLength(){return l.readableLength},onEmpty:c=>l.onEmpty(c)},o}function Yt(t){return t[Symbol.asyncIterator]!=null}function er(...t){let e=[];for(let r of t)Yt(r)||e.push(r);return e.length===t.length?function*(){for(let r of e)yield*r}():async function*(){let r=Q({objectMode:!0});Promise.resolve().then(async()=>{try{await Promise.all(t.map(async n=>{for await(let o of n)r.push(o)})),r.end()}catch(n){r.end(n)}}),yield*r}()}var Ge=er;var tr=_e("blockstore:core:tiered"),oe=class extends D{stores;constructor(e){super(),this.stores=e.slice()}async put(e,r,n){try{return await Promise.all(this.stores.map(async o=>{await o.put(e,r,n)})),e}catch(o){throw se(o)}}async get(e,r){for(let n of this.stores)try{let o=await n.get(e,r);if(o!=null)return o}catch(o){tr.error(o)}throw L()}async has(e,r){for(let n of this.stores)if(await n.has(e,r))return!0;return!1}async delete(e,r){try{await Promise.all(this.stores.map(async n=>{await n.delete(e,r)}))}catch(n){throw ie(n)}}async*putMany(e,r={}){let n,o=this.stores.map(s=>{let a=Q({objectMode:!0});return pe(s.putMany(a,r)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s.cid}}finally{o.forEach(s=>s.end())}}async*deleteMany(e,r={}){let n,o=this.stores.map(s=>{let a=Q({objectMode:!0});return pe(s.deleteMany(a,r)).catch(u=>{n=u}),a});try{for await(let s of e){if(n!=null)throw n;o.forEach(a=>a.push(s)),yield s}}finally{o.forEach(s=>s.end())}}async*getAll(e){let r=new Set;yield*Je(Ge(...this.stores.map(n=>n.getAll(e))),n=>{let o=n.cid.toString();return r.has(o)?!1:(r.add(o),!0)})}};var rr={...R};return We(nr);})(); | ||
return BlockstoreCore})); |
@@ -10,3 +10,3 @@ import type { Blockstore, Pair } from 'interface-blockstore'; | ||
getMany(source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<Pair>; | ||
delete(key: CID, options?: AbortOptions): Promise<void>; | ||
delete(key: CID, options?: AbortOptions): Await<void>; | ||
deleteMany(source: AwaitIterable<CID>, options?: AbortOptions): AwaitIterable<CID>; | ||
@@ -13,0 +13,0 @@ /** |
@@ -25,4 +25,4 @@ export class BaseBlockstore { | ||
} | ||
async delete(key, options) { | ||
await Promise.reject(new Error('.delete is not implemented')); | ||
delete(key, options) { | ||
return Promise.reject(new Error('.delete is not implemented')); | ||
} | ||
@@ -29,0 +29,0 @@ async *deleteMany(source, options) { |
@@ -68,2 +68,17 @@ /** | ||
* ``` | ||
* | ||
* @example IdentityBlockstore | ||
* | ||
* An identity blockstore is one that deals exclusively in Identity CIDs - this is a special CID with the codec [0x00](https://github.com/multiformats/multicodec/blob/d06fc6194710e8909bac64273c43f16b56ca4c34/table.csv#L2) where the multihash digest is the data that makes up the block. | ||
* | ||
* ```TypeScript | ||
* import { IdentityBlockstore } from 'blockstore-core/identity' | ||
* import { CID } from 'multiformats/cid' | ||
* | ||
* const blockstore = new IdentityBlockstore() | ||
* | ||
* blockstore.has(CID.parse('QmFoo')) // false | ||
* | ||
* blockstore.has(CID.parse('bafkqac3imvwgy3zao5xxe3de')) // true | ||
* ``` | ||
*/ | ||
@@ -70,0 +85,0 @@ export { BaseBlockstore } from './base.js'; |
@@ -68,2 +68,17 @@ /** | ||
* ``` | ||
* | ||
* @example IdentityBlockstore | ||
* | ||
* An identity blockstore is one that deals exclusively in Identity CIDs - this is a special CID with the codec [0x00](https://github.com/multiformats/multicodec/blob/d06fc6194710e8909bac64273c43f16b56ca4c34/table.csv#L2) where the multihash digest is the data that makes up the block. | ||
* | ||
* ```TypeScript | ||
* import { IdentityBlockstore } from 'blockstore-core/identity' | ||
* import { CID } from 'multiformats/cid' | ||
* | ||
* const blockstore = new IdentityBlockstore() | ||
* | ||
* blockstore.has(CID.parse('QmFoo')) // false | ||
* | ||
* blockstore.has(CID.parse('bafkqac3imvwgy3zao5xxe3de')) // true | ||
* ``` | ||
*/ | ||
@@ -70,0 +85,0 @@ import * as ErrorsImport from './errors.js'; |
@@ -22,2 +22,4 @@ { | ||
"./errors:putFailedError": "https://ipfs.github.io/js-stores/functions/blockstore_core.errors.putFailedError.html", | ||
"IdentityBlockstore": "https://ipfs.github.io/js-stores/classes/blockstore_core.identity.IdentityBlockstore.html", | ||
"./identity:IdentityBlockstore": "https://ipfs.github.io/js-stores/classes/blockstore_core.identity.IdentityBlockstore.html", | ||
"Errors": "https://ipfs.github.io/js-stores/variables/blockstore_core.index.Errors.html", | ||
@@ -24,0 +26,0 @@ ".:Errors": "https://ipfs.github.io/js-stores/variables/blockstore_core.index.Errors.html", |
{ | ||
"name": "blockstore-core", | ||
"version": "4.3.11", | ||
"version": "4.4.0", | ||
"description": "Contains various implementations of the API contract described in interface-blockstore", | ||
@@ -66,2 +66,6 @@ "author": "Alex Potsides <alex.potsides@protocol.ai>", | ||
}, | ||
"./identity": { | ||
"types": "./dist/src/identity.d.ts", | ||
"import": "./dist/src/identity.js" | ||
}, | ||
"./memory": { | ||
@@ -68,0 +72,0 @@ "types": "./dist/src/memory.d.ts", |
@@ -77,2 +77,17 @@ # blockstore-core | ||
## Example - IdentityBlockstore | ||
An identity blockstore is one that deals exclusively in Identity CIDs - this is a special CID with the codec [0x00](https://github.com/multiformats/multicodec/blob/d06fc6194710e8909bac64273c43f16b56ca4c34/table.csv#L2) where the multihash digest is the data that makes up the block. | ||
```TypeScript | ||
import { IdentityBlockstore } from 'blockstore-core/identity' | ||
import { CID } from 'multiformats/cid' | ||
const blockstore = new IdentityBlockstore() | ||
blockstore.has(CID.parse('QmFoo')) // false | ||
blockstore.has(CID.parse('bafkqac3imvwgy3zao5xxe3de')) // true | ||
``` | ||
# Install | ||
@@ -79,0 +94,0 @@ |
@@ -34,4 +34,4 @@ import type { Blockstore, Pair } from 'interface-blockstore' | ||
async delete (key: CID, options?: AbortOptions): Promise<void> { | ||
await Promise.reject(new Error('.delete is not implemented')) | ||
delete (key: CID, options?: AbortOptions): Await<void> { | ||
return Promise.reject(new Error('.delete is not implemented')) | ||
} | ||
@@ -38,0 +38,0 @@ |
@@ -68,2 +68,17 @@ /** | ||
* ``` | ||
* | ||
* @example IdentityBlockstore | ||
* | ||
* An identity blockstore is one that deals exclusively in Identity CIDs - this is a special CID with the codec [0x00](https://github.com/multiformats/multicodec/blob/d06fc6194710e8909bac64273c43f16b56ca4c34/table.csv#L2) where the multihash digest is the data that makes up the block. | ||
* | ||
* ```TypeScript | ||
* import { IdentityBlockstore } from 'blockstore-core/identity' | ||
* import { CID } from 'multiformats/cid' | ||
* | ||
* const blockstore = new IdentityBlockstore() | ||
* | ||
* blockstore.has(CID.parse('QmFoo')) // false | ||
* | ||
* blockstore.has(CID.parse('bafkqac3imvwgy3zao5xxe3de')) // true | ||
* ``` | ||
*/ | ||
@@ -70,0 +85,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
80817
40
1045
128