@ethersphere/bee-js 9.8.0 → 10.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.
@@ -83,9 +83,12 @@ class Fork {
83
83
  const type = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
84
84
  const prefixLength = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
85
85
  const prefix = reader.read(prefixLength);
86
- reader.read(30 - prefixLength);
86
+ if (prefixLength < 30) {
87
+ reader.read(30 - prefixLength);
88
+ }
87
89
  const selfAddress = reader.read(addressLength);
88
90
  debug('unmarshalling fork', {
91
+ type,
89
92
  prefixLength,
90
93
  prefix: DECODER.decode(prefix),
91
94
  addressLength,
@@ -225,12 +228,12 @@ class MantarayNode {
225
228
  throw new Error('MantarayNode#unmarshal invalid version hash');
226
229
  }
227
230
  const targetAddressLength = cafe_utility_1.Binary.uint8ToNumber(reader.read(1));
228
- const targetAddress = targetAddressLength === 0 ? __1.NULL_ADDRESS : reader.read(targetAddressLength);
231
+ const targetAddress = targetAddressLength ? reader.read(targetAddressLength) : __1.NULL_ADDRESS;
229
232
  const node = new MantarayNode({ selfAddress, targetAddress, obfuscationKey });
230
233
  const forkBitmap = reader.read(32);
231
234
  for (let i = 0; i < 256; i++) {
232
235
  if (cafe_utility_1.Binary.getBit(forkBitmap, i, 'LE')) {
233
- const newFork = Fork.unmarshal(reader, targetAddressLength);
236
+ const newFork = Fork.unmarshal(reader, selfAddress.length);
234
237
  node.forks.set(i, newFork);
235
238
  newFork.node.parent = node;
236
239
  }
@@ -20,7 +20,7 @@ async function getChequebookAddress(requestOptions) {
20
20
  });
21
21
  const body = cafe_utility_1.Types.asObject(response.data, { name: 'response.data' });
22
22
  return {
23
- chequebookAddress: cafe_utility_1.Types.asString(body.chequebookAddress, { name: 'chequebookAddress' }),
23
+ chequebookAddress: new typed_bytes_1.EthAddress(cafe_utility_1.Types.asString(body.chequebookAddress, { name: 'chequebookAddress' })),
24
24
  };
25
25
  }
26
26
  exports.getChequebookAddress = getChequebookAddress;
@@ -14,23 +14,28 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.RedundancyStrategy = exports.RedundancyLevel = exports.FEED_INDEX_HEX_LENGTH = exports.TAGS_LIMIT_MAX = exports.TAGS_LIMIT_MIN = exports.STAMPS_DEPTH_MAX = exports.STAMPS_DEPTH_MIN = exports.PSS_TARGET_HEX_LENGTH_MAX = exports.CHUNK_SIZE = exports.BRANCHES = exports.SECTION_SIZE = void 0;
17
+ exports.capacityBreakpoints = exports.RedundancyStrategy = exports.RedundancyLevel = exports.TAGS_LIMIT_MAX = exports.TAGS_LIMIT_MIN = exports.STAMPS_DEPTH_MAX = exports.STAMPS_DEPTH_MIN = exports.PSS_TARGET_HEX_LENGTH_MAX = exports.CHUNK_SIZE = exports.BRANCHES = exports.SECTION_SIZE = void 0;
18
18
  __exportStar(require("./debug"), exports);
19
19
  exports.SECTION_SIZE = 32;
20
20
  exports.BRANCHES = 128;
21
21
  exports.CHUNK_SIZE = exports.SECTION_SIZE * exports.BRANCHES;
22
22
  exports.PSS_TARGET_HEX_LENGTH_MAX = 4;
23
23
  /**
24
- * Minimal depth that can be used for creation of postage batch
24
+ * Minimum postage batch depth.
25
25
  */
26
26
  exports.STAMPS_DEPTH_MIN = 17;
27
27
  /**
28
- * Maximal depth that can be used for creation of postage batch
28
+ * Maximum postage batch depth.
29
29
  */
30
30
  exports.STAMPS_DEPTH_MAX = 255;
31
+ /**
32
+ * Minimum tags API page size.
33
+ */
31
34
  exports.TAGS_LIMIT_MIN = 1;
35
+ /**
36
+ * Maximum tags API page size.
37
+ */
32
38
  exports.TAGS_LIMIT_MAX = 1000;
33
- exports.FEED_INDEX_HEX_LENGTH = 16;
34
39
  /**
35
40
  * Add redundancy to the data being uploaded so that downloaders can download it with better UX.
36
41
  * 0 value is default and does not add any redundancy to the file.
@@ -60,3 +65,279 @@ var RedundancyStrategy;
60
65
  RedundancyStrategy[RedundancyStrategy["PROX"] = 2] = "PROX";
61
66
  RedundancyStrategy[RedundancyStrategy["RACE"] = 3] = "RACE";
62
67
  })(RedundancyStrategy = exports.RedundancyStrategy || (exports.RedundancyStrategy = {}));
68
+ exports.capacityBreakpoints = {
69
+ ENCRYPTION_OFF: {
70
+ [RedundancyLevel.OFF]: [
71
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '44.70 kB', batchDepth: 17, utilizationRate: '0.01%' },
72
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '6.66 MB', batchDepth: 18, utilizationRate: '0.61%' },
73
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '112.06 MB', batchDepth: 19, utilizationRate: '5.09%' },
74
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '687.62 MB', batchDepth: 20, utilizationRate: '15.65%' },
75
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '2.60 GB', batchDepth: 21, utilizationRate: '30.27%' },
76
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '7.73 GB', batchDepth: 22, utilizationRate: '44.99%' },
77
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '19.94 GB', batchDepth: 23, utilizationRate: '58.03%' },
78
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '47.06 GB', batchDepth: 24, utilizationRate: '68.48%' },
79
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '105.51 GB', batchDepth: 25, utilizationRate: '76.77%' },
80
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '227.98 GB', batchDepth: 26, utilizationRate: '82.94%' },
81
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '476.68 GB', batchDepth: 27, utilizationRate: '86.71%' },
82
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '993.65 GB', batchDepth: 28, utilizationRate: '88.37%' },
83
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '2.04 TB', batchDepth: 29, utilizationRate: '92.88%' },
84
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '4.17 TB', batchDepth: 30, utilizationRate: '94.81%' },
85
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '8.45 TB', batchDepth: 31, utilizationRate: '96.06%' },
86
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '17.07 TB', batchDepth: 32, utilizationRate: '97.01%' },
87
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '34.36 TB', batchDepth: 33, utilizationRate: '97.65%' },
88
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '69.04 TB', batchDepth: 34, utilizationRate: '98.11%' },
89
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '138.54 TB', batchDepth: 35, utilizationRate: '98.44%' },
90
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '277.72 TB', batchDepth: 36, utilizationRate: '98.67%' },
91
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '556.35 TB', batchDepth: 37, utilizationRate: '98.83%' },
92
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '1.11 PB', batchDepth: 38, utilizationRate: '98.91%' },
93
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '2.23 PB', batchDepth: 39, utilizationRate: '98.96%' },
94
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '4.46 PB', batchDepth: 40, utilizationRate: '98.98%' },
95
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '8.93 PB', batchDepth: 41, utilizationRate: '99.11%' },
96
+ ],
97
+ [RedundancyLevel.MEDIUM]: [
98
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '41.56 kB', batchDepth: 17, utilizationRate: '0.01%' },
99
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '6.19 MB', batchDepth: 18, utilizationRate: '0.57%' },
100
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '104.18 MB', batchDepth: 19, utilizationRate: '4.73%' },
101
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '639.27 MB', batchDepth: 20, utilizationRate: '14.54%' },
102
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '2.41 GB', batchDepth: 21, utilizationRate: '28.11%' },
103
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '7.18 GB', batchDepth: 22, utilizationRate: '41.79%' },
104
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '18.54 GB', batchDepth: 23, utilizationRate: '53.95%' },
105
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '43.75 GB', batchDepth: 24, utilizationRate: '63.66%' },
106
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '98.09 GB', batchDepth: 25, utilizationRate: '71.37%' },
107
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '211.95 GB', batchDepth: 26, utilizationRate: '77.11%' },
108
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '443.16 GB', batchDepth: 27, utilizationRate: '80.61%' },
109
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '923.78 GB', batchDepth: 28, utilizationRate: '82.16%' },
110
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '1.90 TB', batchDepth: 29, utilizationRate: '86.30%' },
111
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '3.88 TB', batchDepth: 30, utilizationRate: '88.14%' },
112
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '7.86 TB', batchDepth: 31, utilizationRate: '89.26%' },
113
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '15.87 TB', batchDepth: 32, utilizationRate: '90.21%' },
114
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '31.94 TB', batchDepth: 33, utilizationRate: '90.77%' },
115
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '64.19 TB', batchDepth: 34, utilizationRate: '91.22%' },
116
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '128.80 TB', batchDepth: 35, utilizationRate: '91.52%' },
117
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '258.19 TB', batchDepth: 36, utilizationRate: '91.73%' },
118
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '517.23 TB', batchDepth: 37, utilizationRate: '91.88%' },
119
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '1.04 PB', batchDepth: 38, utilizationRate: '91.95%' },
120
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '2.07 PB', batchDepth: 39, utilizationRate: '92.00%' },
121
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '4.15 PB', batchDepth: 40, utilizationRate: '92.15%' },
122
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '8.30 PB', batchDepth: 41, utilizationRate: '92.14%' },
123
+ ],
124
+ [RedundancyLevel.STRONG]: [
125
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '37.37 kB', batchDepth: 17, utilizationRate: '0.01%' },
126
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '5.57 MB', batchDepth: 18, utilizationRate: '0.51%' },
127
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '93.68 MB', batchDepth: 19, utilizationRate: '4.25%' },
128
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '574.81 MB', batchDepth: 20, utilizationRate: '13.07%' },
129
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '2.17 GB', batchDepth: 21, utilizationRate: '25.26%' },
130
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '6.46 GB', batchDepth: 22, utilizationRate: '37.58%' },
131
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '16.67 GB', batchDepth: 23, utilizationRate: '48.50%' },
132
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '39.34 GB', batchDepth: 24, utilizationRate: '57.24%' },
133
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '88.20 GB', batchDepth: 25, utilizationRate: '64.17%' },
134
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '190.58 GB', batchDepth: 26, utilizationRate: '69.33%' },
135
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '398.47 GB', batchDepth: 27, utilizationRate: '72.48%' },
136
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '830.63 GB', batchDepth: 28, utilizationRate: '73.85%' },
137
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '1.71 TB', batchDepth: 29, utilizationRate: '77.59%' },
138
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '3.49 TB', batchDepth: 30, utilizationRate: '79.27%' },
139
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '7.07 TB', batchDepth: 31, utilizationRate: '80.34%' },
140
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '14.27 TB', batchDepth: 32, utilizationRate: '81.12%' },
141
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '28.72 TB', batchDepth: 33, utilizationRate: '81.63%' },
142
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '57.71 TB', batchDepth: 34, utilizationRate: '82.01%' },
143
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '115.81 TB', batchDepth: 35, utilizationRate: '82.29%' },
144
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '232.16 TB', batchDepth: 36, utilizationRate: '82.48%' },
145
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '465.07 TB', batchDepth: 37, utilizationRate: '82.61%' },
146
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '931.23 TB', batchDepth: 38, utilizationRate: '82.67%' },
147
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '1.86 PB', batchDepth: 39, utilizationRate: '82.71%' },
148
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '3.73 PB', batchDepth: 40, utilizationRate: '82.78%' },
149
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '7.46 PB', batchDepth: 41, utilizationRate: '82.79%' },
150
+ ],
151
+ [RedundancyLevel.INSANE]: [
152
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '33.88 kB', batchDepth: 17, utilizationRate: '0.01%' },
153
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '5.05 MB', batchDepth: 18, utilizationRate: '0.46%' },
154
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '84.92 MB', batchDepth: 19, utilizationRate: '3.86%' },
155
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '521.09 MB', batchDepth: 20, utilizationRate: '11.85%' },
156
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '1.97 GB', batchDepth: 21, utilizationRate: '22.90%' },
157
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '5.86 GB', batchDepth: 22, utilizationRate: '34.09%' },
158
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '15.11 GB', batchDepth: 23, utilizationRate: '43.97%' },
159
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '35.66 GB', batchDepth: 24, utilizationRate: '51.90%' },
160
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '79.96 GB', batchDepth: 25, utilizationRate: '58.18%' },
161
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '172.77 GB', batchDepth: 26, utilizationRate: '62.85%' },
162
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '361.23 GB', batchDepth: 27, utilizationRate: '65.70%' },
163
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '753.00 GB', batchDepth: 28, utilizationRate: '66.95%' },
164
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '1.55 TB', batchDepth: 29, utilizationRate: '70.38%' },
165
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '3.16 TB', batchDepth: 30, utilizationRate: '71.92%' },
166
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '6.41 TB', batchDepth: 31, utilizationRate: '72.85%' },
167
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '12.93 TB', batchDepth: 32, utilizationRate: '73.53%' },
168
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '26.04 TB', batchDepth: 33, utilizationRate: '74.01%' },
169
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '52.32 TB', batchDepth: 34, utilizationRate: '74.35%' },
170
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '104.99 TB', batchDepth: 35, utilizationRate: '74.60%' },
171
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '210.46 TB', batchDepth: 36, utilizationRate: '74.77%' },
172
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '421.61 TB', batchDepth: 37, utilizationRate: '74.89%' },
173
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '844.20 TB', batchDepth: 38, utilizationRate: '74.94%' },
174
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '1.69 PB', batchDepth: 39, utilizationRate: '74.98%' },
175
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '3.38 PB', batchDepth: 40, utilizationRate: '75.03%' },
176
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '6.77 PB', batchDepth: 41, utilizationRate: '75.10%' },
177
+ ],
178
+ [RedundancyLevel.PARANOID]: [
179
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '13.27 kB', batchDepth: 17, utilizationRate: '0.00%' },
180
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '1.98 MB', batchDepth: 18, utilizationRate: '0.18%' },
181
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '33.27 MB', batchDepth: 19, utilizationRate: '1.51%' },
182
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '204.14 MB', batchDepth: 20, utilizationRate: '4.64%' },
183
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '771.13 MB', batchDepth: 21, utilizationRate: '8.75%' },
184
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '2.29 GB', batchDepth: 22, utilizationRate: '13.34%' },
185
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '5.92 GB', batchDepth: 23, utilizationRate: '17.22%' },
186
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '13.97 GB', batchDepth: 24, utilizationRate: '20.33%' },
187
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '31.32 GB', batchDepth: 25, utilizationRate: '22.79%' },
188
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '67.68 GB', batchDepth: 26, utilizationRate: '24.62%' },
189
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '141.51 GB', batchDepth: 27, utilizationRate: '25.74%' },
190
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '294.99 GB', batchDepth: 28, utilizationRate: '26.23%' },
191
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '606.90 GB', batchDepth: 29, utilizationRate: '27.56%' },
192
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '1.24 TB', batchDepth: 30, utilizationRate: '28.15%' },
193
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '2.51 TB', batchDepth: 31, utilizationRate: '28.54%' },
194
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '5.07 TB', batchDepth: 32, utilizationRate: '28.82%' },
195
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '10.20 TB', batchDepth: 33, utilizationRate: '28.99%' },
196
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '20.50 TB', batchDepth: 34, utilizationRate: '29.13%' },
197
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '41.13 TB', batchDepth: 35, utilizationRate: '29.22%' },
198
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '82.45 TB', batchDepth: 36, utilizationRate: '29.29%' },
199
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '165.17 TB', batchDepth: 37, utilizationRate: '29.34%' },
200
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '330.72 TB', batchDepth: 38, utilizationRate: '29.37%' },
201
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '661.97 TB', batchDepth: 39, utilizationRate: '29.39%' },
202
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '1.32 PB', batchDepth: 40, utilizationRate: '29.41%' },
203
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '2.65 PB', batchDepth: 41, utilizationRate: '29.43%' },
204
+ ],
205
+ },
206
+ ENCRYPTION_ON: {
207
+ [RedundancyLevel.OFF]: [
208
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '44.35 kB', batchDepth: 17, utilizationRate: '0.01%' },
209
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '6.61 MB', batchDepth: 18, utilizationRate: '0.60%' },
210
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '111.18 MB', batchDepth: 19, utilizationRate: '5.05%' },
211
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '682.21 MB', batchDepth: 20, utilizationRate: '15.52%' },
212
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '2.58 GB', batchDepth: 21, utilizationRate: '30.04%' },
213
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '7.67 GB', batchDepth: 22, utilizationRate: '44.62%' },
214
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '19.78 GB', batchDepth: 23, utilizationRate: '57.56%' },
215
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '46.69 GB', batchDepth: 24, utilizationRate: '67.93%' },
216
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '104.68 GB', batchDepth: 25, utilizationRate: '76.16%' },
217
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '226.19 GB', batchDepth: 26, utilizationRate: '82.29%' },
218
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '472.93 GB', batchDepth: 27, utilizationRate: '86.02%' },
219
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '985.83 GB', batchDepth: 28, utilizationRate: '87.66%' },
220
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '2.03 TB', batchDepth: 29, utilizationRate: '92.25%' },
221
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '4.14 TB', batchDepth: 30, utilizationRate: '94.21%' },
222
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '8.39 TB', batchDepth: 31, utilizationRate: '95.37%' },
223
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '16.93 TB', batchDepth: 32, utilizationRate: '96.22%' },
224
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '34.09 TB', batchDepth: 33, utilizationRate: '96.88%' },
225
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '68.50 TB', batchDepth: 34, utilizationRate: '97.34%' },
226
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '137.45 TB', batchDepth: 35, utilizationRate: '97.67%' },
227
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '275.53 TB', batchDepth: 36, utilizationRate: '97.89%' },
228
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '551.97 TB', batchDepth: 37, utilizationRate: '98.05%' },
229
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '1.11 PB', batchDepth: 38, utilizationRate: '98.13%' },
230
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '2.21 PB', batchDepth: 39, utilizationRate: '98.18%' },
231
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '4.43 PB', batchDepth: 40, utilizationRate: '98.36%' },
232
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '8.86 PB', batchDepth: 41, utilizationRate: '98.37%' },
233
+ ],
234
+ [RedundancyLevel.MEDIUM]: [
235
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '40.89 kB', batchDepth: 17, utilizationRate: '0.01%' },
236
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '6.09 MB', batchDepth: 18, utilizationRate: '0.56%' },
237
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '102.49 MB', batchDepth: 19, utilizationRate: '4.65%' },
238
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '628.91 MB', batchDepth: 20, utilizationRate: '14.30%' },
239
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '2.38 GB', batchDepth: 21, utilizationRate: '27.68%' },
240
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '7.07 GB', batchDepth: 22, utilizationRate: '41.15%' },
241
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '18.24 GB', batchDepth: 23, utilizationRate: '53.09%' },
242
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '43.04 GB', batchDepth: 24, utilizationRate: '62.63%' },
243
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '96.50 GB', batchDepth: 25, utilizationRate: '70.21%' },
244
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '208.52 GB', batchDepth: 26, utilizationRate: '75.86%' },
245
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '435.98 GB', batchDepth: 27, utilizationRate: '79.30%' },
246
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '908.81 GB', batchDepth: 28, utilizationRate: '80.82%' },
247
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '1.87 TB', batchDepth: 29, utilizationRate: '84.98%' },
248
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '3.81 TB', batchDepth: 30, utilizationRate: '86.67%' },
249
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '7.73 TB', batchDepth: 31, utilizationRate: '87.84%' },
250
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '15.61 TB', batchDepth: 32, utilizationRate: '88.74%' },
251
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '31.43 TB', batchDepth: 33, utilizationRate: '89.34%' },
252
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '63.15 TB', batchDepth: 34, utilizationRate: '89.74%' },
253
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '126.71 TB', batchDepth: 35, utilizationRate: '90.03%' },
254
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '254.01 TB', batchDepth: 36, utilizationRate: '90.24%' },
255
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '508.85 TB', batchDepth: 37, utilizationRate: '90.39%' },
256
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '1.02 PB', batchDepth: 38, utilizationRate: '90.47%' },
257
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '2.04 PB', batchDepth: 39, utilizationRate: '90.51%' },
258
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '4.08 PB', batchDepth: 40, utilizationRate: '90.64%' },
259
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '8.17 PB', batchDepth: 41, utilizationRate: '90.65%' },
260
+ ],
261
+ [RedundancyLevel.STRONG]: [
262
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '36.73 kB', batchDepth: 17, utilizationRate: '0.01%' },
263
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '5.47 MB', batchDepth: 18, utilizationRate: '0.50%' },
264
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '92.07 MB', batchDepth: 19, utilizationRate: '4.18%' },
265
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '564.95 MB', batchDepth: 20, utilizationRate: '12.85%' },
266
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '2.13 GB', batchDepth: 21, utilizationRate: '24.86%' },
267
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '6.35 GB', batchDepth: 22, utilizationRate: '36.97%' },
268
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '16.38 GB', batchDepth: 23, utilizationRate: '47.67%' },
269
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '38.66 GB', batchDepth: 24, utilizationRate: '56.26%' },
270
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '86.69 GB', batchDepth: 25, utilizationRate: '63.07%' },
271
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '187.31 GB', batchDepth: 26, utilizationRate: '68.14%' },
272
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '391.64 GB', batchDepth: 27, utilizationRate: '71.24%' },
273
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '816.39 GB', batchDepth: 28, utilizationRate: '72.59%' },
274
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '1.68 TB', batchDepth: 29, utilizationRate: '76.34%' },
275
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '3.43 TB', batchDepth: 30, utilizationRate: '77.89%' },
276
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '6.94 TB', batchDepth: 31, utilizationRate: '78.86%' },
277
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '14.02 TB', batchDepth: 32, utilizationRate: '79.71%' },
278
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '28.23 TB', batchDepth: 33, utilizationRate: '80.23%' },
279
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '56.72 TB', batchDepth: 34, utilizationRate: '80.60%' },
280
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '113.82 TB', batchDepth: 35, utilizationRate: '80.88%' },
281
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '228.18 TB', batchDepth: 36, utilizationRate: '81.06%' },
282
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '457.10 TB', batchDepth: 37, utilizationRate: '81.20%' },
283
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '915.26 TB', batchDepth: 38, utilizationRate: '81.26%' },
284
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '1.83 PB', batchDepth: 39, utilizationRate: '81.30%' },
285
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '3.67 PB', batchDepth: 40, utilizationRate: '81.43%' },
286
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '7.34 PB', batchDepth: 41, utilizationRate: '81.45%' },
287
+ ],
288
+ [RedundancyLevel.INSANE]: [
289
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '33.26 kB', batchDepth: 17, utilizationRate: '0.01%' },
290
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '4.96 MB', batchDepth: 18, utilizationRate: '0.45%' },
291
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '83.38 MB', batchDepth: 19, utilizationRate: '3.79%' },
292
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '511.65 MB', batchDepth: 20, utilizationRate: '11.64%' },
293
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '1.93 GB', batchDepth: 21, utilizationRate: '22.52%' },
294
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '5.75 GB', batchDepth: 22, utilizationRate: '33.50%' },
295
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '14.84 GB', batchDepth: 23, utilizationRate: '43.19%' },
296
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '35.02 GB', batchDepth: 24, utilizationRate: '50.96%' },
297
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '78.51 GB', batchDepth: 25, utilizationRate: '57.12%' },
298
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '169.64 GB', batchDepth: 26, utilizationRate: '61.71%' },
299
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '354.69 GB', batchDepth: 27, utilizationRate: '64.52%' },
300
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '739.37 GB', batchDepth: 28, utilizationRate: '65.74%' },
301
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '1.52 TB', batchDepth: 29, utilizationRate: '69.15%' },
302
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '3.10 TB', batchDepth: 30, utilizationRate: '70.56%' },
303
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '6.29 TB', batchDepth: 31, utilizationRate: '71.48%' },
304
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '12.70 TB', batchDepth: 32, utilizationRate: '72.18%' },
305
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '25.57 TB', batchDepth: 33, utilizationRate: '72.67%' },
306
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '51.37 TB', batchDepth: 34, utilizationRate: '73.00%' },
307
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '103.08 TB', batchDepth: 35, utilizationRate: '73.24%' },
308
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '206.65 TB', batchDepth: 36, utilizationRate: '73.42%' },
309
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '413.98 TB', batchDepth: 37, utilizationRate: '73.54%' },
310
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '828.91 TB', batchDepth: 38, utilizationRate: '73.59%' },
311
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '1.66 PB', batchDepth: 39, utilizationRate: '73.62%' },
312
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '3.32 PB', batchDepth: 40, utilizationRate: '73.72%' },
313
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '6.64 PB', batchDepth: 41, utilizationRate: '73.74%' },
314
+ ],
315
+ [RedundancyLevel.PARANOID]: [
316
+ { theoreticalVolume: '536.87 MB', effectiveVolume: '13.17 kB', batchDepth: 17, utilizationRate: '0.00%' },
317
+ { theoreticalVolume: '1.07 GB', effectiveVolume: '1.96 MB', batchDepth: 18, utilizationRate: '0.18%' },
318
+ { theoreticalVolume: '2.15 GB', effectiveVolume: '33.01 MB', batchDepth: 19, utilizationRate: '1.50%' },
319
+ { theoreticalVolume: '4.29 GB', effectiveVolume: '202.53 MB', batchDepth: 20, utilizationRate: '4.61%' },
320
+ { theoreticalVolume: '8.59 GB', effectiveVolume: '765.05 MB', batchDepth: 21, utilizationRate: '8.68%' },
321
+ { theoreticalVolume: '17.18 GB', effectiveVolume: '2.28 GB', batchDepth: 22, utilizationRate: '13.27%' },
322
+ { theoreticalVolume: '34.36 GB', effectiveVolume: '5.87 GB', batchDepth: 23, utilizationRate: '17.08%' },
323
+ { theoreticalVolume: '68.72 GB', effectiveVolume: '13.86 GB', batchDepth: 24, utilizationRate: '20.17%' },
324
+ { theoreticalVolume: '137.44 GB', effectiveVolume: '31.08 GB', batchDepth: 25, utilizationRate: '22.61%' },
325
+ { theoreticalVolume: '274.88 GB', effectiveVolume: '67.15 GB', batchDepth: 26, utilizationRate: '24.43%' },
326
+ { theoreticalVolume: '549.76 GB', effectiveVolume: '140.40 GB', batchDepth: 27, utilizationRate: '25.54%' },
327
+ { theoreticalVolume: '1.10 TB', effectiveVolume: '292.67 GB', batchDepth: 28, utilizationRate: '26.03%' },
328
+ { theoreticalVolume: '2.20 TB', effectiveVolume: '602.12 GB', batchDepth: 29, utilizationRate: '27.35%' },
329
+ { theoreticalVolume: '4.40 TB', effectiveVolume: '1.23 TB', batchDepth: 30, utilizationRate: '27.94%' },
330
+ { theoreticalVolume: '8.80 TB', effectiveVolume: '2.49 TB', batchDepth: 31, utilizationRate: '28.32%' },
331
+ { theoreticalVolume: '17.59 TB', effectiveVolume: '5.03 TB', batchDepth: 32, utilizationRate: '28.60%' },
332
+ { theoreticalVolume: '35.18 TB', effectiveVolume: '10.12 TB', batchDepth: 33, utilizationRate: '28.77%' },
333
+ { theoreticalVolume: '70.37 TB', effectiveVolume: '20.34 TB', batchDepth: 34, utilizationRate: '28.91%' },
334
+ { theoreticalVolume: '140.74 TB', effectiveVolume: '40.80 TB', batchDepth: 35, utilizationRate: '29.00%' },
335
+ { theoreticalVolume: '281.47 TB', effectiveVolume: '81.80 TB', batchDepth: 36, utilizationRate: '29.06%' },
336
+ { theoreticalVolume: '562.95 TB', effectiveVolume: '163.87 TB', batchDepth: 37, utilizationRate: '29.11%' },
337
+ { theoreticalVolume: '1.13 PB', effectiveVolume: '328.11 TB', batchDepth: 38, utilizationRate: '29.14%' },
338
+ { theoreticalVolume: '2.25 PB', effectiveVolume: '656.76 TB', batchDepth: 39, utilizationRate: '29.16%' },
339
+ { theoreticalVolume: '4.50 PB', effectiveVolume: '1.31 PB', batchDepth: 40, utilizationRate: '29.18%' },
340
+ { theoreticalVolume: '9.01 PB', effectiveVolume: '2.63 PB', batchDepth: 41, utilizationRate: '29.19%' },
341
+ ],
342
+ },
343
+ };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Bytes = void 0;
3
+ exports.parseSizeToBytes = exports.Bytes = void 0;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
5
  const DECODER = new TextDecoder();
6
6
  const ENCODER = new TextEncoder();
@@ -74,3 +74,21 @@ class Bytes {
74
74
  }
75
75
  }
76
76
  exports.Bytes = Bytes;
77
+ function parseSizeToBytes(sizeStr) {
78
+ const units = {
79
+ B: 1,
80
+ kB: 1000,
81
+ MB: 1000 ** 2,
82
+ GB: 1000 ** 3,
83
+ TB: 1000 ** 4,
84
+ PB: 1000 ** 5,
85
+ };
86
+ const match = sizeStr.match(/^([\d.]+)\s*(B|kB|MB|GB|TB|PB)$/);
87
+ if (!match) {
88
+ throw new Error(`Invalid size format: ${sizeStr}`);
89
+ }
90
+ const value = parseFloat(match[1]);
91
+ const unit = match[2];
92
+ return Math.ceil(value * units[unit]);
93
+ }
94
+ exports.parseSizeToBytes = parseSizeToBytes;
@@ -5,8 +5,8 @@ const cafe_utility_1 = require("cafe-utility");
5
5
  class Duration {
6
6
  constructor(seconds) {
7
7
  this.seconds = Math.ceil(seconds);
8
- if (seconds <= 0) {
9
- throw Error('Duration must be greater than 0');
8
+ if (seconds < 0) {
9
+ this.seconds = 0;
10
10
  }
11
11
  }
12
12
  static fromMilliseconds(milliseconds) {
@@ -51,5 +51,9 @@ class Duration {
51
51
  represent() {
52
52
  return cafe_utility_1.Dates.secondsToHumanTime(this.seconds);
53
53
  }
54
+ isZero() {
55
+ return this.seconds === 0;
56
+ }
54
57
  }
55
58
  exports.Duration = Duration;
59
+ Duration.ZERO = new Duration(0);
@@ -2,6 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.marshalStamp = exports.convertEnvelopeToMarshaledStamp = exports.getDepthForSize = exports.getAmountForDuration = exports.getStampDuration = exports.getStampCost = exports.getStampEffectiveBytesBreakpoints = exports.getStampEffectiveBytes = exports.getStampTheoreticalBytes = exports.getStampUsage = void 0;
4
4
  const cafe_utility_1 = require("cafe-utility");
5
+ const types_1 = require("../types");
5
6
  const bytes_1 = require("./bytes");
6
7
  const duration_1 = require("./duration");
7
8
  const tokens_1 = require("./tokens");
@@ -61,25 +62,35 @@ const effectiveSizeBreakpoints = [
61
62
  *
62
63
  * @returns {number} The effective size of the postage batch in bytes.
63
64
  */
64
- function getStampEffectiveBytes(depth) {
65
+ function getStampEffectiveBytes(depth, encryption, erasureCodeLevel) {
65
66
  if (depth < 17) {
66
67
  return 0;
67
68
  }
68
- const breakpoint = effectiveSizeBreakpoints.find(([d, size]) => {
69
- if (depth === d) {
70
- return size;
69
+ if (encryption !== undefined && erasureCodeLevel !== undefined) {
70
+ const encryptionKey = encryption ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF';
71
+ const breakpoints = types_1.capacityBreakpoints[encryptionKey][erasureCodeLevel];
72
+ const entry = breakpoints.find(item => item.batchDepth === depth);
73
+ if (entry?.effectiveVolume) {
74
+ return (0, bytes_1.parseSizeToBytes)(entry.effectiveVolume);
75
+ }
76
+ }
77
+ else {
78
+ const breakpoint = effectiveSizeBreakpoints.find(([d, size]) => {
79
+ if (depth === d) {
80
+ return size;
81
+ }
82
+ });
83
+ if (breakpoint) {
84
+ return breakpoint[1] * 1000 * 1000 * 1000;
71
85
  }
72
- });
73
- if (breakpoint) {
74
- return breakpoint[1] * 1000 * 1000 * 1000;
75
86
  }
76
87
  return Math.ceil(getStampTheoreticalBytes(depth) * MAX_UTILIZATION);
77
88
  }
78
89
  exports.getStampEffectiveBytes = getStampEffectiveBytes;
79
- function getStampEffectiveBytesBreakpoints() {
90
+ function getStampEffectiveBytesBreakpoints(encryption, erasureCodeLevel) {
80
91
  const map = new Map();
81
92
  for (let i = 17; i < 35; i++) {
82
- map.set(i, getStampEffectiveBytes(i));
93
+ map.set(i, getStampEffectiveBytes(i, encryption, erasureCodeLevel));
83
94
  }
84
95
  return map;
85
96
  }
@@ -120,10 +131,22 @@ exports.getAmountForDuration = getAmountForDuration;
120
131
  * @param size The effective size of the postage batch
121
132
  * @returns
122
133
  */
123
- function getDepthForSize(size) {
124
- for (const [depth, sizeBreakpoint] of effectiveSizeBreakpoints) {
125
- if (size.toBytes() <= sizeBreakpoint * 1000 * 1000 * 1000) {
126
- return depth;
134
+ function getDepthForSize(size, encryption, erasureCodeLevel) {
135
+ if (encryption !== undefined && erasureCodeLevel !== undefined) {
136
+ const encryptionKey = encryption ? 'ENCRYPTION_ON' : 'ENCRYPTION_OFF';
137
+ const breakpoints = types_1.capacityBreakpoints[encryptionKey][erasureCodeLevel];
138
+ const entry = breakpoints.find(item => {
139
+ return size.toBytes() <= (0, bytes_1.parseSizeToBytes)(item.effectiveVolume);
140
+ });
141
+ if (entry?.effectiveVolume) {
142
+ return entry.batchDepth;
143
+ }
144
+ }
145
+ else {
146
+ for (const [depth, sizeBreakpoint] of effectiveSizeBreakpoints) {
147
+ if (size.toBytes() <= sizeBreakpoint * 1000 * 1000 * 1000) {
148
+ return depth;
149
+ }
127
150
  }
128
151
  }
129
152
  return 35;
@@ -124,6 +124,7 @@ function preparePssMessageHandler(value) {
124
124
  return {
125
125
  onMessage: cafe_utility_1.Types.asFunction(object.onMessage, { name: 'onMessage' }),
126
126
  onError: cafe_utility_1.Types.asFunction(object.onError, { name: 'onError' }),
127
+ onClose: cafe_utility_1.Types.asFunction(object.onClose, { name: 'onClose' }),
127
128
  };
128
129
  }
129
130
  exports.preparePssMessageHandler = preparePssMessageHandler;
@@ -132,6 +133,7 @@ function prepareGsocMessageHandler(value) {
132
133
  return {
133
134
  onMessage: cafe_utility_1.Types.asFunction(object.onMessage, { name: 'onMessage' }),
134
135
  onError: cafe_utility_1.Types.asFunction(object.onError, { name: 'onError' }),
136
+ onClose: cafe_utility_1.Types.asFunction(object.onClose, { name: 'onClose' }),
135
137
  };
136
138
  }
137
139
  exports.prepareGsocMessageHandler = prepareGsocMessageHandler;