2020-08-22 15:20:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-04-05 13:58:32 +00:00
|
|
|
"context"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
accountingGRPC "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/accounting/grpc"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client/balance"
|
|
|
|
accountingTransportGRPC "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/network/transport/accounting/grpc"
|
|
|
|
accountingService "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/accounting"
|
|
|
|
accounting "git.frostfs.info/TrueCloudLab/frostfs-node/pkg/services/accounting/morph"
|
2020-08-22 15:20:47 +00:00
|
|
|
)
|
|
|
|
|
2023-04-05 13:58:32 +00:00
|
|
|
func initAccountingService(ctx context.Context, c *cfg) {
|
2020-08-24 09:40:32 +00:00
|
|
|
if c.cfgMorph.client == nil {
|
2023-04-05 13:58:32 +00:00
|
|
|
initMorphComponents(ctx, c)
|
2020-08-22 15:20:47 +00:00
|
|
|
}
|
|
|
|
|
2022-01-31 09:24:25 +00:00
|
|
|
balanceMorphWrapper, err := balance.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
|
|
|
}
|