2020-08-21 15:01:59 +00:00
|
|
|
package main
|
|
|
|
|
2020-08-22 11:03:45 +00:00
|
|
|
import (
|
|
|
|
"context"
|
2020-08-22 14:17:03 +00:00
|
|
|
"crypto/ecdsa"
|
2020-08-24 09:40:32 +00:00
|
|
|
"net"
|
2020-08-22 11:03:45 +00:00
|
|
|
"sync"
|
2020-08-22 14:17:03 +00:00
|
|
|
|
2020-08-22 15:20:47 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-08-22 14:17:03 +00:00
|
|
|
crypto "github.com/nspcc-dev/neofs-crypto"
|
2020-08-22 15:20:47 +00:00
|
|
|
"github.com/nspcc-dev/neofs-node/pkg/morph/client"
|
2020-08-24 15:51:42 +00:00
|
|
|
tokenStorage "github.com/nspcc-dev/neofs-node/pkg/services/session/storage"
|
2020-08-22 15:20:47 +00:00
|
|
|
"google.golang.org/grpc"
|
2020-08-22 11:03:45 +00:00
|
|
|
)
|
|
|
|
|
2020-08-21 15:01:59 +00:00
|
|
|
type cfg struct {
|
2020-08-22 11:03:45 +00:00
|
|
|
ctx context.Context
|
|
|
|
|
|
|
|
wg *sync.WaitGroup
|
|
|
|
|
2020-08-22 14:17:03 +00:00
|
|
|
key *ecdsa.PrivateKey
|
2020-08-22 15:20:47 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
cfgGRPC cfgGRPC
|
|
|
|
|
|
|
|
cfgMorph cfgMorph
|
|
|
|
|
|
|
|
cfgAccounting cfgAccounting
|
2020-08-24 14:07:08 +00:00
|
|
|
|
|
|
|
cfgContainer cfgContainer
|
2020-08-24 15:51:42 +00:00
|
|
|
|
|
|
|
privateTokenStore *tokenStorage.TokenStore
|
2020-08-24 09:40:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
type cfgGRPC struct {
|
|
|
|
endpoint string
|
|
|
|
|
|
|
|
listener net.Listener
|
2020-08-22 15:20:47 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
server *grpc.Server
|
|
|
|
}
|
|
|
|
|
|
|
|
type cfgMorph struct {
|
|
|
|
endpoint string
|
|
|
|
|
|
|
|
client *client.Client
|
|
|
|
}
|
2020-08-22 15:20:47 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
type cfgAccounting struct {
|
|
|
|
scriptHash string
|
2020-08-22 15:20:47 +00:00
|
|
|
|
2020-08-24 09:40:32 +00:00
|
|
|
fee util.Fixed8
|
2020-08-21 15:01:59 +00:00
|
|
|
}
|
|
|
|
|
2020-08-24 14:07:08 +00:00
|
|
|
type cfgContainer struct {
|
|
|
|
scriptHash string
|
|
|
|
|
|
|
|
fee util.Fixed8
|
|
|
|
}
|
|
|
|
|
2020-08-21 15:01:59 +00:00
|
|
|
func defaultCfg() *cfg {
|
2020-08-22 14:17:03 +00:00
|
|
|
key, err := crypto.LoadPrivateKey("Kwk6k2eC3L3QuPvD8aiaNyoSXgQ2YL1bwS5CP1oKoA9waeAze97s")
|
|
|
|
fatalOnErr(err)
|
|
|
|
|
2020-08-21 15:01:59 +00:00
|
|
|
return &cfg{
|
2020-08-24 09:40:32 +00:00
|
|
|
ctx: context.Background(),
|
|
|
|
wg: new(sync.WaitGroup),
|
|
|
|
key: key,
|
|
|
|
cfgGRPC: cfgGRPC{
|
|
|
|
endpoint: "127.0.0.1:50501",
|
|
|
|
},
|
|
|
|
cfgMorph: cfgMorph{
|
|
|
|
endpoint: "http://morph_chain.localtest.nspcc.ru:30333/",
|
|
|
|
},
|
|
|
|
cfgAccounting: cfgAccounting{
|
2020-08-22 15:20:47 +00:00
|
|
|
scriptHash: "1aeefe1d0dfade49740fff779c02cd4a0538ffb1",
|
|
|
|
fee: util.Fixed8(1),
|
|
|
|
},
|
2020-08-24 14:07:08 +00:00
|
|
|
cfgContainer: cfgContainer{
|
|
|
|
scriptHash: "9d2ca84d7fb88213c4baced5a6ed4dc402309039",
|
|
|
|
fee: util.Fixed8(1),
|
|
|
|
},
|
2020-08-21 15:01:59 +00:00
|
|
|
}
|
|
|
|
}
|