HarukaMa / aleo-pool-server

GNU Affero General Public License v3.0
77 stars 79 forks source link

fix panic of blocks_mined in accounting.rs #3

Closed SatoKentaNayoro closed 2 years ago

SatoKentaNayoro commented 2 years ago

latest_block_height - Testnet2::ALEO_MAXIMUM_FORK_DEPTH >= height will panic when the result of (latest_block_height - Testnet2::ALEO_MAXIMUM_FORK_DEPTH) < 0,

HarukaMa commented 2 years ago

Oh, then it's underflowing when the chain is less than 4096 blocks high?

If so, please use saturating_sub instead of changing the types, as it doesn't really make sense to use signed types on block heights.

Good catch though.

SatoKentaNayoro commented 2 years ago

Oh, then it's underflowing when the chain is less than 4096 blocks high?

If so, please use saturating_sub instead of changing the types, as it doesn't really make sense to use signed types on block heights.

Good catch though.

I'm new to Rust and haven't used Saturating_sub yet, thanks for reminding me, I'll fix it in the morning

SatoKentaNayoro commented 2 years ago

I've used saturating_sub instead of changing the types, and apis should will work fine when the chain is less than 4096 blocks high now.