Improve Version to cap parts at 16-bits rather than masking them

This commit is contained in:
bemusementpark
2024-08-03 21:52:01 +09:30
parent 6e1ed8cc11
commit 5417660996
2 changed files with 5 additions and 6 deletions

View File

@@ -64,7 +64,7 @@ class Snode(val address: String, val port: Int, val publicKeySet: KeySet?, val v
private const val MASK = 0xFFFFUL
private fun Sequence<ULong>.foldToVersionAsULong() = take(4).foldIndexed(0UL) { i, acc, it ->
it and MASK shl (3 - i) * MASK_BITS or acc
it.coerceAtMost(MASK) shl (3 - i) * MASK_BITS or acc
}
}