refactor: Rewrite InsertBlockIndex and AddToBlockIndex with try_emplace
Summary:
Credit to ajtowns for this suggestion, thanks!
This is a partial backport of core#24050
https://github.com/bitcoin/bitcoin/pull/24050/commits/dd79dad17545424d145e846026518d70da594380
https://github.com/bitcoin/bitcoin/pull/24050/commits/6c23c415613d8b847e6f6a2f872be893da9f4384
Depends on D12992
Test Plan: ninja all check-all
Reviewers: #bitcoin_abc, Fabien
Reviewed By: #bitcoin_abc, Fabien
Subscribers: Fabien
Differential Revision: https://reviews.bitcoinabc.org/D12993