mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-19 18:32:23 +00:00
core/state/snapshot: only acquire read-lock when iterating
This commit is contained in:
parent
4c8dc88a48
commit
4579ef94d8
1 changed files with 6 additions and 6 deletions
|
|
@ -666,8 +666,8 @@ func diffToDisk(bottom *diffLayer) *diskLayer {
|
||||||
|
|
||||||
// Release releases resources
|
// Release releases resources
|
||||||
func (t *Tree) Release() {
|
func (t *Tree) Release() {
|
||||||
t.lock.Lock()
|
t.lock.RLock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
if dl := t.disklayer(); dl != nil {
|
if dl := t.disklayer(); dl != nil {
|
||||||
dl.Release()
|
dl.Release()
|
||||||
|
|
@ -851,8 +851,8 @@ func (t *Tree) diskRoot() common.Hash {
|
||||||
// generating is an internal helper function which reports whether the snapshot
|
// generating is an internal helper function which reports whether the snapshot
|
||||||
// is still under the construction.
|
// is still under the construction.
|
||||||
func (t *Tree) generating() (bool, error) {
|
func (t *Tree) generating() (bool, error) {
|
||||||
t.lock.Lock()
|
t.lock.RLock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
layer := t.disklayer()
|
layer := t.disklayer()
|
||||||
if layer == nil {
|
if layer == nil {
|
||||||
|
|
@ -865,8 +865,8 @@ func (t *Tree) generating() (bool, error) {
|
||||||
|
|
||||||
// DiskRoot is a external helper function to return the disk layer root.
|
// DiskRoot is a external helper function to return the disk layer root.
|
||||||
func (t *Tree) DiskRoot() common.Hash {
|
func (t *Tree) DiskRoot() common.Hash {
|
||||||
t.lock.Lock()
|
t.lock.RLock()
|
||||||
defer t.lock.Unlock()
|
defer t.lock.RUnlock()
|
||||||
|
|
||||||
return t.diskRoot()
|
return t.diskRoot()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue