HomePhabricator

Fix an unsigned issue in the availability score calculation

Description

Fix an unsigned issue in the availability score calculation

Summary: The number of votes and polls are stored as unsigned ints for the computation, causing an overflow when 2 * votes - polls is negative. This can happen if a node never responded any poll, and cause the score to turn high instead of going negative. The test case was checking the score response against a rise then fall, so it didn't check for negative values and missed the edge case.

Test Plan:

ninja all check

Reviewers: #bitcoin_abc, deadalnix

Reviewed By: #bitcoin_abc, deadalnix

Differential Revision: https://reviews.bitcoinabc.org/D10827

Details

Provenance
FabienAuthored on Jan 13 2022, 19:57
FabienPushed on Jan 13 2022, 21:20
Reviewer
Restricted Project
Differential Revision
D10827: Fix an unsigned issue in the availability score calculation
Parents
rABC40ddc93c7c96: Add an option to override the max addr sent in response to a getaddr message
Branches
Unknown
Tags
Unknown