@peerbit/blocks 2.3.4 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -11,7 +11,7 @@ export declare class DirectBlock extends DirectStream implements IBlocks {
11
11
  canRelayMessage?: boolean;
12
12
  localTimeout?: number;
13
13
  messageProcessingConcurrency?: number;
14
- earlyBlocks?: boolean | {
14
+ eagerBlocks?: boolean | {
15
15
  cacheSize?: number;
16
16
  };
17
17
  });
@@ -26,7 +26,7 @@ export class DirectBlock extends DirectStream {
26
26
  messageProcessingConcurrency: options?.messageProcessingConcurrency || 10,
27
27
  waitFor: this.waitFor.bind(this),
28
28
  publicKey: this.publicKey,
29
- earlyBlocks: options?.earlyBlocks,
29
+ eagerBlocks: options?.eagerBlocks,
30
30
  });
31
31
  this.onDataFn = (data) => {
32
32
  data.detail?.data?.length &&
@@ -23,7 +23,7 @@ export declare class RemoteBlocks implements IBlocks {
23
23
  localTimeout?: number;
24
24
  messageProcessingConcurrency?: number;
25
25
  publicKey: PublicSignKey;
26
- earlyBlocks?: boolean | {
26
+ eagerBlocks?: boolean | {
27
27
  cacheSize?: number;
28
28
  };
29
29
  publish: (data: BlockRequest | BlockResponse, options: PublishOptions) => Promise<Uint8Array | undefined | void>;
@@ -47,7 +47,7 @@ export declare class RemoteBlocks implements IBlocks {
47
47
  localTimeout?: number;
48
48
  messageProcessingConcurrency?: number;
49
49
  publicKey: PublicSignKey;
50
- earlyBlocks?: boolean | {
50
+ eagerBlocks?: boolean | {
51
51
  cacheSize?: number;
52
52
  };
53
53
  publish: (data: BlockRequest | BlockResponse, options: PublishOptions) => Promise<Uint8Array | undefined | void>;
@@ -80,11 +80,11 @@ export class RemoteBlocks {
80
80
  this.localStore = options?.local;
81
81
  this._resolvers = new Map();
82
82
  this._readFromPeersPromises = new Map();
83
- this._blockCache = options?.earlyBlocks
83
+ this._blockCache = options?.eagerBlocks
84
84
  ? new Cache({
85
- max: typeof options.earlyBlocks === "boolean"
85
+ max: typeof options.eagerBlocks === "boolean"
86
86
  ? 1e3
87
- : (options.earlyBlocks.cacheSize ?? 1e3),
87
+ : (options.eagerBlocks.cacheSize ?? 1e3),
88
88
  ttl: 1e4,
89
89
  })
90
90
  : undefined;
@@ -97,7 +97,7 @@ export class RemoteBlocks {
97
97
  // TODO make sure we are not storing too much bytes in ram (like filter large blocks)
98
98
  let resolver = this._resolvers.get(message.cid);
99
99
  if (!resolver) {
100
- if (options.earlyBlocks) {
100
+ if (options.eagerBlocks) {
101
101
  // wait for the resolve to exist
102
102
  this._blockCache.add(message.cid, message.bytes);
103
103
  }
@@ -184,7 +184,7 @@ export class RemoteBlocks {
184
184
  });
185
185
  return value;
186
186
  };
187
- const cachedValue = this.options.earlyBlocks
187
+ const cachedValue = this.options.eagerBlocks
188
188
  ? this._blockCache?.get(cidString)
189
189
  : undefined;
190
190
  if (cachedValue) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peerbit/blocks",
3
- "version": "2.3.4",
3
+ "version": "3.0.0",
4
4
  "description": "Block store streaming",
5
5
  "type": "module",
6
6
  "types": "./dist/src/index.d.ts",
@@ -79,7 +79,7 @@
79
79
  "dependencies": {
80
80
  "@dao-xyz/borsh": "^5.2.3",
81
81
  "@peerbit/any-store": "^2.1.9",
82
- "@peerbit/stream": "4.3.3",
82
+ "@peerbit/stream": "4.3.4",
83
83
  "@peerbit/blocks-interface": "1.4.4",
84
84
  "@peerbit/crypto": "2.3.8",
85
85
  "@ipld/dag-cbor": "^9.2.1",
package/src/libp2p.ts CHANGED
@@ -22,7 +22,7 @@ export class DirectBlock extends DirectStream implements IBlocks {
22
22
  canRelayMessage?: boolean;
23
23
  localTimeout?: number;
24
24
  messageProcessingConcurrency?: number;
25
- earlyBlocks?: boolean | { cacheSize?: number };
25
+ eagerBlocks?: boolean | { cacheSize?: number };
26
26
  },
27
27
  ) {
28
28
  super(components, ["/lazyblock/0.0.0"], {
@@ -40,7 +40,7 @@ export class DirectBlock extends DirectStream implements IBlocks {
40
40
  messageProcessingConcurrency: options?.messageProcessingConcurrency || 10,
41
41
  waitFor: this.waitFor.bind(this),
42
42
  publicKey: this.publicKey,
43
- earlyBlocks: options?.earlyBlocks,
43
+ eagerBlocks: options?.eagerBlocks,
44
44
  });
45
45
 
46
46
  this.onDataFn = (data: CustomEvent<DataMessage>) => {
package/src/remote.ts CHANGED
@@ -75,7 +75,7 @@ export class RemoteBlocks implements IBlocks {
75
75
  localTimeout?: number;
76
76
  messageProcessingConcurrency?: number;
77
77
  publicKey: PublicSignKey;
78
- earlyBlocks?: boolean | { cacheSize?: number };
78
+ eagerBlocks?: boolean | { cacheSize?: number };
79
79
  publish: (
80
80
  data: BlockRequest | BlockResponse,
81
81
  options: PublishOptions,
@@ -97,12 +97,12 @@ export class RemoteBlocks implements IBlocks {
97
97
  this.localStore = options?.local;
98
98
  this._resolvers = new Map();
99
99
  this._readFromPeersPromises = new Map();
100
- this._blockCache = options?.earlyBlocks
100
+ this._blockCache = options?.eagerBlocks
101
101
  ? new Cache<Uint8Array>({
102
102
  max:
103
- typeof options.earlyBlocks === "boolean"
103
+ typeof options.eagerBlocks === "boolean"
104
104
  ? 1e3
105
- : (options.earlyBlocks.cacheSize ?? 1e3),
105
+ : (options.eagerBlocks.cacheSize ?? 1e3),
106
106
  ttl: 1e4,
107
107
  })
108
108
  : undefined;
@@ -117,7 +117,7 @@ export class RemoteBlocks implements IBlocks {
117
117
  // TODO make sure we are not storing too much bytes in ram (like filter large blocks)
118
118
  let resolver = this._resolvers.get(message.cid);
119
119
  if (!resolver) {
120
- if (options.earlyBlocks) {
120
+ if (options.eagerBlocks) {
121
121
  // wait for the resolve to exist
122
122
  this._blockCache!.add(message.cid, message.bytes);
123
123
  }
@@ -234,7 +234,7 @@ export class RemoteBlocks implements IBlocks {
234
234
 
235
235
  return value;
236
236
  };
237
- const cachedValue = this.options.earlyBlocks
237
+ const cachedValue = this.options.eagerBlocks
238
238
  ? this._blockCache?.get(cidString)
239
239
  : undefined;
240
240
  if (cachedValue) {