Skip to content

Commit

Permalink
fix: regtest no quorums bug (#163)
Browse files Browse the repository at this point in the history
* noop if no quorums (regtest)

* bump version

* update package lock

* switch on network name instead of object
  • Loading branch information
Cofresi authored Jun 26, 2020
1 parent c0fdf57 commit c1570bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 14 deletions.
25 changes: 13 additions & 12 deletions lib/deterministicmnlist/SimplifiedMNList.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,16 @@ SimplifiedMNList.prototype.applyDiff = function applyDiff(simplifiedMNListDiff)
this.addAndMaybeRemoveQuorums(diff.newQuorums);
this.lastDiffMerkleRootQuorums = diff.merkleRootQuorums || constants.NULL_HASH;

// we cannot verify the quorum merkle root for DashCore vers. < 0.16
if (this.quorumList[0].isOutdatedRPC) {
this.merkleRootQuorums = diff.merkleRootQuorums;
return
}

this.merkleRootQuorums = this.calculateMerkleRootQuorums();
if (this.lastDiffMerkleRootQuorums !== this.merkleRootQuorums) {
throw new Error("Quorum merkle root from the diff doesn't match calculated merkle root after diff is applied");
if (this.quorumList.length > 0) {
// we cannot verify the quorum merkle root for DashCore vers. < 0.16
if (this.quorumList[0].isOutdatedRPC) {
this.merkleRootQuorums = diff.merkleRootQuorums;
return
}
this.merkleRootQuorums = this.calculateMerkleRootQuorums();
if (this.lastDiffMerkleRootQuorums !== this.merkleRootQuorums) {
throw new Error("Quorum merkle root from the diff doesn't match calculated merkle root after diff is applied");
}
}
}
};
Expand Down Expand Up @@ -271,13 +272,13 @@ SimplifiedMNList.prototype.getValidMasternodesList = function getValidMasternode
*/
SimplifiedMNList.prototype.getLLMQTypes = function getLLMQTypes() {
var llmqTypes = [];
switch (this.network) {
case Networks.livenet:
switch (this.network.name) {
case Networks.livenet.name:
llmqTypes = [constants.LLMQ_TYPES.LLMQ_TYPE_50_60,
constants.LLMQ_TYPES.LLMQ_TYPE_400_60,
constants.LLMQ_TYPES.LLMQ_TYPE_400_85];
return llmqTypes;
case Networks.testnet:
case Networks.testnet.name:
// TODO: add proper devnet identifier to networks.js
// maybe through existing 'customnet' functionality
if (this.mnList.length > 100) {
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dashevo/dashcore-lib",
"version": "0.18.8",
"version": "0.18.9",
"description": "A pure and powerful JavaScript Dash library.",
"author": "Dash Core Group, Inc. <dev@dash.org>",
"main": "index.js",
Expand Down

0 comments on commit c1570bd

Please sign in to comment.