[NOD-1095] RLock the dagLock in SelectedTipHeader. (#893)

This commit is contained in:
stasatdaglabs 2020-08-24 11:31:12 +03:00 committed by GitHub
parent 83e7c9e8e4
commit 5fd164bf66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -211,6 +211,8 @@ func (dag *BlockDAG) selectedTip() *blockNode {
//
// This function is safe for concurrent access.
func (dag *BlockDAG) SelectedTipHeader() *appmessage.BlockHeader {
dag.dagLock.RLock()
defer dag.dagLock.RUnlock()
selectedTip := dag.selectedTip()
if selectedTip == nil {
return nil