From cc08895e96f7bd800b4203902f16e170d44acc10 Mon Sep 17 00:00:00 2001 From: Mark Holt Date: Tue, 28 May 2024 10:09:51 +0100 Subject: [PATCH] re-correct lock usage --- polygon/bor/finality/whitelist/milestone.go | 3 +-- polygon/bor/finality/whitelist/service_test.go | 6 +----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/polygon/bor/finality/whitelist/milestone.go b/polygon/bor/finality/whitelist/milestone.go index 3aad36036e4..a79c712358e 100644 --- a/polygon/bor/finality/whitelist/milestone.go +++ b/polygon/bor/finality/whitelist/milestone.go @@ -216,8 +216,7 @@ func (m *milestone) GetMilestoneIDsList() []string { func (m *milestone) purgeMilestoneIDsList() { // try is used here as the finality lock is preserved over calls - so the lock state // is not clearly defined in the local code - this likely needs to be revised - if !m.finality.TryLock() { - m.finality.Lock() + if m.finality.TryLock() { defer m.finality.Unlock() } diff --git a/polygon/bor/finality/whitelist/service_test.go b/polygon/bor/finality/whitelist/service_test.go index 62fe3651dea..4e0de45b663 100644 --- a/polygon/bor/finality/whitelist/service_test.go +++ b/polygon/bor/finality/whitelist/service_test.go @@ -548,11 +548,7 @@ func TestPropertyBasedTestingMilestone(t *testing.T) { } fitlerFn := func(i uint64) bool { - if i <= uint64(1000) { - return true - } - - return false + return i <= uint64(1000) } var (