This is a bugfix follow-up to #16248 and #19191 that was noticed in #21506. Both v0.21 and master are affected.
Since #19191, noban is a multi-flag that implies download, so the conditional in CConnman::Bind()
using a bitwise AND on noban will return the same result for both the noban status and the download status. This means that download peers are incorrectly not being added to local addresses because they are mistakenly seen as noban peers.
The second commit adds unit test coverage to illustrate and test the noban/download relationship and the NetPermissions
operations involving them.
The final commit adds documentation and disallows calling NetPermissions::ClearFlag()
with any second param other than NetPermissionFlags
“implicit” – per current usage in the codebase – because ClearFlag()
should not be called with any second param that is a subflag of a multiflag, e.g. “relay” or “download,” as that would leave the result in an invalid state corresponding to none of the existing NetPermissionFlags. Thanks to Vasil Dimov for noticing this.