Use the newly stabilized div_ceil

Sets a msrv of 1.73.0.
This commit is contained in:
Luke Parker
2023-10-05 14:27:59 -04:00
parent 4ee65ed243
commit 9cdca1d3d6
4 changed files with 4 additions and 13 deletions

View File

@@ -197,7 +197,7 @@ impl SignableTransaction {
// multiplied by DEFAULT_BYTES_PER_SIGOP (20)
// We only use 1 signature per input, and our inputs have a weight exceeding 20
// Accordingly, our inputs' weight will always be greater than the cost of the signature ops
let vsize = (weight + 3) / 4;
let vsize = weight.div_ceil(4);
// Technically, if there isn't change, this TX may still pay enough of a fee to pass the
// minimum fee. Such edge cases aren't worth programming when they go against intent, as the
// specified fee rate is too low to be valid

View File

@@ -50,8 +50,7 @@ fn birthday_decode(birthday: u16) -> u64 {
const SECRET_BITS: usize = 150;
const BITS_PER_BYTE: usize = 8;
// ceildiv of SECRET_BITS by BITS_PER_BYTE
const SECRET_SIZE: usize = (SECRET_BITS + BITS_PER_BYTE - 1) / BITS_PER_BYTE; // 19
const SECRET_SIZE: usize = SECRET_BITS.div_ceil(BITS_PER_BYTE); // 19
const CLEAR_BITS: usize = (SECRET_SIZE * BITS_PER_BYTE) - SECRET_BITS; // 2
// Polyseed calls this CLEAR_MASK and has a very complicated formula for this fundamental