[avalanche] Turn the vote registration logic into a generic lambda
Summary:
This is a preliminary step before being able to register a vote on a proof.
The vote registration logic will be the exact same between blocks and proofs, but works on different types. Using a generic lambda makes it possible to share the code snippet for any types with a compatible interface.
There is no change in behavior.
Ref T1854.
Test Plan:
ninja all check-all
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Maniphest Tasks: T1854
Differential Revision: https://reviews.bitcoinabc.org/D10253