capitalisk-dex 17.2.0 → 17.2.2

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.
@@ -16,6 +16,7 @@ module.exports = {
16
16
  orderBookSnapshotBackupDirPath: 'dex-snapshot-backups',
17
17
  orderBookSnapshotBackupMaxCount: 50,
18
18
  baseChain: 'lsk',
19
+ apiIsPublic: true,
19
20
  apiDefaultPageLimit: 100,
20
21
  apiMaxPageLimit: 200,
21
22
  apiMaxFilterFields: 10,
package/index.js CHANGED
@@ -459,7 +459,7 @@ module.exports = class CapitaliskDEXModule {
459
459
  get actions() {
460
460
  return {
461
461
  getStatus: {
462
- isPublic: true,
462
+ isPublic: this.options.apiIsPublic,
463
463
  handler: () => {
464
464
  return {
465
465
  version: CapitaliskDEXModule.info.version,
@@ -476,7 +476,7 @@ module.exports = class CapitaliskDEXModule {
476
476
  }
477
477
  },
478
478
  getMarket: {
479
- isPublic: true,
479
+ isPublic: this.options.apiIsPublic,
480
480
  handler: () => {
481
481
  return {
482
482
  baseSymbol: this.baseChainSymbol,
@@ -485,7 +485,7 @@ module.exports = class CapitaliskDEXModule {
485
485
  }
486
486
  },
487
487
  getBids: {
488
- isPublic: true,
488
+ isPublic: this.options.apiIsPublic,
489
489
  handler: (action) => {
490
490
  let query = {...action.params};
491
491
  // Optimization.
@@ -511,7 +511,7 @@ module.exports = class CapitaliskDEXModule {
511
511
  }
512
512
  },
513
513
  getAsks: {
514
- isPublic: true,
514
+ isPublic: this.options.apiIsPublic,
515
515
  handler: (action) => {
516
516
  let query = {...action.params};
517
517
  // Optimization.
@@ -537,7 +537,7 @@ module.exports = class CapitaliskDEXModule {
537
537
  }
538
538
  },
539
539
  getOrders: {
540
- isPublic: true,
540
+ isPublic: this.options.apiIsPublic,
541
541
  handler: (action) => {
542
542
  let query = {...action.params};
543
543
  let orderIterator;
@@ -561,7 +561,7 @@ module.exports = class CapitaliskDEXModule {
561
561
  }
562
562
  },
563
563
  getOrderBook: {
564
- isPublic: true,
564
+ isPublic: this.options.apiIsPublic,
565
565
  handler: (action) => {
566
566
  let query = {...action.params};
567
567
  let { depth } = query;
@@ -633,7 +633,7 @@ module.exports = class CapitaliskDEXModule {
633
633
  }
634
634
  },
635
635
  getRecentPrices: {
636
- isPublic: true,
636
+ isPublic: this.options.apiIsPublic,
637
637
  handler: (action) => {
638
638
  let priceEntryIterator = this.recentPricesSkipList.findEntriesFromMax();
639
639
  let priceGenerator = this._getValuesGenerator(priceEntryIterator);
@@ -644,7 +644,7 @@ module.exports = class CapitaliskDEXModule {
644
644
  }
645
645
  },
646
646
  getPendingTransfers: {
647
- isPublic: true,
647
+ isPublic: this.options.apiIsPublic,
648
648
  handler: (action) => {
649
649
  let transferList = this._execQueryAgainstIterator(
650
650
  action.params,
@@ -674,7 +674,7 @@ module.exports = class CapitaliskDEXModule {
674
674
  }
675
675
  },
676
676
  getRecentTransfers: {
677
- isPublic: true,
677
+ isPublic: this.options.apiIsPublic,
678
678
  handler: (action) => {
679
679
  let recentTransfersIterator = this.recentTransfersSkipList.findEntriesFromMax();
680
680
  let transferGenerator = this._getNestedObjectValuesGenerator(recentTransfersIterator);
@@ -2036,10 +2036,27 @@ module.exports = class CapitaliskDEXModule {
2036
2036
  let currentBlock = await this._getBlockAtHeight(chainSymbol, fromHeight);
2037
2037
 
2038
2038
  while (currentBlock) {
2039
- let blocksToProcess = await this._getBlocksBetweenHeights(chainSymbol, currentBlock.height, toHeight, readMaxBlocks, false);
2040
2039
  this.logger.info(
2041
2040
  `Chain ${chainSymbol}: Processing blocks between heights ${currentBlock.height} and ${toHeight} as part of dividend calculation`
2042
2041
  );
2042
+ let blocksToProcess;
2043
+ try {
2044
+ blocksToProcess = await this._getBlocksBetweenHeights(chainSymbol, currentBlock.height, toHeight, readMaxBlocks, false);
2045
+ } catch (error) {
2046
+ this.logger.error(
2047
+ `Chain ${
2048
+ chainSymbol
2049
+ }: Failed to fetch blocks between heights ${
2050
+ currentBlock.height
2051
+ } and ${
2052
+ toHeight
2053
+ } during dividend calculation because of error: ${
2054
+ error.message
2055
+ }`
2056
+ );
2057
+ await wait(this.options.readBlocksInterval);
2058
+ continue;
2059
+ }
2043
2060
  for (let block of blocksToProcess) {
2044
2061
  if (block.numberOfTransactions === 0) {
2045
2062
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "capitalisk-dex",
3
- "version": "17.2.0",
3
+ "version": "17.2.2",
4
4
  "description": "Decentralized exchange module.",
5
5
  "main": "index.js",
6
6
  "scripts": {