@dashevo/dash-spv 1.1.7-1 → 1.1.7-4

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/lib/blockstore.js CHANGED
@@ -53,5 +53,4 @@ class BlockStore {
53
53
  }
54
54
  }
55
55
 
56
-
57
56
  module.exports = BlockStore;
package/lib/consensus.js CHANGED
@@ -6,7 +6,7 @@ const MIN_TIMESTAMP_HEADERS = 11;
6
6
  const MIN_DGW_HEADERS = 24;
7
7
 
8
8
  function getMedianTimestamp(headers) {
9
- const timestamps = headers.map(h => h.time);
9
+ const timestamps = headers.map((h) => h.time);
10
10
  const median = (arr) => {
11
11
  const mid = Math.floor(arr.length / 2);
12
12
  const nums = [...arr].sort((a, b) => a - b);
@@ -22,7 +22,7 @@ function hasGreaterThanMedianTimestamp(newHeader, previousHeaders) {
22
22
  const headerNormalised = utils.normalizeHeader(newHeader);
23
23
  const normalizedLatestHeaders = previousHeaders.slice(
24
24
  Math.max(previousHeaders.length - MIN_TIMESTAMP_HEADERS, 0),
25
- ).map(h => utils.normalizeHeader(h));
25
+ ).map((h) => utils.normalizeHeader(h));
26
26
  return getMedianTimestamp(normalizedLatestHeaders) < headerNormalised.time;
27
27
  }
28
28
 
@@ -32,7 +32,7 @@ function isValidBlockHeader(newHeader, previousHeaders, network = 'mainnet') {
32
32
  && newHeader.validTimestamp()
33
33
  && hasGreaterThanMedianTimestamp(newHeader, previousHeaders)
34
34
  && hasValidTarget(
35
- utils.getDgwBlock(newHeader), previousHeaders.map(h => utils.getDgwBlock(h)), network,
35
+ utils.getDgwBlock(newHeader), previousHeaders.map((h) => utils.getDgwBlock(h)), network,
36
36
  );
37
37
  }
38
38
  return newHeader.validProofOfWork()
@@ -11,10 +11,10 @@ const merkleproofs = {
11
11
  validateTxProofs: (merkleBlock, transactions) => {
12
12
  let txToFilter = transactions.slice();
13
13
  if (typeof transactions[0] === 'string') {
14
- txToFilter = txToFilter.map(tx => DashUtil.toHash(tx).toString('hex'));
14
+ txToFilter = txToFilter.map((tx) => DashUtil.toHash(tx).toString('hex'));
15
15
  }
16
16
  return merkleBlock.validMerkleTree
17
- && txToFilter.filter(tx => merkleBlock.hasTransaction(tx)).length === transactions.length;
17
+ && txToFilter.filter((tx) => merkleBlock.hasTransaction(tx)).length === transactions.length;
18
18
  },
19
19
  };
20
20
 
package/lib/spvchain.js CHANGED
@@ -1,7 +1,7 @@
1
1
  const BlockStore = require('./blockstore');
2
2
  const config = require('../config/config');
3
3
  const Consensus = require('./consensus');
4
- const utils = require('../lib/utils');
4
+ const utils = require('./utils');
5
5
 
6
6
  const SpvChain = class {
7
7
  constructor(chainType, confirms = 100, startBlock) {
@@ -130,9 +130,9 @@ const SpvChain = class {
130
130
 
131
131
  /** @private */
132
132
  isDuplicate(compareHash) {
133
- return this.getAllBranches().map(branch => branch.map(node => node.hash))
134
- .concat(this.orphanBlocks.map(orphan => orphan.hash))
135
- .filter(hash => hash === compareHash).length > 0;
133
+ return this.getAllBranches().map((branch) => branch.map((node) => node.hash))
134
+ .concat(this.orphanBlocks.map((orphan) => orphan.hash))
135
+ .filter((hash) => hash === compareHash).length > 0;
136
136
  }
137
137
 
138
138
  /** @private */
@@ -254,7 +254,7 @@ const SpvChain = class {
254
254
  return blockInDB;
255
255
  }
256
256
 
257
- return this.getLongestChain().filter(h => h.hash === hash)[0];
257
+ return this.getLongestChain().filter((h) => h.hash === hash)[0];
258
258
  });
259
259
  }
260
260
 
@@ -295,7 +295,7 @@ const SpvChain = class {
295
295
  return true;
296
296
  }
297
297
  }
298
- const normalizedHeaders = headers.map(h => utils.normalizeHeader(h));
298
+ const normalizedHeaders = headers.map((h) => utils.normalizeHeader(h));
299
299
  const isOrphan = !SpvChain.isParentChild(normalizedHeaders[0], this.getTipHeader());
300
300
 
301
301
  const allValid = normalizedHeaders.reduce(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dashevo/dash-spv",
3
- "version": "1.1.7-1",
3
+ "version": "1.1.7-4",
4
4
  "description": "Repository containing SPV functions used by @dashevo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -213,4 +213,4 @@ const headers = [
213
213
  },
214
214
  ];
215
215
 
216
- module.exports = headers.map(h => utils.normalizeHeader(h));
216
+ module.exports = headers.map((h) => utils.normalizeHeader(h));