Moves the logic to prevent running inactivity checks until the peer has been connected for -peertimeout time into its own function. This will be reused by net_processing later.
Partial backport of core#20721:
https://github.com/bitcoin/bitcoin/pull/20721/commits/1a07600b4b0d08cffc7cd5c58af33fcd1ede558e
Depends on D10873.
Ref T1696.