[#363] Define global config and use it to fetch basic income rate

Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
Alex Vanin 2021-02-02 14:12:41 +03:00 committed by Alex Vanin
parent be2ed6bf4c
commit 487c9b7589
7 changed files with 89 additions and 9 deletions

View file

@ -26,6 +26,10 @@ import (
"go.uber.org/zap"
)
type globalConfig interface {
BasicIncomeRate() (uint64, error)
}
type settlementDeps struct {
log *logger.Logger
@ -47,6 +51,7 @@ type auditSettlementDeps struct {
type basicIncomeSettlementDeps struct {
*settlementDeps
cnrClient *containerClient.Wrapper
cfg globalConfig
}
type basicSettlementConstructor struct {
@ -226,8 +231,8 @@ func (b basicIncomeSettlementDeps) Transfer(sender, recipient *owner.ID, amount
b.transfer(sender, recipient, amount, basicIncomeAuditDetails)
}
func (b basicIncomeSettlementDeps) BasicRate() uint64 {
return 1_0000_0000 // fixme: read from config and from chain
func (b basicIncomeSettlementDeps) BasicRate() (uint64, error) {
return b.cfg.BasicIncomeRate()
}
func (b basicIncomeSettlementDeps) Estimations(epoch uint64) ([]*wrapper.Estimations, error) {