Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
addrmgr: set min value and optimize address chance
This updates the (*KnownAddress).chance method in the following ways: 1. Apply a lower limit to the return value. Using 0.01 as this minimum prevents tiny chance values from causing excessive iterations in (*AddrManager).GetAddress, currently the only caller. 2. Replace an inefficient loop with a single math.Pow. These changes are mitigations to excessive CPU use in the GetAddress method that manifest when the number of attempts for a KnownAddress becomes large. However, this method and much of addrmgr should be rewritten in the future since there are some ad hoc and questionable approaches to candidate address selection.
- Loading branch information