Commit 518b858
committed
addrman, net: filter during selection via AddrPolicy to avoid underfill
Add AddrMan::AddrPolicy, a predicate returning true to exclude an address
during selection. This allows callers to apply custom filtering directly in
AddrMan rather than post-processing results.
Use the new policy in CConnman::GetAddressesUnsafe to exclude banned and
discouraged peers while filling address requests. This fixes underfilled
results observed when banned peers were removed after selection, causing
P2P responses from `GETADDR` to return fewer entries than requested.
Also log the number of filtered entries for debugging and diagnostics.1 parent a14e7b9 commit 518b858
File tree
5 files changed
+57
-18
lines changed- src
- test
5 files changed
+57
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
809 | 809 | | |
810 | 810 | | |
811 | 811 | | |
812 | | - | |
| 812 | + | |
813 | 813 | | |
814 | 814 | | |
815 | 815 | | |
| |||
827 | 827 | | |
828 | 828 | | |
829 | 829 | | |
| 830 | + | |
830 | 831 | | |
831 | 832 | | |
832 | 833 | | |
| |||
839 | 840 | | |
840 | 841 | | |
841 | 842 | | |
842 | | - | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
843 | 847 | | |
844 | 848 | | |
845 | | - | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
846 | 859 | | |
847 | 860 | | |
848 | 861 | | |
849 | | - | |
| 862 | + | |
850 | 863 | | |
851 | 864 | | |
852 | 865 | | |
| |||
1226 | 1239 | | |
1227 | 1240 | | |
1228 | 1241 | | |
1229 | | - | |
| 1242 | + | |
1230 | 1243 | | |
1231 | 1244 | | |
1232 | 1245 | | |
1233 | | - | |
| 1246 | + | |
1234 | 1247 | | |
1235 | 1248 | | |
1236 | 1249 | | |
| |||
1329 | 1342 | | |
1330 | 1343 | | |
1331 | 1344 | | |
1332 | | - | |
| 1345 | + | |
1333 | 1346 | | |
1334 | | - | |
| 1347 | + | |
1335 | 1348 | | |
1336 | 1349 | | |
1337 | 1350 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
91 | 92 | | |
92 | 93 | | |
93 | 94 | | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
94 | 101 | | |
95 | 102 | | |
96 | 103 | | |
| |||
169 | 176 | | |
170 | 177 | | |
171 | 178 | | |
| 179 | + | |
172 | 180 | | |
173 | 181 | | |
174 | 182 | | |
175 | | - | |
| 183 | + | |
176 | 184 | | |
177 | 185 | | |
178 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
135 | 135 | | |
136 | 136 | | |
137 | 137 | | |
138 | | - | |
| 138 | + | |
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
| |||
267 | 267 | | |
268 | 268 | | |
269 | 269 | | |
270 | | - | |
| 270 | + | |
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3507 | 3507 | | |
3508 | 3508 | | |
3509 | 3509 | | |
3510 | | - | |
3511 | | - | |
3512 | | - | |
3513 | | - | |
3514 | | - | |
3515 | | - | |
3516 | | - | |
| 3510 | + | |
| 3511 | + | |
| 3512 | + | |
| 3513 | + | |
3517 | 3514 | | |
3518 | 3515 | | |
3519 | 3516 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
407 | 407 | | |
408 | 408 | | |
409 | 409 | | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
410 | 431 | | |
411 | 432 | | |
412 | 433 | | |
| |||
0 commit comments