@audius/sdk 3.0.3-beta.83 → 3.0.3-beta.84

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/index.cjs.js CHANGED
@@ -20,7 +20,7 @@ var bs58 = require('bs58');
20
20
  var require$$0$1 = require('web3');
21
21
  var axios = require('axios');
22
22
  var util = require('util');
23
- var _ = require('lodash');
23
+ var lodash = require('lodash');
24
24
  var ipfsUnixfsImporter = require('ipfs-unixfs-importer');
25
25
  var fs = require('fs');
26
26
  var stream = require('stream');
@@ -80,7 +80,6 @@ var semver__default = /*#__PURE__*/_interopDefaultLegacy(semver);
80
80
  var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
81
81
  var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
82
82
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
83
- var ___default = /*#__PURE__*/_interopDefaultLegacy(_);
84
83
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
85
84
  var solanaWeb3__default = /*#__PURE__*/_interopDefaultLegacy(solanaWeb3);
86
85
  var FormData__default = /*#__PURE__*/_interopDefaultLegacy(FormData$1);
@@ -28568,7 +28567,7 @@ var MultiProvider = /*#__PURE__*/function (_Web3$providers$HttpP) {
28568
28567
  while (1) {
28569
28568
  switch (_context.prev = _context.next) {
28570
28569
  case 0:
28571
- _iterator = _createForOfIteratorHelper(_.shuffle(this.providers));
28570
+ _iterator = _createForOfIteratorHelper(lodash.shuffle(this.providers));
28572
28571
  _context.prev = 1;
28573
28572
 
28574
28573
  _iterator.s();
@@ -29851,195 +29850,6 @@ function getDomainSeparator(web3, name, contractAddress, chainId) {
29851
29850
  return Utils.keccak256(encoded);
29852
29851
  }
29853
29852
 
29854
- /**
29855
- * Fetches a url and times how long it took the request to complete.
29856
- */
29857
-
29858
- function timeRequest(_x, _x2, _x3) {
29859
- return _timeRequest.apply(this, arguments);
29860
- }
29861
- /**
29862
- * Custom sort for `serviceTimings`, the response from `timeRequest()` function above
29863
- */
29864
-
29865
-
29866
- function _timeRequest() {
29867
- _timeRequest = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee(request, timeout, headers) {
29868
- var startTime, config, response, millis;
29869
- return regeneratorRuntime.wrap(function _callee$(_context) {
29870
- while (1) {
29871
- switch (_context.prev = _context.next) {
29872
- case 0:
29873
- // This is non-perfect because of the js event loop, but enough
29874
- // of a proximation. Don't use for mission-critical timing.
29875
- startTime = new Date().getTime();
29876
- config = {};
29877
-
29878
- if (timeout !== null && timeout !== undefined) {
29879
- config.timeout = timeout;
29880
- }
29881
-
29882
- if (headers) config.headers = headers;
29883
- _context.prev = 4;
29884
- _context.next = 7;
29885
- return axios__default["default"].get(request.url, config);
29886
-
29887
- case 7:
29888
- response = _context.sent;
29889
- _context.next = 14;
29890
- break;
29891
-
29892
- case 10:
29893
- _context.prev = 10;
29894
- _context.t0 = _context["catch"](4);
29895
- console.debug("Error with request for ".concat(request.url, ": ").concat(_context.t0));
29896
- return _context.abrupt("return", {
29897
- request: request,
29898
- response: null,
29899
- millis: null
29900
- });
29901
-
29902
- case 14:
29903
- millis = new Date().getTime() - startTime;
29904
- return _context.abrupt("return", {
29905
- request: request,
29906
- response: response,
29907
- millis: millis
29908
- });
29909
-
29910
- case 16:
29911
- case "end":
29912
- return _context.stop();
29913
- }
29914
- }
29915
- }, _callee, null, [[4, 10]]);
29916
- }));
29917
- return _timeRequest.apply(this, arguments);
29918
- }
29919
-
29920
- function sortServiceTimings(_ref) {
29921
- var serviceTimings = _ref.serviceTimings,
29922
- sortByVersion = _ref.sortByVersion,
29923
- _ref$currentVersion = _ref.currentVersion,
29924
- currentVersion = _ref$currentVersion === void 0 ? null : _ref$currentVersion,
29925
- _ref$equivalencyDelta = _ref.equivalencyDelta,
29926
- equivalencyDelta = _ref$equivalencyDelta === void 0 ? null : _ref$equivalencyDelta;
29927
- return serviceTimings.sort(function (a, b) {
29928
- var _a$millis, _b$millis;
29929
-
29930
- // If health check failed, send to back of timings
29931
- if (a.response == null) return 1;
29932
- if (b.response == null) return -1;
29933
- var aVersion = a.response.data.data.version;
29934
- var bVersion = b.response.data.data.version;
29935
-
29936
- if (sortByVersion) {
29937
- // Always sort by version desc
29938
- if (semver__default["default"].gt(aVersion, bVersion)) return -1;
29939
- if (semver__default["default"].lt(aVersion, bVersion)) return 1;
29940
- } else if (!sortByVersion && currentVersion) {
29941
- // Only sort by version if behind current on-chain version
29942
- if (semver__default["default"].gt(currentVersion, aVersion) && semver__default["default"].gt(currentVersion, bVersion)) {
29943
- if (semver__default["default"].gt(aVersion, bVersion)) return -1;
29944
- if (semver__default["default"].lt(aVersion, bVersion)) return 1;
29945
- } else if (semver__default["default"].gt(currentVersion, aVersion)) {
29946
- return 1;
29947
- } else if (semver__default["default"].gt(currentVersion, bVersion)) {
29948
- return -1;
29949
- }
29950
- } // If same version and transcode queue load, do a tie breaker on the response time
29951
- // If the requests are near eachother (delta < equivalencyDelta), pick randomly
29952
-
29953
-
29954
- var delta = ((_a$millis = a.millis) !== null && _a$millis !== void 0 ? _a$millis : 0) - ((_b$millis = b.millis) !== null && _b$millis !== void 0 ? _b$millis : 0);
29955
-
29956
- if (equivalencyDelta !== null && delta < equivalencyDelta) {
29957
- return 1 - 2 * Math.random(); // [-1, 1]
29958
- }
29959
-
29960
- return delta;
29961
- });
29962
- }
29963
- /**
29964
- * Fetches multiple urls and times each request and returns the results sorted
29965
- * first by version and then by lowest-latency.
29966
- */
29967
-
29968
-
29969
- function timeRequests(_x4) {
29970
- return _timeRequests.apply(this, arguments);
29971
- }
29972
- /**
29973
- * Races multiple requests
29974
- * @param urls
29975
- * @param callback invoked with the first successful url
29976
- * @param axiosConfig extra axios config for each request
29977
- * @param timeout timeout for any requests to be considered bad
29978
- * @param timeBetweenRequests time between requests being dispatched to free up client network interface
29979
- */
29980
-
29981
-
29982
- function _timeRequests() {
29983
- _timeRequests = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref2) {
29984
- var requests, _ref2$sortByVersion, sortByVersion, _ref2$currentVersion, currentVersion, _ref2$filterNonRespon, filterNonResponsive, _ref2$timeout, timeout, _ref2$equivalencyDelt, equivalencyDelta, _ref2$headers, headers, serviceTimings;
29985
-
29986
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
29987
- while (1) {
29988
- switch (_context3.prev = _context3.next) {
29989
- case 0:
29990
- requests = _ref2.requests, _ref2$sortByVersion = _ref2.sortByVersion, sortByVersion = _ref2$sortByVersion === void 0 ? false : _ref2$sortByVersion, _ref2$currentVersion = _ref2.currentVersion, currentVersion = _ref2$currentVersion === void 0 ? null : _ref2$currentVersion, _ref2$filterNonRespon = _ref2.filterNonResponsive, filterNonResponsive = _ref2$filterNonRespon === void 0 ? false : _ref2$filterNonRespon, _ref2$timeout = _ref2.timeout, timeout = _ref2$timeout === void 0 ? null : _ref2$timeout, _ref2$equivalencyDelt = _ref2.equivalencyDelta, equivalencyDelta = _ref2$equivalencyDelt === void 0 ? null : _ref2$equivalencyDelt, _ref2$headers = _ref2.headers, headers = _ref2$headers === void 0 ? null : _ref2$headers;
29991
- _context3.next = 3;
29992
- return Promise.all(requests.map( /*#__PURE__*/function () {
29993
- var _ref4 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2(request) {
29994
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
29995
- while (1) {
29996
- switch (_context2.prev = _context2.next) {
29997
- case 0:
29998
- _context2.next = 2;
29999
- return timeRequest(request, timeout, headers);
30000
-
30001
- case 2:
30002
- return _context2.abrupt("return", _context2.sent);
30003
-
30004
- case 3:
30005
- case "end":
30006
- return _context2.stop();
30007
- }
30008
- }
30009
- }, _callee2);
30010
- }));
30011
-
30012
- return function (_x9) {
30013
- return _ref4.apply(this, arguments);
30014
- };
30015
- }()));
30016
-
30017
- case 3:
30018
- serviceTimings = _context3.sent;
30019
-
30020
- if (filterNonResponsive) {
30021
- serviceTimings = serviceTimings.filter(function (timing) {
30022
- return timing.response !== null;
30023
- });
30024
- }
30025
-
30026
- return _context3.abrupt("return", sortServiceTimings({
30027
- serviceTimings: serviceTimings,
30028
- currentVersion: currentVersion,
30029
- sortByVersion: sortByVersion,
30030
- equivalencyDelta: equivalencyDelta
30031
- }));
30032
-
30033
- case 6:
30034
- case "end":
30035
- return _context3.stop();
30036
- }
30037
- }
30038
- }, _callee3);
30039
- }));
30040
- return _timeRequests.apply(this, arguments);
30041
- }
30042
-
30043
29853
  function raceRequests(_x5, _x6, _x7) {
30044
29854
  return _raceRequests.apply(this, arguments);
30045
29855
  }
