2020-08-22 15:20:47 +00:00
|
|
|
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"
|
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)
|
|
|
|
}
|
|
|
|
|
|
|
|
u160, err := util.Uint160DecodeStringLE(c.cfgAccounting.scriptHash)
|
|
|
|
fatalOnErr(err)
|
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
staticClient, err := client.NewStatic(c.cfgMorph.client, u160, c.cfgAccounting.fee)
|
2020-08-22 15:20:47 +00:00
|
|
|
fatalOnErr(err)
|
|
|
|
|
|
|
|
balanceClient, err := balance.New(staticClient)
|
|
|
|
fatalOnErr(err)
|
|
|
|
|
2020-09-01 14:33:26 +00:00
|
|
|
balanceMorphWrapper, err := wrapper.New(balanceClient)
|
|
|
|
fatalOnErr(err)
|
|
|
|
|
2020-08-22 15:20:47 +00:00
|
|
|
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})
|
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
accountingGRPC.RegisterAccountingServiceServer(c.cfgGRPC.server,
|
2020-08-22 15:20:47 +00:00
|
|
|
accountingTransportGRPC.New(
|
|
|
|
accountingService.NewSignService(
|
|
|
|
c.key,
|
|
|
|
accountingService.NewExecutionService(
|
2020-09-01 14:33:26 +00:00
|
|
|
accounting.NewExecutor(balanceMorphWrapper),
|
2020-08-22 15:20:47 +00:00
|
|
|
metaHdr,
|
|
|
|
),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
}
|