Motivated by #11913 (review), this pull makes blockToJSON
and blockheaderToJSON
free of cs_main
locks.
Locking cs_main
was required to access chainActive
in order to check if the block was in the chain and to retrieve the next block index.
With the this approach, CBlockIndex::GetAncestor()
is used in a way to check if the block belongs to the specified chain tip and, at the same time, get the next block index.