@@ -32681,9 +32491,9 @@ var EthWeb3Manager = /*#__PURE__*/function () {
32681
32491
  }();
32682
32492
 
32683
32493
  var name = "@audius/sdk";
32684
- var version = "3.0.3-beta.83";
32494
+ var version = "3.0.3-beta.84";
32685
32495
  var audius = {
32686
- releaseSHA: "950901e0c75f4b2f4e478a72ad2316a23fd8bc11"
32496
+ releaseSHA: "a742c13c166e5def2fca6faf9d40de19f6559e3f"
32687
32497
  };
32688
32498
  var description = "Audius SDK";
32689
32499
  var main = "dist/index.cjs.js";
@@ -34414,7 +34224,7 @@ var RegistryClient = /*#__PURE__*/function () {
34414
34224
  return RegistryClient;
34415
34225
  }();
34416
34226
 
34417
- var DECISION_TREE_STATE$1;
34227
+ var DECISION_TREE_STATE;
34418
34228
 
34419
34229
  (function (DECISION_TREE_STATE) {
34420
34230
  DECISION_TREE_STATE["CHECK_SHORT_CIRCUIT"] = "Check Short Circuit";
@@ -34429,7 +34239,7 @@ var DECISION_TREE_STATE$1;
34429
34239
  DECISION_TREE_STATE["ROUND_FAILED_RETRY"] = "Round Failed Retry";
34430
34240
  DECISION_TREE_STATE["MADE_A_SELECTION"] = "Made A Selection";
34431
34241
  DECISION_TREE_STATE["RACED_AND_FOUND_BEST"] = "Raced And Found Best";
34432
- })(DECISION_TREE_STATE$1 || (DECISION_TREE_STATE$1 = {}));
34242
+ })(DECISION_TREE_STATE || (DECISION_TREE_STATE = {}));
34433
34243
 
