forked from TrueCloudLab/frostfs-node
e6fedfbc69
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
51 lines
1.4 KiB
Go
51 lines
1.4 KiB
Go
package main
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
|
accountingGRPC "github.com/nspcc-dev/neofs-api-go/v2/accounting/grpc"
|
|
"github.com/nspcc-dev/neofs-api-go/v2/session"
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client/balance"
|
|
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"
|
|
)
|
|
|
|
type cfgAccounting struct {
|
|
scriptHash string
|
|
|
|
fee util.Fixed8
|
|
}
|
|
|
|
func initAccountingService(c *cfg) {
|
|
if c.morphClient == nil {
|
|
initMorphComponents(c)
|
|
}
|
|
|
|
u160, err := util.Uint160DecodeStringLE(c.cfgAccounting.scriptHash)
|
|
fatalOnErr(err)
|
|
|
|
staticClient, err := client.NewStatic(c.morphClient, u160, c.cfgAccounting.fee)
|
|
fatalOnErr(err)
|
|
|
|
balanceClient, err := balance.New(staticClient)
|
|
fatalOnErr(err)
|
|
|
|
metaHdr := new(session.ResponseMetaHeader)
|
|
xHdr := new(session.XHeader)
|
|
xHdr.SetKey("test X-Header key")
|
|
xHdr.SetValue("test X-Header value")
|
|
metaHdr.SetXHeaders([]*session.XHeader{xHdr})
|
|
|
|
accountingGRPC.RegisterAccountingServiceServer(c.grpcSrv,
|
|
accountingTransportGRPC.New(
|
|
accountingService.NewSignService(
|
|
c.key,
|
|
accountingService.NewExecutionService(
|
|
accounting.NewExecutor(balanceClient),
|
|
metaHdr,
|
|
),
|
|
),
|
|
),
|
|
)
|
|
}
|