From 30910de62d41fe51a8fa4147cbb3591643f64f2f Mon Sep 17 00:00:00 2001 From: Delweng Date: Fri, 22 Sep 2023 17:11:17 +0800 Subject: [PATCH] Update core/rawdb/freezer.go Co-authored-by: Martin Holst Swende --- core/rawdb/freezer.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/core/rawdb/freezer.go b/core/rawdb/freezer.go index 0cdec03a5b..b7824ddc0d 100644 --- a/core/rawdb/freezer.go +++ b/core/rawdb/freezer.go @@ -108,11 +108,9 @@ func NewFreezer(datadir string, namespace string, readonly bool, maxTableSize ui // Leveldb uses LOCK as the filelock filename. To prevent the // name collision, we use FLOCK as the lock name. lock := flock.New(flockFile) - tryLock := func() (bool, error) { - if readonly { - return lock.TryRLock() - } - return lock.TryLock() + tryLock := lock.TryLock + if readonly { + tryLock = lock.TryRLock } if locked, err := tryLock(); err != nil { return nil, err