[refactor] refactor FinalizeBlockAndInvalidate
Summary:
Upcoming Core PR15971 requires InvalidateBlock to not hold cs_main lock. Currently the function FinalizeBlockAndInvalidate does both things, requires cs_main to be locked and has only one callsite (FinalizeBlock RPC method)
This diff extracts the RPC method exclusive functionality and refactors FinalizeBlockAndInvalidate to FinalizeBlock, requiring cs_main to be held while allowing for the upcoming diff to move the InvalidateBlock call outside the scope of the lock.
Test Plan:
ninja check-all
Reviewers: #bitcoin_abc, deadalnix
Reviewed By: #bitcoin_abc, deadalnix
Subscribers: deadalnix
Differential Revision: https://reviews.bitcoinabc.org/D6861