Are you sure these are protected by cs_main, is it?
The members’ write process, not the read. If the read would be protected by cs_main
, this PR wouldn’t make any sense :p.
The two places are: the CBlockIndex
creation time and CBlockIndex
pruning time.
Still, those cs_main
locks can also be removed in a follow-up PR. I haven’t removed them here because they require further changes.
Not sure if I’m understanding your concern here. You are thinking on a race in-between GetFileNum
and GetDataPos
?
Because, if that is the concern, the error that could arise from it is harmless. The read block call would just return false, and callers would continue. But, to not even have to think about such error, we could just call GetFilePos()
instead of the two getters.
I agree with you that a new struct should just be nFile and nDataPos (or nPos). This struct can be used for either block data or rev data.
There is already a method for that: CBlockIndex::GetFilePos
.