2020-08-22 15:20:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
accountingGRPC "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
|
2020-09-01 14:33:26 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance/wrapper"
|
2020-08-22 15:20:47 +00:00
|
|
|
accountingTransportGRPC "github.com/nspcc-dev/neofs-node/pkg/network/transport/accounting/grpc"
|
|
|
|
accountingService "github.com/nspcc-dev/neofs-node/pkg/services/accounting"
|
|
|
|
accounting "github.com/nspcc-dev/neofs-node/pkg/services/accounting/morph"
|
|
|
|
)
|
|
|
|
|
|
|
|
func initAccountingService(c *cfg) {
|
2020-08-24 09:40:32 +00:00
|
|
|
if c.cfgMorph.client == nil {
|
2020-08-22 15:20:47 +00:00
|
|
|
initMorphComponents(c)
|
|
|
|
}
|
|
|
|
|
2021-05-21 11:02:46 +00:00
|
|
|
balanceMorphWrapper, err := wrapper.NewFromMorph(c.cfgMorph.client, c.cfgAccounting.scriptHash, 0)
|
2020-09-01 14:33:26 +00:00
|
|
|
fatalOnErr(err)
|
|
|
|
|
2021-06-22 17:25:18 +00:00
|
|
|
server := accountingTransportGRPC.New(
|
|
|
|
accountingService.NewSignService(
|
|
|
|
&c.key.PrivateKey,
|
|
|
|
accountingService.NewResponseService(
|
|
|
|
accountingService.NewExecutionService(
|
|
|
|
accounting.NewExecutor(balanceMorphWrapper),
|
2020-08-22 15:20:47 +00:00
|
|
|
),
|
2021-06-22 17:25:18 +00:00
|
|
|
c.respSvc,
|
2020-08-22 15:20:47 +00:00
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
2021-06-22 17:25:18 +00:00
|
|
|
|
|
|
|
for _, srv := range c.cfgGRPC.servers {
|
|
|
|
accountingGRPC.RegisterAccountingServiceServer(srv, server)
|
|
|
|
}
|
2020-08-22 15:20:47 +00:00
|
|
|
}
|