@upcoming/bee-js 0.14.0 → 0.15.1

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.
package/dist/cjs/bee.js CHANGED
@@ -713,7 +713,7 @@ class Bee {
713
713
  }
714
714
  });
715
715
  }
716
- gsocMine(targetOverlay, identifier, proximity = 16) {
716
+ gsocMine(targetOverlay, identifier, proximity = 12) {
717
717
  targetOverlay = new typed_bytes_1.PeerAddress(targetOverlay);
718
718
  identifier = new typed_bytes_1.Identifier(identifier);
719
719
  const start = 0xb33n;
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.subscribe = exports.send = void 0;
7
+ const cafe_utility_1 = require("cafe-utility");
7
8
  const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
8
9
  const soc_1 = require("../chunk/soc");
9
10
  const endpoint = 'gsoc';
@@ -13,6 +14,9 @@ async function send(requestOptions, soc, stamp, options) {
13
14
  exports.send = send;
14
15
  function subscribe(url, reference, headers) {
15
16
  const wsUrl = url.replace(/^http/i, 'ws');
17
+ if (cafe_utility_1.System.whereAmI() === 'browser') {
18
+ return new isomorphic_ws_1.default(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`);
19
+ }
16
20
  return new isomorphic_ws_1.default(`${wsUrl}/${endpoint}/subscribe/${reference.toHex()}`, {
17
21
  headers,
18
22
  });
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.subscribe = exports.send = void 0;
7
+ const cafe_utility_1 = require("cafe-utility");
7
8
  const isomorphic_ws_1 = __importDefault(require("isomorphic-ws"));
8
9
  const headers_1 = require("../utils/headers");
9
10
  const http_1 = require("../utils/http");
@@ -38,6 +39,9 @@ exports.send = send;
38
39
  */
39
40
  function subscribe(url, topic, headers) {
40
41
  const wsUrl = url.replace(/^http/i, 'ws');
42
+ if (cafe_utility_1.System.whereAmI() === 'browser') {
43
+ return new isomorphic_ws_1.default(`${wsUrl}/${endpoint}/subscribe/${topic.toHex()}`);
44
+ }
41
45
  return new isomorphic_ws_1.default(`${wsUrl}/${endpoint}/subscribe/${topic.toHex()}`, {
42
46
  headers,
43
47
  });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStampUsage = exports.getStampTheoreticalBytes = exports.getStampEffectiveBytes = exports.getStampDuration = exports.getStampCost = exports.getDepthForSize = exports.getAmountForDuration = exports.getRedundancyStats = exports.getRedundancyStat = exports.approximateOverheadForRedundancyLevel = exports.makeMaxTarget = exports.getFolderSize = exports.makeCollectionFromFileList = exports.getCollectionSize = void 0;
3
+ exports.getStampUsage = exports.getStampTheoreticalBytes = exports.getStampEffectiveBytesBreakpoints = exports.getStampEffectiveBytes = exports.getStampDuration = exports.getStampCost = exports.getDepthForSize = exports.getAmountForDuration = exports.getRedundancyStats = exports.getRedundancyStat = exports.approximateOverheadForRedundancyLevel = exports.makeMaxTarget = exports.getFolderSize = exports.makeCollectionFromFileList = exports.getCollectionSize = void 0;
4
4
  var collection_1 = require("./collection");
5
5
  Object.defineProperty(exports, "getCollectionSize", { enumerable: true, get: function () { return collection_1.getCollectionSize; } });
6
6
  Object.defineProperty(exports, "makeCollectionFromFileList", { enumerable: true, get: function () { return collection_1.makeCollectionFromFileList; } });
@@ -18,5 +18,6 @@ Object.defineProperty(exports, "getDepthForSize", { enumerable: true, get: funct
18
18
  Object.defineProperty(exports, "getStampCost", { enumerable: true, get: function () { return stamps_1.getStampCost; } });
19
19
  Object.defineProperty(exports, "getStampDuration", { enumerable: true, get: function () { return stamps_1.getStampDuration; } });
20
20
  Object.defineProperty(exports, "getStampEffectiveBytes", { enumerable: true, get: function () { return stamps_1.getStampEffectiveBytes; } });
21
+ Object.defineProperty(exports, "getStampEffectiveBytesBreakpoints", { enumerable: true, get: function () { return stamps_1.getStampEffectiveBytesBreakpoints; } });
21
22
  Object.defineProperty(exports, "getStampTheoreticalBytes", { enumerable: true, get: function () { return stamps_1.getStampTheoreticalBytes; } });
22
23
  Object.defineProperty(exports, "getStampUsage", { enumerable: true, get: function () { return stamps_1.getStampUsage; } });
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.marshalStamp = exports.convertEnvelopeToMarshaledStamp = exports.getDepthForSize = exports.getAmountForDuration = exports.getStampDuration = exports.getStampCost = exports.getStampEffectiveBytes = exports.getStampTheoreticalBytes = exports.getStampUsage = void 0;
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
5
  const bytes_1 = require("./bytes");
6
6
  const duration_1 = require("./duration");
@@ -51,14 +51,14 @@ const effectiveSizeBreakpoints = [
51
51
  [23, 17.03],
52
52
  [24, 44.21],
53
53
  [25, 102.78],
54
- [26, 225.86],
55
- [27, 480.43],
56
- [28, 1.0],
57
- [29, 2.06],
58
- [30, 4.2],
59
- [31, 8.52],
60
- [32, 17.2],
61
- [33, 34.63],
54
+ [26, 225.87],
55
+ [27, 480.44],
56
+ [28, 1001.44],
57
+ [29, 2060.27],
58
+ [30, 4201.9],
59
+ [31, 8519.02],
60
+ [32, 17199.89],
61
+ [33, 34628.46],
62
62
  ];
63
63
  /**
64
64
  * Utility function that calculates the effective size of a postage batch based on its depth.
@@ -76,6 +76,14 @@ function getStampEffectiveBytes(depth) {
76
76
  return Math.ceil(getStampTheoreticalBytes(depth) * utilRate);
77
77
  }
78
78
  exports.getStampEffectiveBytes = getStampEffectiveBytes;
79
+ function getStampEffectiveBytesBreakpoints() {
80
+ const map = new Map();
81
+ for (let i = 22; i < 35; i++) {
82
+ map.set(i, getStampEffectiveBytes(i));
83
+ }
84
+ return map;
85
+ }
86
+ exports.getStampEffectiveBytesBreakpoints = getStampEffectiveBytesBreakpoints;
79
87
  /**
80
88
  * Utility function that calculates the cost of a postage batch based on its depth and amount.
81
89
  */