34434
34244
  function isVerbose(service) {
34435
34245
  return typeof service !== 'string';
@@ -34539,7 +34349,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34539
34349
  case 4:
34540
34350
  shortcircuit = _context.sent;
34541
34351
  this.decisionTree.push({
34542
- stage: DECISION_TREE_STATE$1.CHECK_SHORT_CIRCUIT,
34352
+ stage: DECISION_TREE_STATE.CHECK_SHORT_CIRCUIT,
34543
34353
  val: shortcircuit
34544
34354
  }); // If there is a shortcircuit defined and we have not blacklisted it, pick it
34545
34355
 
@@ -34557,14 +34367,14 @@ var ServiceSelection = /*#__PURE__*/function () {
34557
34367
  case 10:
34558
34368
  services = _context.sent;
34559
34369
  this.decisionTree.push({
34560
- stage: DECISION_TREE_STATE$1.GET_ALL_SERVICES,
34370
+ stage: DECISION_TREE_STATE.GET_ALL_SERVICES,
34561
34371
  val: services
34562
34372
  }); // If a whitelist is provided, filter down to it
34563
34373
 
34564
34374
  if (this.whitelist) {
34565
34375
  services = this.filterToWhitelist(services);
34566
34376
  this.decisionTree.push({
34567
- stage: DECISION_TREE_STATE$1.FILTER_TO_WHITELIST,
34377
+ stage: DECISION_TREE_STATE.FILTER_TO_WHITELIST,
34568
34378
  val: services
34569
34379
  });
34570
34380
  } // if a blacklist is provided, filter out services in the list
@@ -34573,7 +34383,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34573
34383
  if (this.blacklist) {
34574
34384
  services = this.filterFromBlacklist(services);
34575
34385
  this.decisionTree.push({
34576
- stage: DECISION_TREE_STATE$1.FILTER_FROM_BLACKLIST,
34386
+ stage: DECISION_TREE_STATE.FILTER_FROM_BLACKLIST,
34577
34387
  val: services
34578
34388
  });
34579
34389
  } // Filter out anything we know is already unhealthy
@@ -34581,13 +34391,13 @@ var ServiceSelection = /*#__PURE__*/function () {
34581
34391
 
34582
34392
  filteredServices = this.filterOutKnownUnhealthy(services);
34583
34393
  this.decisionTree.push({
34584
- stage: DECISION_TREE_STATE$1.FILTER_OUT_KNOWN_UNHEALTHY,
34394
+ stage: DECISION_TREE_STATE.FILTER_OUT_KNOWN_UNHEALTHY,
34585
34395
  val: filteredServices
34586
34396
  }); // Randomly sample a "round" to test
34587
34397
 
34588
34398
  round = this.getSelectionRound(filteredServices);
34589
34399
  this.decisionTree.push({
34590
- stage: DECISION_TREE_STATE$1.GET_SELECTION_ROUND,
34400
+ stage: DECISION_TREE_STATE.GET_SELECTION_ROUND,
34591
34401
  val: round
34592
34402
  });
34593
34403
  this.totalAttempts += round.length; // If there are no services left to try, either pick a backup or return null
@@ -34598,7 +34408,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34598
34408
  }
34599
34409
 
34600
34410
  this.decisionTree.push({
34601
- stage: DECISION_TREE_STATE$1.NO_SERVICES_LEFT_TO_TRY
34411
+ stage: DECISION_TREE_STATE.NO_SERVICES_LEFT_TO_TRY
34602
34412
  });
34603
34413
 
34604
34414
  if (!(this.getBackupsSize() > 0)) {
@@ -34612,7 +34422,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34612
34422
  case 24:
34613
34423
  backup = _context.sent;
34614
34424
  this.decisionTree.push({
34615
- stage: DECISION_TREE_STATE$1.SELECTED_FROM_BACKUP,
34425
+ stage: DECISION_TREE_STATE.SELECTED_FROM_BACKUP,
34616
34426
  val: backup
34617
34427
  });
34618
34428
  return _context.abrupt("return", backup);
@@ -34623,7 +34433,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34623
34433
  this.unhealthy = new Set([]);
34624
34434
  this.backups = {};
34625
34435
  this.decisionTree.push({
34626
- stage: DECISION_TREE_STATE$1.FAILED_AND_RESETTING
34436
+ stage: DECISION_TREE_STATE.FAILED_AND_RESETTING
34627
34437
  });
34628
34438
  return _context.abrupt("return", null);
34629
34439
 
@@ -34651,7 +34461,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34651
34461
  }
34652
34462
 
34653
34463
  this.decisionTree.push({
34654
- stage: DECISION_TREE_STATE$1.ROUND_FAILED_RETRY
34464
+ stage: DECISION_TREE_STATE.ROUND_FAILED_RETRY
34655
34465
  });
34656
34466
  _context.next = 44;
34657
34467
  return this.select(
@@ -34663,7 +34473,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34663
34473
 
34664
34474
  case 45:
34665
34475
  this.decisionTree.push({
34666
- stage: DECISION_TREE_STATE$1.MADE_A_SELECTION,
34476
+ stage: DECISION_TREE_STATE.MADE_A_SELECTION,
34667
34477
  val: best
34668
34478
  }); // If we made it this far, we found the best service! (of the rounds we tried)
34669
34479
 
@@ -34869,7 +34679,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34869
34679
  }, {
34870
34680
  key: "getSelectionRound",
34871
34681
  value: function getSelectionRound(services) {
34872
- return _.sampleSize(services, this.maxConcurrentRequests);
34682
+ return lodash.sampleSize(services, this.maxConcurrentRequests);
34873
34683
  }
34874
34684
  /** Gets the total number of attempts we've made this instantiation */
34875
34685
 
@@ -34930,7 +34740,7 @@ var ServiceSelection = /*#__PURE__*/function () {
34930
34740
  _yield$raceRequests = _context4.sent;
34931
34741
  errored = _yield$raceRequests.errored;
34932
34742
  this.decisionTree.push({
34933
- stage: DECISION_TREE_STATE$1.RACED_AND_FOUND_BEST,
34743
+ stage: DECISION_TREE_STATE.RACED_AND_FOUND_BEST,
34934
34744
  val: best
34935
34745
  });
34936
34746
  return _context4.abrupt("return", {
@@ -38358,7 +38168,7 @@ var ServiceProviderFactoryClient = /*#__PURE__*/function (_GovernedContractClie)
38358
38168
  case 2:
38359
38169
  numberOfProviders = _context28.sent;
38360
38170
  _context28.next = 5;
38361
- return Promise.all(_.range(1, numberOfProviders + 1).map( /*#__PURE__*/function () {
38171
+ return Promise.all(lodash.range(1, numberOfProviders + 1).map( /*#__PURE__*/function () {
38362
38172
  var _ref8 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee27(i) {
38363
38173
  return regeneratorRuntime.wrap(function _callee27$(_context27) {
38364
38174
  while (1) {
@@ -52469,7 +52279,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
52469
52279
  break;
52470
52280
  }
52471
52281
 
52472
- endpoints = _.sampleSize(endpoints, quorumSize);
52282
+ endpoints = lodash.sampleSize(endpoints, quorumSize);
52473
52283
  _context2.next = 9;
52474
52284
  break;
52475
52285
 
@@ -52980,7 +52790,7 @@ var Rewards = /*#__PURE__*/function (_Base) {
52980
52790
  break;
52981
52791
  }
52982
52792
 
52983
- attestEndpoints = _.sampleSize(endpoints, numAttestations);
52793
+ attestEndpoints = lodash.sampleSize(endpoints, numAttestations);
52984
52794
  _context10.next = 8;
52985
52795
  break;
52986
52796
 
@@ -58642,476 +58452,6 @@ var CreatorNode = /*#__PURE__*/function () {
58642
58452
  return CreatorNode;
58643
58453
  }();
58644
58454
 
58645
- var CREATOR_NODE_SERVICE_NAME = 'content-node';
58646
- var DECISION_TREE_STATE;
58647
-
58648
- (function (DECISION_TREE_STATE) {
58649
- DECISION_TREE_STATE["GET_ALL_SERVICES"] = "Get All Services";
58650
- DECISION_TREE_STATE["FILTER_TO_WHITELIST"] = "Filter To Whitelist";
58651
- DECISION_TREE_STATE["FILTER_FROM_BLACKLIST"] = "Filter From Blacklist";
58652
- DECISION_TREE_STATE["FILTER_OUT_UNHEALTHY_OUTDATED_AND_NO_STORAGE_SPACE"] = "Filter Out Unhealthy, Outdated, And No Storage Space";
58653
- DECISION_TREE_STATE["FILTER_OUT_SYNC_IN_PROGRESS"] = "Filter Out Sync In Progress";
58654
- DECISION_TREE_STATE["SELECT_PRIMARY_AND_SECONDARIES"] = "Select Primary And Secondaries";
58655
- })(DECISION_TREE_STATE || (DECISION_TREE_STATE = {}));
58656
-
58657
- /**
58658
- * In memory dictionary used to query spID from endpoint
58659
- * Eliminates duplicate web3 calls within same session
58660
- */
58661
-
58662
- var contentNodeEndpointToSpID = {};
58663
- function setSpIDForEndpoint(endpoint, spID) {
58664
- contentNodeEndpointToSpID[endpoint] = spID;
58665
- }
58666
- var CreatorNodeSelection = /*#__PURE__*/function (_ServiceSelection) {
58667
- _inherits(CreatorNodeSelection, _ServiceSelection);
58668
-
58669
- var _super = _createSuper(CreatorNodeSelection);
58670
-
58671
- function CreatorNodeSelection(_ref) {
58672
- var _this;
58673
-
58674
- var creatorNode = _ref.creatorNode,
58675
- numberOfNodes = _ref.numberOfNodes,
58676
- ethContracts = _ref.ethContracts,
58677
- whitelist = _ref.whitelist,
58678
- blacklist = _ref.blacklist,
58679
- _ref$logger = _ref.logger,
58680
- logger = _ref$logger === void 0 ? console : _ref$logger,
58681
- _ref$maxStorageUsedPe = _ref.maxStorageUsedPercent,
58682
- maxStorageUsedPercent = _ref$maxStorageUsedPe === void 0 ? 95 : _ref$maxStorageUsedPe,
58683
- _ref$timeout = _ref.timeout,
58684
- timeout = _ref$timeout === void 0 ? null : _ref$timeout,
58685
- _ref$equivalencyDelta = _ref.equivalencyDelta,
58686
- equivalencyDelta = _ref$equivalencyDelta === void 0 ? null : _ref$equivalencyDelta,
58687
- _ref$preferHigherPatc = _ref.preferHigherPatchForPrimary,
58688
- preferHigherPatchForPrimary = _ref$preferHigherPatc === void 0 ? true : _ref$preferHigherPatc,
58689
- _ref$preferHigherPatc2 = _ref.preferHigherPatchForSecondaries,
58690
- preferHigherPatchForSecondaries = _ref$preferHigherPatc2 === void 0 ? true : _ref$preferHigherPatc2,
58691
- getServices = _ref.getServices;
58692
-
58693
- _classCallCheck(this, CreatorNodeSelection);
58694
-
58695
- _this = _super.call(this, {
58696
- getServices: getServices ? getServices : /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee() {
58697
- var services;
58698
- return regeneratorRuntime.wrap(function _callee$(_context) {
58699
- while (1) {
58700
- switch (_context.prev = _context.next) {
58701
- case 0:
58702
- _context.next = 2;
58703
- return ethContracts.getCurrentVersion(CREATOR_NODE_SERVICE_NAME);
58704
-
58705
- case 2:
58706
- _this.currentVersion = _context.sent;
58707
- _context.next = 5;
58708
- return _this.ethContracts.getServiceProviderList(CREATOR_NODE_SERVICE_NAME);
58709
-
58710
- case 5:
58711
- services = _context.sent;
58712
- return _context.abrupt("return", services.map(function (e) {
58713
- setSpIDForEndpoint(e.endpoint, e.spID);
58714
- return e.endpoint;
58715
- }));
58716
-
58717
- case 7:
58718
- case "end":
58719
- return _context.stop();
58720
- }
58721
- }
58722
- }, _callee);
58723
- })),
58724
- // Use the content node's configured whitelist if not provided
58725
- whitelist: whitelist !== null && whitelist !== void 0 ? whitelist : creatorNode === null || creatorNode === void 0 ? void 0 : creatorNode.passList,
58726
- blacklist: blacklist !== null && blacklist !== void 0 ? blacklist : creatorNode === null || creatorNode === void 0 ? void 0 : creatorNode.blockList
58727
- });
58728
- _this.currentVersion = '';
58729
- _this.creatorNode = creatorNode;
58730
- _this.numberOfNodes = numberOfNodes;
58731
- _this.ethContracts = ethContracts;
58732
- _this.timeout = timeout;
58733
- _this.equivalencyDelta = equivalencyDelta;
58734
- _this.preferHigherPatchForPrimary = preferHigherPatchForPrimary;
58735
- _this.preferHigherPatchForSecondaries = preferHigherPatchForSecondaries;
58736
- _this.logger = logger;
58737
- _this.healthCheckPath = 'health_check/verbose'; // String array of healthy Content Node endpoints
58738
-
58739
- _this.backupsList = [];
58740
- _this.backupTimings = []; // Max percentage (represented out of 100) allowed before determining CN is unsuitable for selection
58741
-
58742
- _this.maxStorageUsedPercent = maxStorageUsedPercent; // The decision tree path that was taken. Reset on each new selection.
58743
-
58744
- _this.decisionTree = [];
58745
- return _this;
58746
- }
58747
- /**
58748
- * Selects a primary and secondary Content Nodes. Order of preference is highest version, then response time.
58749
- *
58750
- * 1. Retrieve all the Content Node services
58751
- * 2. Filter from/out Content Nodes based off of the whitelist and blacklist
58752
- * 3. Filter out unhealthy, outdated, and still syncing nodes via health and sync check
58753
- * 4. Sort by healthiest (highest version -> lowest version); secondary check if equal version based off of responseTime
58754
- * 5. Select a primary and numberOfNodes-1 number of secondaries (most likely 2) from backups
58755
- * @param @deprecated performSyncCheck (deprecated / unused) whether or not to check whether the nodes need syncs before selection
58756
- */
58757
-
58758
-
58759
- _createClass(CreatorNodeSelection, [{
58760
- key: "select",
58761
- value: function () {
58762
- var _select = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
58763
- var log,
58764
- services,
58765
- _yield$this$_performH,
58766
- healthyServicesList,
58767
- servicesMap,
58768
- healthyServiceTimings,
58769
- primary,
58770
- serviceTimingsSortedByVersion,
58771
- servicesSortedByVersion,
58772
- backupsList,
58773
- backupTimings,
58774
- secondaries,
58775
- _args2 = arguments;
58776
-
58777
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
58778
- while (1) {
58779
- switch (_context2.prev = _context2.next) {
58780
- case 0:
58781
- log = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : true;
58782
- // Reset decision tree and backups
58783
- this.decisionTree = [];
58784
- this.clearBackups();
58785
- this.clearUnhealthy(); // Get all the Content Node endpoints on chain and filter
58786
-
58787
- _context2.next = 7;
58788
- return this.getServices();
58789
-
58790
- case 7:
58791
- services = _context2.sent;
58792
- this.decisionTree.push({
58793
- stage: DECISION_TREE_STATE.GET_ALL_SERVICES,
58794
- val: services
58795
- });
58796
-
58797
- if (this.whitelist) {
58798
- services = this.filterToWhitelist(services);
58799
- }
58800
-
58801
- this.decisionTree.push({
58802
- stage: DECISION_TREE_STATE.FILTER_TO_WHITELIST,
58803
- val: services
58804
- });
58805
-
58806
- if (this.blacklist) {
58807
- services = this.filterFromBlacklist(services);
58808
- }
58809
-
58810
- this.decisionTree.push({
58811
- stage: DECISION_TREE_STATE.FILTER_FROM_BLACKLIST,
58812
- val: services
58813
- });
58814
- _context2.next = 15;
58815
- return this._performHealthChecks(services);
58816
-
58817
- case 15:
58818
- _yield$this$_performH = _context2.sent;
58819
- healthyServicesList = _yield$this$_performH.healthyServicesList;
58820
- servicesMap = _yield$this$_performH.healthyServicesMap;
58821
- healthyServiceTimings = _yield$this$_performH.healthyServiceTimings;
58822
- services = healthyServicesList;
58823
-
58824
- if (this.preferHigherPatchForPrimary) {
58825
- serviceTimingsSortedByVersion = sortServiceTimings({
58826
- serviceTimings: healthyServiceTimings,
58827
- currentVersion: this.currentVersion,
58828
- sortByVersion: true,
58829
- equivalencyDelta: this.equivalencyDelta
58830
- });
58831
- servicesSortedByVersion = serviceTimingsSortedByVersion.map(function (service) {
58832
- return service.request.id;
58833
- });
58834
- primary = this.getPrimary(servicesSortedByVersion);
58835
- } else {
58836
- primary = this.getPrimary(services);
58837
- } // `this.backupsList` & this.backupTimings are used in selecting secondaries
58838
-
58839
-
58840
- backupsList = ___default["default"].without(services, primary);
58841
- backupTimings = healthyServiceTimings.filter(function (timing) {
58842
- return timing.request.id !== primary;
58843
- });
58844
- this.setBackupsList(backupsList, backupTimings);
58845
- secondaries = this.getSecondaries();
58846
- this.decisionTree.push({
58847
- stage: DECISION_TREE_STATE.SELECT_PRIMARY_AND_SECONDARIES,
58848
- val: {
58849
- primary: primary,
58850
- secondaries: secondaries.toString(),
58851
- services: Object.keys(servicesMap).toString()
58852
- }
58853
- });
58854
-
58855
- if (log) {
58856
- this.logger.info('CreatorNodeSelection - final decision tree state', this.decisionTree);
58857
- }
58858
-
58859
- return _context2.abrupt("return", {
58860
- primary: primary,
58861
- secondaries: secondaries,
58862
- services: servicesMap
58863
- });
58864
-
58865
- case 28:
58866
- case "end":
58867
- return _context2.stop();
58868
- }
58869
- }
58870
- }, _callee2, this);
58871
- }));
58872
-
58873
- function select() {
58874
- return _select.apply(this, arguments);
58875
- }
58876
-
58877
- return select;
58878
- }()
58879
- /**
58880
- * Sets backupsList to input
58881
- * @param backupsList string array of Content Node endpoints
58882
- */
58883
-
58884
- }, {
58885
- key: "setBackupsList",
58886
- value: function setBackupsList(backupsList, backupTimings) {
58887
- // Rest of services that are not selected as the primary are valid backups. Add as backup
58888
- // This backups list will also be in order of descending highest version/fastest
58889
- this.backupsList = backupsList;
58890
- this.backupTimings = backupTimings;
58891
- }
58892
- /**
58893
- * Get backups in the form of an array
58894
- */
58895
-
58896
- }, {
58897
- key: "getBackupsList",
58898
- value: function getBackupsList() {
58899
- return this.backupsList;
58900
- }
58901
- /**
58902
- * Get backup timings in the form of an array
58903
- */
58904
-
58905
- }, {
58906
- key: "getBackupTimings",
58907
- value: function getBackupTimings() {
58908
- return this.backupTimings;
58909
- }
58910
- /**
58911
- * Select a primary Content Node
58912
- * @param {string[]} services all healthy Content Node endpoints
58913
- */
58914
-
58915
- }, {
58916
- key: "getPrimary",
58917
- value: function getPrimary(services) {
58918
- // Index 0 of services will be the most optimal Content Node candidate
58919
- // TODO: fix `as` cast
58920
- return services[0];
58921
- }
58922
- /**
58923
- * Selects secondary Content Nodes
58924
- * Returns first nodes from `services`, optionally sorted by version
58925
- */
58926
-
58927
- }, {
58928
- key: "getSecondaries",
58929
- value: function getSecondaries() {
58930
- var numberOfSecondaries = this.numberOfNodes - 1;
58931
- var backupsList = this.getBackupsList();
58932
- var backupTimings = this.getBackupTimings();
58933
- var secondaries;
58934
-
58935
- if (this.preferHigherPatchForSecondaries) {
58936
- var backupTimingsSortedByVersion = sortServiceTimings({
58937
- serviceTimings: backupTimings,
58938
- currentVersion: this.currentVersion,
58939
- sortByVersion: true,
58940
- equivalencyDelta: this.equivalencyDelta
58941
- });
58942
- var secondaryTimings = backupTimingsSortedByVersion.slice(0, numberOfSecondaries);
58943
- secondaries = secondaryTimings.map(function (timing) {
58944
- return timing.request.id;
58945
- });
58946
- } else {
58947
- secondaries = backupsList.slice(0, numberOfSecondaries);
58948
- }
58949
-
58950
- return secondaries;
58951
- }
58952
- /**
58953
- * Performs a health check for every endpoint in services. Returns an array of successful health checked endpoints and
58954
- * adds the err'd health checked endpoints to this.unhealthy, and a mapping of successful endpoint to its health check response.
58955
- * @param services content node endpoints
58956
- */
58957
-
58958
- }, {
58959
- key: "_performHealthChecks",
58960
- value: function () {
58961
- var _performHealthChecks2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(services) {
58962
- var _this2 = this,
58963
- _this$creatorNode;
58964
-
58965
- var healthCheckedServices, healthyServices, servicesMap, healthyServicesList;
58966
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
58967
- while (1) {
58968
- switch (_context3.prev = _context3.next) {
58969
- case 0:
58970
- _context3.next = 2;
58971
- return timeRequests({
58972
- requests: services.map(function (node) {
58973
- return {
58974
- id: node,
58975
- url: "".concat(node, "/").concat(_this2.healthCheckPath)
58976
- };
58977
- }),
58978
- sortByVersion: false,
58979
- currentVersion: this.currentVersion,
58980
- timeout: this.timeout,
58981
- equivalencyDelta: this.equivalencyDelta,
58982
- headers: {
58983
- 'User-Agent': 'Axios - @audius/sdk - CreatorNodeSelection.ts#_performHealthChecks'
58984
- }
58985
- });
58986
-
58987
- case 2:
58988
- healthCheckedServices = _context3.sent;
58989
- healthyServices = healthCheckedServices.filter(function (resp) {
58990
- var endpoint = resp.request.id;
58991
- var isHealthy = false; // Check that the health check:
58992
- // 1. Responded with status code 200
58993
- // 2. Version is up to date on major and minor
58994
- // 3. Has enough storage space
58995
- // - Max capacity percent is defined from CN health check response. If not present,
58996
- // use existing value from `this.maxStorageUsedPercent`
58997
-
58998
- if (resp.response) {
58999
- var isUp = resp.response.status === 200;
59000
- var versionIsUpToDate = isVersionAtLeastSameMajorMinor(_this2.currentVersion, resp.response.data.data.version);
59001
- var isHealthyStatus = resp.response.data.data.healthy;
59002
- var _resp$response$data$d = resp.response.data.data,
59003
- storagePathSize = _resp$response$data$d.storagePathSize,
59004
- storagePathUsed = _resp$response$data$d.storagePathUsed,
59005
- maxStorageUsedPercent = _resp$response$data$d.maxStorageUsedPercent;
59006
-
59007
- if (maxStorageUsedPercent) {
59008
- _this2.maxStorageUsedPercent = maxStorageUsedPercent;
59009
- } else {
59010
- _this2.logger.warn("maxStorageUsedPercent not found in health check response. Using constructor value of ".concat(_this2.maxStorageUsedPercent, "% as maxStorageUsedPercent."));
59011
- }
59012
-
59013
- var hasEnoughStorage = _this2._hasEnoughStorageSpace(storagePathSize, storagePathUsed);
59014
-
59015
- isHealthy = isUp && versionIsUpToDate && hasEnoughStorage && isHealthyStatus;
59016
- }
59017
-
59018
- if (!isHealthy) {
59019
- _this2.addUnhealthy(endpoint);
59020
- }
59021
-
59022
- return isHealthy;
59023
- }); // Create a mapping of healthy services and their responses. Used on dapp to display the healthy services for selection
59024
- // Also update services to be healthy services
59025
-
59026
- servicesMap = {};
59027
- healthyServicesList = healthyServices.map(function (service) {
59028
- var _service$response;
59029
-
59030
- var requestId = service.request.id;
59031
- servicesMap[requestId] = (_service$response = service.response) === null || _service$response === void 0 ? void 0 : _service$response.data;
59032
- return service.request.id;
59033
- });
59034
- this.decisionTree.push({
59035
- stage: DECISION_TREE_STATE.FILTER_OUT_UNHEALTHY_OUTDATED_AND_NO_STORAGE_SPACE,
59036
- val: healthyServicesList
59037
- }); // Record metrics
59038
-
59039
- if ((_this$creatorNode = this.creatorNode) !== null && _this$creatorNode !== void 0 && _this$creatorNode.monitoringCallbacks.healthCheck) {
59040
- healthCheckedServices.forEach(function (check) {
59041
- var _check$response;
59042
-
59043
- if ((_check$response = check.response) !== null && _check$response !== void 0 && _check$response.data) {
59044
- var url = new URL(check.request.url);
59045
- var data = check.response.data.data;
59046
-
59047
- try {
59048
- var _this2$creatorNode$mo, _this2$creatorNode$mo2;
59049
-
59050
- (_this2$creatorNode$mo = (_this2$creatorNode$mo2 = _this2.creatorNode.monitoringCallbacks).healthCheck) === null || _this2$creatorNode$mo === void 0 ? void 0 : _this2$creatorNode$mo.call(_this2$creatorNode$mo2, {
59051
- endpoint: url.origin,
59052
- pathname: url.pathname,
59053
- searchParams: url.searchParams,
59054
- version: data.version,
59055
- git: data.git,
59056
- selectedDiscoveryNode: data.selectedDiscoveryProvider,
59057
- databaseSize: data.databaseSize,
59058
- databaseConnections: data.databaseConnections,
59059
- totalMemory: data.totalMemory,
59060
- usedMemory: data.usedMemory,
59061
- totalStorage: data.storagePathSize,
59062
- usedStorage: data.storagePathUsed,
59063
- maxFileDescriptors: data.maxFileDescriptors,
59064
- allocatedFileDescriptors: data.allocatedFileDescriptors,
59065
- receivedBytesPerSec: data.receivedBytesPerSec,
59066
- transferredBytesPerSec: data.transferredBytesPerSec,
59067
- transcodeWaiting: data.transcodeWaiting,
59068
- transcodeActive: data.transcodeActive,
59069
- fileProcessingWaiting: data.fileProcessingWaiting,
59070
- fileProcessingActive: data.fileProcessingActive
59071
- });
59072
- } catch (e) {
59073
- // Swallow errors -- this method should not throw generally
59074
- _this2.logger.error(e);
59075
- }
59076
- }
59077
- });
59078
- }
59079
-
59080
- return _context3.abrupt("return", {
59081
- healthyServicesList: healthyServicesList,
59082
- healthyServicesMap: servicesMap,
59083
- healthyServiceTimings: healthyServices
59084
- });
59085
-
59086
- case 9:
59087
- case "end":
59088
- return _context3.stop();
59089
- }
59090
- }
59091
- }, _callee3, this);
59092
- }));
59093
-
59094
- function _performHealthChecks(_x) {
59095
- return _performHealthChecks2.apply(this, arguments);
59096
- }
59097
-
59098
- return _performHealthChecks;
59099
- }()
59100
- }, {
59101
- key: "_hasEnoughStorageSpace",
59102
- value: function _hasEnoughStorageSpace(storagePathSize, storagePathUsed) {
59103
- // If for any reason these values off the response is falsy value, default to enough storage
59104
- if (storagePathSize === null || storagePathSize === undefined || storagePathUsed === null || storagePathUsed === undefined) {
59105
- return true;
59106
- }
59107
-
59108
- return 100 * storagePathUsed / storagePathSize < this.maxStorageUsedPercent;
59109
- }
59110
- }]);
59111
-
59112
- return CreatorNodeSelection;
59113
- }(ServiceSelection);
59114
-
59115
58455
  var DISCOVERY_PROVIDER_TIMESTAMP = '@audius/libs:discovery-node-timestamp';
59116
58456
  var DISCOVERY_SERVICE_NAME = 'discovery-node';
59117
58457
  var DEFAULT_UNHEALTHY_BLOCK_DIFF = 15;
@@ -64662,13 +64002,7 @@ var UserStateManager = /*#__PURE__*/function () {
64662
64002
  }();
64663
64003
 
64664
64004
  var CONTENT_NODE_SERVICE_NAME = 'content-node';
64665
- var DISCOVERY_NODE_SERVICE_NAME = 'discovery-node'; // Default timeout for each content node's sync and health check
64666
-
64667
- var CONTENT_NODE_DEFAULT_SELECTION_TIMEOUT = 7500; // Default time at which responses are considered equal weighting.
64668
- // Content nodes that reply within 200ms of eachother are given equal footing
64669
- // in selection
64670
-
64671
- var CONTENT_NODE_SELECTION_EQUIVALENCY_DELTA = 200;
64005
+ var DISCOVERY_NODE_SERVICE_NAME = 'discovery-node';
64672
64006
  /**
64673
64007
  * API methods to interact with Audius service providers.
64674
64008
  * Types of services include:
@@ -64726,143 +64060,6 @@ var ServiceProvider = /*#__PURE__*/function (_Base) {
64726
64060
 
64727
64061
  return listCreatorNodes;
64728
64062
  }()
64729
- /**
64730
- * Fetches healthy Content Nodes filtered down to a given whitelist and blacklist
64731
- */
64732
-
64733
- }, {
64734
- key: "getSelectableCreatorNodes",
64735
- value: function () {
64736
- var _getSelectableCreatorNodes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
64737
- var whitelist,
64738
- blacklist,
64739
- timeout,
64740
- creatorNodes,
64741
- timings,
64742
- services,
64743
- _args2 = arguments;
64744
- return regeneratorRuntime.wrap(function _callee2$(_context2) {
64745
- while (1) {
64746
- switch (_context2.prev = _context2.next) {
64747
- case 0:
64748
- whitelist = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : null;
64749
- blacklist = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : null;
64750
- timeout = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : CONTENT_NODE_DEFAULT_SELECTION_TIMEOUT;
64751
- _context2.next = 5;
64752
- return this.listCreatorNodes();
64753
-
64754
- case 5:
64755
- creatorNodes = _context2.sent;
64756
-
64757
- // Filter whitelist
64758
- if (whitelist) {
64759
- creatorNodes = creatorNodes.filter(function (node) {
64760
- return whitelist.has(node.endpoint);
64761
- });
64762
- } // Filter blacklist
64763
-
64764
-
64765
- if (blacklist) {
64766
- creatorNodes = creatorNodes.filter(function (node) {
64767
- return !blacklist.has(node.endpoint);
64768
- });
64769
- } // Time requests and get version info
64770
-
64771
-
64772
- _context2.next = 10;
64773
- return timeRequests({
64774
- requests: creatorNodes.map(function (node) {
64775
- return {
64776
- id: node.endpoint,
64777
- url: "".concat(node.endpoint, "/health_check/verbose")
64778
- };
64779
- }),
64780
- sortByVersion: true,
64781
- timeout: timeout,
64782
- headers: {
64783
- 'User-Agent': 'Axios - @audius/sdk - ServiceProvider.ts#getSelectableCreatorNodes'
64784
- }
64785
- });
64786
-
64787
- case 10:
64788
- timings = _context2.sent;
64789
- services = {};
64790
- timings.forEach(function (timing) {
64791
- if (timing.response && timing.request.id) services[timing.request.id] = timing.response.data.data;
64792
- });
64793
- return _context2.abrupt("return", services);
64794
-
64795
- case 14:
64796
- case "end":
64797
- return _context2.stop();
64798
- }
64799
- }
64800
- }, _callee2, this);
64801
- }));
64802
-
64803
- function getSelectableCreatorNodes() {
64804
- return _getSelectableCreatorNodes.apply(this, arguments);
64805
- }
64806
-
64807
- return getSelectableCreatorNodes;
64808
- }()
64809
- /**
64810
- * Fetches healthy Content Nodes and autoselects a primary
64811
- * and two secondaries.
64812
- */
64813
-
64814
- }, {
64815
- key: "autoSelectCreatorNodes",
64816
- value: function () {
64817
- var _autoSelectCreatorNodes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3(_ref) {
64818
- var _ref$numberOfNodes, numberOfNodes, _ref$whitelist, whitelist, _ref$blacklist, blacklist, _ref$performSyncCheck, performSyncCheck, _ref$timeout, timeout, _ref$equivalencyDelta, equivalencyDelta, _ref$preferHigherPatc, preferHigherPatchForPrimary, _ref$preferHigherPatc2, preferHigherPatchForSecondaries, _ref$log, log, getServices, creatorNodeSelection, _yield$creatorNodeSel, primary, secondaries, services;
64819
-
64820
- return regeneratorRuntime.wrap(function _callee3$(_context3) {
64821
- while (1) {
64822
- switch (_context3.prev = _context3.next) {
64823
- case 0:
64824
- _ref$numberOfNodes = _ref.numberOfNodes, numberOfNodes = _ref$numberOfNodes === void 0 ? 3 : _ref$numberOfNodes, _ref$whitelist = _ref.whitelist, whitelist = _ref$whitelist === void 0 ? null : _ref$whitelist, _ref$blacklist = _ref.blacklist, blacklist = _ref$blacklist === void 0 ? null : _ref$blacklist, _ref$performSyncCheck = _ref.performSyncCheck, performSyncCheck = _ref$performSyncCheck === void 0 ? true : _ref$performSyncCheck, _ref$timeout = _ref.timeout, timeout = _ref$timeout === void 0 ? CONTENT_NODE_DEFAULT_SELECTION_TIMEOUT : _ref$timeout, _ref$equivalencyDelta = _ref.equivalencyDelta, equivalencyDelta = _ref$equivalencyDelta === void 0 ? CONTENT_NODE_SELECTION_EQUIVALENCY_DELTA : _ref$equivalencyDelta, _ref$preferHigherPatc = _ref.preferHigherPatchForPrimary, preferHigherPatchForPrimary = _ref$preferHigherPatc === void 0 ? true : _ref$preferHigherPatc, _ref$preferHigherPatc2 = _ref.preferHigherPatchForSecondaries, preferHigherPatchForSecondaries = _ref$preferHigherPatc2 === void 0 ? true : _ref$preferHigherPatc2, _ref$log = _ref.log, log = _ref$log === void 0 ? true : _ref$log, getServices = _ref.getServices;
64825
- creatorNodeSelection = new CreatorNodeSelection({
64826
- creatorNode: this.creatorNode,
64827
- ethContracts: this.ethContracts,
64828
- logger: this.logger,
64829
- numberOfNodes: numberOfNodes,
64830
- whitelist: whitelist,
64831
- blacklist: blacklist,
64832
- timeout: timeout,
64833
- equivalencyDelta: equivalencyDelta,
64834
- preferHigherPatchForPrimary: preferHigherPatchForPrimary,
64835
- preferHigherPatchForSecondaries: preferHigherPatchForSecondaries,
64836
- getServices: getServices
64837
- });
64838
- _context3.next = 4;
64839
- return creatorNodeSelection.select(performSyncCheck, log);
64840
-
64841
- case 4:
64842
- _yield$creatorNodeSel = _context3.sent;
64843
- primary = _yield$creatorNodeSel.primary;
64844
- secondaries = _yield$creatorNodeSel.secondaries;
64845
- services = _yield$creatorNodeSel.services;
64846
- return _context3.abrupt("return", {
64847
- primary: primary,
64848
- secondaries: secondaries,
64849
- services: services
64850
- });
64851
-
64852
- case 9:
64853
- case "end":
64854
- return _context3.stop();
64855
- }
64856
- }
64857
- }, _callee3, this);
64858
- }));
64859
-
64860
- function autoSelectCreatorNodes(_x) {
64861
- return _autoSelectCreatorNodes.apply(this, arguments);
64862
- }
64863
-
64864
- return autoSelectCreatorNodes;
64865
- }()
64866
64063
  /**
64867
64064
  * Selects numNodes storage nodes from the list of registered storage nodes on chain, optionally ordering them (descending) by rendezvous score.
64868
64065
  * TODO: This might want to handle blocklist/allowlist, latency checks, health checks, etc... but for now it just uses all nodes.
@@ -64872,43 +64069,43 @@ var ServiceProvider = /*#__PURE__*/function (_Base) {
64872
64069
  }, {
64873
64070
  key: "autoSelectStorageV2Nodes",
64874
64071
  value: function () {
64875
- var _autoSelectStorageV2Nodes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4() {
64072
+ var _autoSelectStorageV2Nodes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee2() {
64876
64073
  var numNodes,
64877
64074
  userWallet,
64878
64075
  logger,
64879
- _args4 = arguments;
64880
- return regeneratorRuntime.wrap(function _callee4$(_context4) {
64076
+ _args2 = arguments;
64077
+ return regeneratorRuntime.wrap(function _callee2$(_context2) {
64881
64078
  while (1) {
64882
- switch (_context4.prev = _context4.next) {
64079
+ switch (_context2.prev = _context2.next) {
64883
64080
  case 0:
64884
- numNodes = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : 0;
64885
- userWallet = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : '';
64886
- logger = _args4.length > 2 && _args4[2] !== undefined ? _args4[2] : console;
64081
+ numNodes = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : 0;
64082
+ userWallet = _args2.length > 1 && _args2[1] !== undefined ? _args2[1] : '';
64083
+ logger = _args2.length > 2 && _args2[2] !== undefined ? _args2[2] : console;
64887
64084
 
64888
64085
  if (this.cachedStorageNodes.length) {
64889
- _context4.next = 7;
64086
+ _context2.next = 7;
64890
64087
  break;
64891
64088
  }
64892
64089
 
64893
- _context4.next = 6;
64090
+ _context2.next = 6;
64894
64091
  return this.listCreatorNodes();
64895
64092
 
64896
64093
  case 6:
64897
- this.cachedStorageNodes = _context4.sent;
64094
+ this.cachedStorageNodes = _context2.sent;
64898
64095
 
64899
64096
  case 7:
64900
- _context4.next = 9;
64097
+ _context2.next = 9;
64901
64098
  return getNStorageNodes(this.cachedStorageNodes, numNodes, userWallet, logger);
64902
64099
 
64903
64100
  case 9:
64904
- return _context4.abrupt("return", _context4.sent);
64101
+ return _context2.abrupt("return", _context2.sent);
64905
64102
 
64906
64103
  case 10:
64907
64104
  case "end":
64908
- return _context4.stop();
64105
+ return _context2.stop();
64909
64106
  }
64910
64107
  }
64911
- }, _callee4, this);
64108
+ }, _callee2, this);
64912
64109
  }));
64913
64110
 
64914
64111
  function autoSelectStorageV2Nodes() {
@@ -64922,23 +64119,23 @@ var ServiceProvider = /*#__PURE__*/function (_Base) {
64922
64119
  }, {
64923
64120
  key: "listDiscoveryProviders",
64924
64121
  value: function () {
64925
- var _listDiscoveryProviders = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5() {
64926
- return regeneratorRuntime.wrap(function _callee5$(_context5) {
64122
+ var _listDiscoveryProviders = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee3() {
64123
+ return regeneratorRuntime.wrap(function _callee3$(_context3) {
64927
64124
  while (1) {
64928
- switch (_context5.prev = _context5.next) {
64125
+ switch (_context3.prev = _context3.next) {
64929
64126
  case 0:
64930
- _context5.next = 2;
64127
+ _context3.next = 2;
64931
64128
  return this.ethContracts.ServiceProviderFactoryClient.getServiceProviderList(DISCOVERY_NODE_SERVICE_NAME);
64932
64129
 
64933
64130
  case 2:
64934
- return _context5.abrupt("return", _context5.sent);
64131
+ return _context3.abrupt("return", _context3.sent);
64935
64132
 
64936
64133
  case 3:
64937
64134
  case "end":
64938
- return _context5.stop();
64135
+ return _context3.stop();
64939
64136
  }
64940
64137
  }
64941
- }, _callee5, this);
64138
+ }, _callee3, this);
64942
64139
  }));
64943
64140
 
64944
64141
  function listDiscoveryProviders() {
@@ -64956,47 +64153,47 @@ var ServiceProvider = /*#__PURE__*/function (_Base) {
64956
64153
  }, {
64957
64154
  key: "getUniquelyOwnedDiscoveryNodes",
64958
64155
  value: function () {
64959
- var _getUniquelyOwnedDiscoveryNodes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee7(_ref2) {
64960
- var quorumSize, _ref2$discoveryNodes, discoveryNodes, _ref2$filter, filter, _ref2$useWhitelist, useWhitelist, grouped, owners;
64156
+ var _getUniquelyOwnedDiscoveryNodes = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee5(_ref) {
64157
+ var quorumSize, _ref$discoveryNodes, discoveryNodes, _ref$filter, filter, _ref$useWhitelist, useWhitelist, grouped, owners;
64961
64158
 
64962
- return regeneratorRuntime.wrap(function _callee7$(_context7) {
64159
+ return regeneratorRuntime.wrap(function _callee5$(_context5) {
64963
64160
  while (1) {
64964
- switch (_context7.prev = _context7.next) {
64161
+ switch (_context5.prev = _context5.next) {
64965
64162
  case 0:
64966
- quorumSize = _ref2.quorumSize, _ref2$discoveryNodes = _ref2.discoveryNodes, discoveryNodes = _ref2$discoveryNodes === void 0 ? [] : _ref2$discoveryNodes, _ref2$filter = _ref2.filter, filter = _ref2$filter === void 0 ? /*#__PURE__*/function () {
64967
- var _ref3 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee6(_) {
64968
- return regeneratorRuntime.wrap(function _callee6$(_context6) {
64163
+ quorumSize = _ref.quorumSize, _ref$discoveryNodes = _ref.discoveryNodes, discoveryNodes = _ref$discoveryNodes === void 0 ? [] : _ref$discoveryNodes, _ref$filter = _ref.filter, filter = _ref$filter === void 0 ? /*#__PURE__*/function () {
64164
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/regeneratorRuntime.mark(function _callee4(_) {
64165
+ return regeneratorRuntime.wrap(function _callee4$(_context4) {
64969
64166
  while (1) {
64970
- switch (_context6.prev = _context6.next) {
64167
+ switch (_context4.prev = _context4.next) {
64971
64168
  case 0:
64972
- return _context6.abrupt("return", true);
64169
+ return _context4.abrupt("return", true);
64973
64170
 
64974
64171
  case 1:
64975
64172
  case "end":
64976
- return _context6.stop();
64173
+ return _context4.stop();
64977
64174
  }
64978
64175
  }
64979
- }, _callee6);
64176
+ }, _callee4);
64980
64177
  }));
64981
64178
 
64982
- return function (_x3) {
64983
- return _ref3.apply(this, arguments);
64179
+ return function (_x2) {
64180
+ return _ref2.apply(this, arguments);
64984
64181
  };
64985
- }() : _ref2$filter, _ref2$useWhitelist = _ref2.useWhitelist, useWhitelist = _ref2$useWhitelist === void 0 ? true : _ref2$useWhitelist;
64182
+ }() : _ref$filter, _ref$useWhitelist = _ref.useWhitelist, useWhitelist = _ref$useWhitelist === void 0 ? true : _ref$useWhitelist;
64986
64183
 
64987
64184
  if (!(!discoveryNodes || discoveryNodes.length === 0)) {
64988
- _context7.next = 5;
64185
+ _context5.next = 5;
64989
64186
  break;
64990
64187
  }
64991
64188
 
64992
- _context7.next = 4;
64189
+ _context5.next = 4;
64993
64190
  return this.discoveryProvider.serviceSelector.findAll({
64994
64191
  verbose: true,
64995
64192
  whitelist: useWhitelist ? undefined : null
64996
64193
  });
64997
64194
 
64998
64195
  case 4:
64999
- discoveryNodes = _context7.sent;
64196
+ discoveryNodes = _context5.sent;
65000
64197
 
65001
64198
  case 5:
65002
64199
  discoveryNodes.filter(filter); // Group nodes by owner
@@ -65014,7 +64211,7 @@ var ServiceProvider = /*#__PURE__*/function (_Base) {
65014
64211
  }, {});
65015
64212
 
65016
64213
  if (!(Object.keys(grouped).length < quorumSize)) {
65017
- _context7.next = 9;
64214
+ _context5.next = 9;
65018
64215
  break;
65019
64216
  }
65020
64217
 
@@ -65022,21 +64219,21 @@ var ServiceProvider = /*#__PURE__*/function (_Base) {
65022
64219
 
65023
64220
  case 9:
65024
64221
  // Select quorumSize owners from the groups
65025
- owners = _.sampleSize(Object.keys(grouped), quorumSize); // Select 1 node from each owner selected
64222
+ owners = lodash.sampleSize(Object.keys(grouped), quorumSize); // Select 1 node from each owner selected
65026
64223
 
65027
- return _context7.abrupt("return", owners.map(function (owner) {
65028
- return _.sampleSize(grouped[owner], 1)[0].endpoint;
64224
+ return _context5.abrupt("return", owners.map(function (owner) {
64225
+ return lodash.sampleSize(grouped[owner], 1)[0].endpoint;
65029
64226
  }));
65030
64227
 
65031
64228
  case 11:
65032
64229
  case "end":
65033
- return _context7.stop();
64230
+ return _context5.stop();
65034
64231
  }
65035
64232
  }
65036
- }, _callee7, this);
64233
+ }, _callee5, this);
65037
64234
  }));
65038
64235
 
65039
- function getUniquelyOwnedDiscoveryNodes(_x2) {
64236
+ function getUniquelyOwnedDiscoveryNodes(_x) {
65040
64237
  return _getUniquelyOwnedDiscoveryNodes.apply(this, arguments);
65041
64238
  }
65042
64239
 
@@ -67646,7 +66843,7 @@ var Users = /*#__PURE__*/function (_Base) {
67646
66843
  metadata[prop] = null;
67647
66844
  }
67648
66845
  });
67649
- return _.pick(metadata, USER_PROPS.concat('user_id'));
66846
+ return lodash.pick(metadata, USER_PROPS.concat('user_id'));
67650
66847
  }
67651
66848
  }, {
67652
66849
  key: "_generateUserId",