mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-12-22 19:08:00 +01:00
Use IntRange for Trustworthiness range check
This commit is contained in:
parent
e57e74163c
commit
39c5d12096
1 changed files with 5 additions and 3 deletions
|
@ -62,11 +62,13 @@ class Trustworthiness(amount: Int, depth: Int) {
|
|||
fun canIntroduce(other: Trustworthiness) = canIntroduce(other.depth)
|
||||
|
||||
companion object {
|
||||
|
||||
const val THRESHOLD_FULLY_CONVINCED = 120 // greater or equal is fully trusted
|
||||
const val MARGINALLY_CONVINCED = 60 // default value for marginally convinced
|
||||
const val NOT_TRUSTED = 0 // 0 is not trusted
|
||||
|
||||
@JvmStatic
|
||||
private val validRange = 0..255
|
||||
|
||||
/**
|
||||
* This means that we are fully convinced of the trustworthiness of the key.
|
||||
*
|
||||
|
@ -94,7 +96,7 @@ class Trustworthiness(amount: Int, depth: Int) {
|
|||
|
||||
@JvmStatic
|
||||
private fun capAmount(amount: Int): Int {
|
||||
if (amount !in 0..255) {
|
||||
if (amount !in validRange) {
|
||||
throw IllegalArgumentException("Trust amount MUST be a value between 0 and 255")
|
||||
}
|
||||
return amount
|
||||
|
@ -102,7 +104,7 @@ class Trustworthiness(amount: Int, depth: Int) {
|
|||
|
||||
@JvmStatic
|
||||
private fun capDepth(depth: Int): Int {
|
||||
if (depth !in 0..255) {
|
||||
if (depth !in validRange) {
|
||||
throw IllegalArgumentException("Trust depth MUST be a value between 0 and 255")
|
||||
}
|
||||
return depth
|
||||
|
|
Loading…
Reference in a new issue