From 6a9a2b5d0414fcbf75a73d9a1cb5df52634a35da Mon Sep 17 00:00:00 2001
From: Alex Vanin <alexey@nspcc.ru>
Date: Tue, 2 Feb 2021 20:39:41 +0300
Subject: [PATCH] [#365] settlement/basic: Remove TxTable from context

TxTable used twice in context to transfer assets to
and from banking account. There is no need to store
instance of table persistently.

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
---
 pkg/innerring/processors/settlement/basic/collect.go | 6 ++++--
 pkg/innerring/processors/settlement/basic/context.go | 2 --
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/pkg/innerring/processors/settlement/basic/collect.go b/pkg/innerring/processors/settlement/basic/collect.go
index e9dc61aca..f78446741 100644
--- a/pkg/innerring/processors/settlement/basic/collect.go
+++ b/pkg/innerring/processors/settlement/basic/collect.go
@@ -34,6 +34,8 @@ func (inc *IncomeSettlementContext) Collect() {
 		return
 	}
 
+	txTable := common.NewTransferTable()
+
 	for i := range cnrEstimations {
 		owner, err := inc.container.ContainerInfo(cnrEstimations[i].ContainerID)
 		if err != nil {
@@ -61,14 +63,14 @@ func (inc *IncomeSettlementContext) Collect() {
 			inc.distributeTable.Put(cnrNodes[i].PublicKey(), avg)
 		}
 
-		inc.txTable.Transfer(&common.TransferTx{
+		txTable.Transfer(&common.TransferTx{
 			From:   owner.Owner(),
 			To:     inc.bankOwner,
 			Amount: total,
 		})
 	}
 
-	common.TransferAssets(inc.exchange, inc.txTable)
+	common.TransferAssets(inc.exchange, txTable)
 }
 
 // avgEstimation returns estimation value for single container. Right now it
diff --git a/pkg/innerring/processors/settlement/basic/context.go b/pkg/innerring/processors/settlement/basic/context.go
index 599effb1a..23e5fa3d3 100644
--- a/pkg/innerring/processors/settlement/basic/context.go
+++ b/pkg/innerring/processors/settlement/basic/context.go
@@ -41,7 +41,6 @@ type (
 		exchange    common.Exchanger
 		accounts    common.AccountStorage
 
-		txTable   *common.TransferTable
 		bankOwner *owner.ID
 
 		// this table is not thread safe, make sure you use it with mu.Lock()
@@ -77,7 +76,6 @@ func NewIncomeSettlementContext(p *IncomeSettlementContextPrms) (*IncomeSettleme
 		placement:       p.Placement,
 		exchange:        p.Exchange,
 		accounts:        p.Accounts,
-		txTable:         common.NewTransferTable(),
 		bankOwner:       bankingAccount,
 		distributeTable: NewNodeSizeTable(),
 	}, nil