Move peer state updates from headers message into separate function
Summary:
Review hint:
git show --color-moved=dimmed-zebra --color-moved-ws=ignore-all-space
This is a partial backport of core#25454
https://github.com/bitcoin/bitcoin/pull/25454/commits/6d95cd3e7444ebaaabb64a76783ea3551530f1d7
Depends on D14909
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Differential Revision: https://reviews.bitcoinabc.org/D14910