Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/dash-spv/lib/blockstore.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,4 @@ class BlockStore {
}
}


module.exports = BlockStore;
6 changes: 3 additions & 3 deletions packages/dash-spv/lib/consensus.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const MIN_TIMESTAMP_HEADERS = 11;
const MIN_DGW_HEADERS = 24;

function getMedianTimestamp(headers) {
const timestamps = headers.map(h => h.time);
const timestamps = headers.map((h) => h.time);
const median = (arr) => {
const mid = Math.floor(arr.length / 2);
const nums = [...arr].sort((a, b) => a - b);
Expand All @@ -22,7 +22,7 @@ function hasGreaterThanMedianTimestamp(newHeader, previousHeaders) {
const headerNormalised = utils.normalizeHeader(newHeader);
const normalizedLatestHeaders = previousHeaders.slice(
Math.max(previousHeaders.length - MIN_TIMESTAMP_HEADERS, 0),
).map(h => utils.normalizeHeader(h));
).map((h) => utils.normalizeHeader(h));
return getMedianTimestamp(normalizedLatestHeaders) < headerNormalised.time;
}

Expand All @@ -32,7 +32,7 @@ function isValidBlockHeader(newHeader, previousHeaders, network = 'mainnet') {
&& newHeader.validTimestamp()
&& hasGreaterThanMedianTimestamp(newHeader, previousHeaders)
&& hasValidTarget(
utils.getDgwBlock(newHeader), previousHeaders.map(h => utils.getDgwBlock(h)), network,
utils.getDgwBlock(newHeader), previousHeaders.map((h) => utils.getDgwBlock(h)), network,
);
}
return newHeader.validProofOfWork()
Expand Down
4 changes: 2 additions & 2 deletions packages/dash-spv/lib/merkleproofs.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ const merkleproofs = {
validateTxProofs: (merkleBlock, transactions) => {
let txToFilter = transactions.slice();
if (typeof transactions[0] === 'string') {
txToFilter = txToFilter.map(tx => DashUtil.toHash(tx).toString('hex'));
txToFilter = txToFilter.map((tx) => DashUtil.toHash(tx).toString('hex'));
}
return merkleBlock.validMerkleTree
&& txToFilter.filter(tx => merkleBlock.hasTransaction(tx)).length === transactions.length;
&& txToFilter.filter((tx) => merkleBlock.hasTransaction(tx)).length === transactions.length;
},
};

Expand Down
12 changes: 6 additions & 6 deletions packages/dash-spv/lib/spvchain.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const BlockStore = require('./blockstore');
const config = require('../config/config');
const Consensus = require('./consensus');
const utils = require('../lib/utils');
const utils = require('./utils');

const SpvChain = class {
constructor(chainType, confirms = 100, startBlock) {
Expand Down Expand Up @@ -130,9 +130,9 @@ const SpvChain = class {

/** @private */
isDuplicate(compareHash) {
return this.getAllBranches().map(branch => branch.map(node => node.hash))
.concat(this.orphanBlocks.map(orphan => orphan.hash))
.filter(hash => hash === compareHash).length > 0;
return this.getAllBranches().map((branch) => branch.map((node) => node.hash))
.concat(this.orphanBlocks.map((orphan) => orphan.hash))
.filter((hash) => hash === compareHash).length > 0;
}

/** @private */
Expand Down Expand Up @@ -254,7 +254,7 @@ const SpvChain = class {
return blockInDB;
}

return this.getLongestChain().filter(h => h.hash === hash)[0];
return this.getLongestChain().filter((h) => h.hash === hash)[0];
});
}

Expand Down Expand Up @@ -295,7 +295,7 @@ const SpvChain = class {
return true;
}
}
const normalizedHeaders = headers.map(h => utils.normalizeHeader(h));
const normalizedHeaders = headers.map((h) => utils.normalizeHeader(h));
const isOrphan = !SpvChain.isParentChild(normalizedHeaders[0], this.getTipHeader());

const allValid = normalizedHeaders.reduce(
Expand Down
2 changes: 1 addition & 1 deletion packages/dash-spv/test/data/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,4 +213,4 @@ const headers = [
},
];

module.exports = headers.map(h => utils.normalizeHeader(h));
module.exports = headers.map((h) => utils.normalizeHeader(h));
2 changes: 1 addition & 1 deletion packages/dashmate/src/commands/group/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class GroupStopCommand extends GroupBaseCommand {
try {
await tasks.run({
isVerbose,
isForce
isForce,
});
} catch (e) {
throw new MuteOneLineError(e);
Expand Down
4 changes: 2 additions & 2 deletions packages/dashmate/src/docker/DockerCompose.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,11 +374,11 @@ class DockerCompose {
throw new Error(`Update Docker to version ${DockerCompose.DOCKER_MIN_VERSION} or higher`);
}

let version
let version;

// Check docker compose
try {
({out: version} = await dockerCompose.version());
({ out: version } = await dockerCompose.version());
} catch (e) {
throw new Error('Docker Compose V2 is not available in your system');
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const Dash = require('dash');
const path = require('path');

let storageAdapter;

Expand Down