From de8f697b47d5b6df99a24d474f3f16fc4bbf7e6b Mon Sep 17 00:00:00 2001 From: hopeyen Date: Tue, 17 Dec 2024 13:16:23 -0800 Subject: [PATCH] refactor: locks --- core/meterer/onchain_state.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/core/meterer/onchain_state.go b/core/meterer/onchain_state.go index 8546a8bb10..951d60b974 100644 --- a/core/meterer/onchain_state.go +++ b/core/meterer/onchain_state.go @@ -153,7 +153,9 @@ func (pcs *OnchainPaymentState) GetReservedPaymentByAccount(ctx context.Context, if err != nil { return nil, err } + pcs.ReservationsLock.Lock() (pcs.ReservedPayments)[accountID] = res + pcs.ReservationsLock.Unlock() return res, nil } @@ -172,7 +174,10 @@ func (pcs *OnchainPaymentState) GetOnDemandPaymentByAccount(ctx context.Context, if err != nil { return nil, err } + + pcs.OnDemandLocks.Lock() (pcs.OnDemandPayments)[accountID] = res + pcs.OnDemandLocks.Unlock() return res, nil }