From 9cd8f7cea01241035ee1c877d68c4a8805bfdb56 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Mon, 20 Mar 2023 20:36:07 +0300 Subject: [PATCH] [#152] IR: Process empty basic incomes If network is not configured for basic income earnings, do not distribute GAS by the Alphabet nodes. Signed-off-by: Pavel Karpy --- pkg/innerring/processors/settlement/basic/collect.go | 5 +++++ pkg/innerring/processors/settlement/basic/context.go | 2 ++ pkg/innerring/processors/settlement/basic/distribute.go | 4 ++++ 3 files changed, 11 insertions(+) diff --git a/pkg/innerring/processors/settlement/basic/collect.go b/pkg/innerring/processors/settlement/basic/collect.go index 72f4eb8dd..ee7354c4f 100644 --- a/pkg/innerring/processors/settlement/basic/collect.go +++ b/pkg/innerring/processors/settlement/basic/collect.go @@ -26,6 +26,11 @@ func (inc *IncomeSettlementContext) Collect() { return } + if cachedRate == 0 { + inc.noop = true + return + } + cnrEstimations, err := inc.estimations.Estimations(inc.epoch) if err != nil { inc.log.Error("can't fetch container size estimations", diff --git a/pkg/innerring/processors/settlement/basic/context.go b/pkg/innerring/processors/settlement/basic/context.go index a605c053b..59bedf2e4 100644 --- a/pkg/innerring/processors/settlement/basic/context.go +++ b/pkg/innerring/processors/settlement/basic/context.go @@ -28,6 +28,8 @@ type ( IncomeSettlementContext struct { mu sync.Mutex // lock to prevent collection and distribution in the same time + noop bool + log *logger.Logger epoch uint64 diff --git a/pkg/innerring/processors/settlement/basic/distribute.go b/pkg/innerring/processors/settlement/basic/distribute.go index a2baa36af..e085f1e22 100644 --- a/pkg/innerring/processors/settlement/basic/distribute.go +++ b/pkg/innerring/processors/settlement/basic/distribute.go @@ -12,6 +12,10 @@ func (inc *IncomeSettlementContext) Distribute() { inc.mu.Lock() defer inc.mu.Unlock() + if inc.noop { + return + } + txTable := common.NewTransferTable() bankBalance, err := inc.balances.Balance(inc.bankOwner)