Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: u64->i64->u64 conversion; chain split height as u64 #3442

Merged
merged 8 commits into from
Oct 11, 2021

Conversation

Impala123
Copy link
Contributor

Description

removing an unnecessary conversion and using u64 for chain height

How Has This Been Tested?

rust build & test

@@ -326,15 +326,15 @@ impl tari_rpc::base_node_server::BaseNode for BaseNodeGrpcServer {

let headers: Vec<u64> = if request.from_height != 0 {
match sorting {
Sorting::Desc => ((cmp::max(0, request.from_height as i64 - num_headers as i64 + 1) as u64)..=
Sorting::Desc => (cmp::max(0, request.from_height - num_headers + 1)..=
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there not a chance for an underflow here?

Copy link
Contributor

@delta1 delta1 Oct 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs a covering test, even if this logic is moved into a function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this then be

let headers: Vec<u64> = if request.from_height >= num_headers {

num_headers is forced to be between 10 and 10_000
Means that from_height being 0 would go to the else

Or is it more desirable to check the underflow flag with overflowing_sub() ?

@delta1
Copy link
Contributor

delta1 commented Oct 10, 2021

Seems you need to run cargo fmt

@aviator-app aviator-app bot merged commit 43b2033 into tari-project:development Oct 11, 2021
sdbondi added a commit to sdbondi/tari that referenced this pull request Oct 12, 2021
* development:
  fix: fix confusing names in get_balance functions (tari-project#3447)
  feat: add sql query to obtain balance (tari-project#3446)
  fix: u64->i64->u64 conversion; chain split height as u64 (tari-project#3442)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants