Skip to content

Commit

Permalink
add mutex for baseNode
Browse files Browse the repository at this point in the history
  • Loading branch information
BeniaminDrasovean committed Dec 16, 2024
1 parent 4d5f3e2 commit 354812c
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions trie/baseNode.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,16 @@ type baseNode struct {
}

func (bn *baseNode) getHash() []byte {
//TODO add mutex protection for all methods

bn.mutex.RLock()
defer bn.mutex.RUnlock()

return bn.hash
}

func (bn *baseNode) setGivenHash(hash []byte) {
bn.mutex.Lock()
defer bn.mutex.Unlock()

bn.hash = hash
}

Expand All @@ -36,6 +37,9 @@ func (bn *baseNode) isDirty() bool {
}

func (bn *baseNode) setDirty(dirty bool) {
bn.mutex.Lock()
defer bn.mutex.Unlock()

bn.dirty = dirty
}

Expand Down

0 comments on commit 354812c

Please sign in to comment.