forked from TrueCloudLab/frostfs-node
[#365] Provide distribute income event in settlement processor
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
8e741a277d
commit
d77d49bd2a
2 changed files with 39 additions and 0 deletions
|
@ -85,3 +85,41 @@ func (p *Processor) HandleIncomeCollectionEvent(e event.Event) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *Processor) HandleIncomeDistributionEvent(e event.Event) {
|
||||||
|
ev := e.(BasicIncomeDistributeEvent)
|
||||||
|
epoch := ev.Epoch()
|
||||||
|
|
||||||
|
if !p.state.IsActive() {
|
||||||
|
p.log.Info("passive mode, ignore income distribution event")
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
p.log.Info("start basic income distribution",
|
||||||
|
zap.Uint64("epoch", epoch))
|
||||||
|
|
||||||
|
p.contextMu.Lock()
|
||||||
|
defer p.contextMu.Unlock()
|
||||||
|
|
||||||
|
incomeCtx, ok := p.incomeContexts[epoch]
|
||||||
|
delete(p.incomeContexts, epoch)
|
||||||
|
|
||||||
|
if !ok {
|
||||||
|
p.log.Warn("income context distribution does not exists",
|
||||||
|
zap.Uint64("epoch", epoch))
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
err := p.pool.Submit(func() {
|
||||||
|
incomeCtx.Distribute()
|
||||||
|
})
|
||||||
|
if err != nil {
|
||||||
|
p.log.Warn("could not add handler of basic income distribution to queue",
|
||||||
|
zap.String("error", err.Error()),
|
||||||
|
)
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -279,5 +279,6 @@ func (b *basicSettlementConstructor) CreateContext(epoch uint64) (*basic.IncomeS
|
||||||
Container: b.dep,
|
Container: b.dep,
|
||||||
Placement: b.dep,
|
Placement: b.dep,
|
||||||
Exchange: b.dep,
|
Exchange: b.dep,
|
||||||
|
Accounts: b.dep,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue