2020-08-22 15:20:47 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-04-05 13:58:32 +00:00
|
|
|
"context"
|
2023-11-30 17:51:23 +00:00
|
|
|
"net"
|
2023-04-05 13:58:32 +00:00
|
|
|
|
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"
|
2023-11-30 17:51:23 +00:00
|
|
|
"google.golang.org/grpc"
|
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,
|
2022-12-30 14:48:50 +00:00
|
|
|
accountingService.NewExecutionService(
|
|
|
|
accounting.NewExecutor(balanceMorphWrapper),
|
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
|
|
|
|
2023-11-30 17:51:23 +00:00
|
|
|
c.cfgGRPC.performAndSave(func(_ string, _ net.Listener, s *grpc.Server) {
|
|
|
|
accountingGRPC.RegisterAccountingServiceServer(s, server)
|
|
|
|
})
|
2020-08-22 15:20:47 +00:00
|
|
|
}
|