Skip to content

Commit

Permalink
feat: add validator quorum type (#200)
Browse files Browse the repository at this point in the history
* add LLMQ_TYPE_100_67 constant

* add getValidatorLLMQType

* add missing typings

* chore: bump version

* chore: update package-lock.json
  • Loading branch information
Cofresi authored Dec 9, 2020
1 parent 2079183 commit e09348a
Show file tree
Hide file tree
Showing 5 changed files with 182 additions and 159 deletions.
2 changes: 2 additions & 0 deletions lib/constants/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ module.exports = {
// 400 members, 240 (60%) threshold, one every 12 hours (288 blocks)
LLMQ_TYPE_400_85: 3,
// 400 members, 340 (85%) threshold, one every 24 hours (576 blocks)
LLMQ_TYPE_100_67: 4,
// 100 members, 67 (67%) threshold, one every 24 hours (576 blocks)
LLMQ_TYPE_LLMQ_TEST: 100,
// 3 members, 2 (66%) threshold, one per hour (24 blocks)
// Params might differ when -llmqtestparams is used
Expand Down
26 changes: 26 additions & 0 deletions lib/deterministicmnlist/SimplifiedMNList.js
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,32 @@ SimplifiedMNList.prototype.getChainlockLLMQType = function getChainlockLLMQType(
}
};

/**
* @return {constants.LLMQ_TYPES}
*/
SimplifiedMNList.prototype.getValidatorLLMQType = function getValidatorLLMQType() {
if (!this.network) {
throw new Error('Network is not set');
}

switch (this.network.name) {
case Networks.livenet.name:
return constants.LLMQ_TYPES.LLMQ_TYPE_100_67;
case Networks.testnet.name:
if (this.mnList.length > 100) {
return constants.LLMQ_TYPES.LLMQ_TYPE_100_67;
}
// regtest
if (Networks.testnet.regtestEnabled === true) {
return constants.LLMQ_TYPES.LLMQ_TYPE_LLMQ_TEST;
}
// devnet
return constants.LLMQ_TYPES.LLMQ_TYPE_LLMQ_DEVNET;
default:
throw new Error('Unknown network');
}
};

/**
* @return {constants.LLMQ_TYPES}
*/
Expand Down
Loading

0 comments on commit e09348a

Please sign in to comment.