[#1422] morph: Resolve funlen linter
Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
This commit is contained in:
parent
110f2fd9e3
commit
f6fe5da020
1 changed files with 44 additions and 40 deletions
|
@ -29,6 +29,50 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func initMorphComponents(ctx context.Context, c *cfg) {
|
func initMorphComponents(ctx context.Context, c *cfg) {
|
||||||
|
initMorphClient(ctx, c)
|
||||||
|
|
||||||
|
lookupScriptHashesInNNS(c) // smart contract auto negotiation
|
||||||
|
|
||||||
|
if c.cfgMorph.notaryEnabled {
|
||||||
|
err := c.cfgMorph.client.EnableNotarySupport(
|
||||||
|
client.WithProxyContract(
|
||||||
|
c.cfgMorph.proxyScriptHash,
|
||||||
|
),
|
||||||
|
)
|
||||||
|
fatalOnErr(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.log.Info(logs.FrostFSNodeNotarySupport,
|
||||||
|
zap.Bool("sidechain_enabled", c.cfgMorph.notaryEnabled),
|
||||||
|
)
|
||||||
|
|
||||||
|
wrap, err := nmClient.NewFromMorph(c.cfgMorph.client, c.cfgNetmap.scriptHash, 0, nmClient.TryNotary())
|
||||||
|
fatalOnErr(err)
|
||||||
|
|
||||||
|
var netmapSource netmap.Source
|
||||||
|
|
||||||
|
c.cfgMorph.containerCacheSize = morphconfig.ContainerCacheSize(c.appCfg)
|
||||||
|
c.cfgMorph.cacheTTL = morphconfig.CacheTTL(c.appCfg)
|
||||||
|
|
||||||
|
if c.cfgMorph.cacheTTL == 0 {
|
||||||
|
msPerBlock, err := c.cfgMorph.client.MsPerBlock()
|
||||||
|
fatalOnErr(err)
|
||||||
|
c.cfgMorph.cacheTTL = time.Duration(msPerBlock) * time.Millisecond
|
||||||
|
c.log.Debug(logs.FrostFSNodeMorphcacheTTLFetchedFromNetwork, zap.Duration("value", c.cfgMorph.cacheTTL))
|
||||||
|
}
|
||||||
|
|
||||||
|
if c.cfgMorph.cacheTTL < 0 {
|
||||||
|
netmapSource = wrap
|
||||||
|
} else {
|
||||||
|
// use RPC node as source of netmap (with caching)
|
||||||
|
netmapSource = newCachedNetmapStorage(c.cfgNetmap.state, wrap)
|
||||||
|
}
|
||||||
|
|
||||||
|
c.netMapSource = netmapSource
|
||||||
|
c.cfgNetmap.wrapper = wrap
|
||||||
|
}
|
||||||
|
|
||||||
|
func initMorphClient(ctx context.Context, c *cfg) {
|
||||||
addresses := morphconfig.RPCEndpoint(c.appCfg)
|
addresses := morphconfig.RPCEndpoint(c.appCfg)
|
||||||
|
|
||||||
// Morph client stable-sorts endpoints by priority. Shuffle here to randomize
|
// Morph client stable-sorts endpoints by priority. Shuffle here to randomize
|
||||||
|
@ -70,46 +114,6 @@ func initMorphComponents(ctx context.Context, c *cfg) {
|
||||||
|
|
||||||
c.cfgMorph.client = cli
|
c.cfgMorph.client = cli
|
||||||
c.cfgMorph.notaryEnabled = cli.ProbeNotary()
|
c.cfgMorph.notaryEnabled = cli.ProbeNotary()
|
||||||
|
|
||||||
lookupScriptHashesInNNS(c) // smart contract auto negotiation
|
|
||||||
|
|
||||||
if c.cfgMorph.notaryEnabled {
|
|
||||||
err = c.cfgMorph.client.EnableNotarySupport(
|
|
||||||
client.WithProxyContract(
|
|
||||||
c.cfgMorph.proxyScriptHash,
|
|
||||||
),
|
|
||||||
)
|
|
||||||
fatalOnErr(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
c.log.Info(logs.FrostFSNodeNotarySupport,
|
|
||||||
zap.Bool("sidechain_enabled", c.cfgMorph.notaryEnabled),
|
|
||||||
)
|
|
||||||
|
|
||||||
wrap, err := nmClient.NewFromMorph(c.cfgMorph.client, c.cfgNetmap.scriptHash, 0, nmClient.TryNotary())
|
|
||||||
fatalOnErr(err)
|
|
||||||
|
|
||||||
var netmapSource netmap.Source
|
|
||||||
|
|
||||||
c.cfgMorph.containerCacheSize = morphconfig.ContainerCacheSize(c.appCfg)
|
|
||||||
c.cfgMorph.cacheTTL = morphconfig.CacheTTL(c.appCfg)
|
|
||||||
|
|
||||||
if c.cfgMorph.cacheTTL == 0 {
|
|
||||||
msPerBlock, err := c.cfgMorph.client.MsPerBlock()
|
|
||||||
fatalOnErr(err)
|
|
||||||
c.cfgMorph.cacheTTL = time.Duration(msPerBlock) * time.Millisecond
|
|
||||||
c.log.Debug(logs.FrostFSNodeMorphcacheTTLFetchedFromNetwork, zap.Duration("value", c.cfgMorph.cacheTTL))
|
|
||||||
}
|
|
||||||
|
|
||||||
if c.cfgMorph.cacheTTL < 0 {
|
|
||||||
netmapSource = wrap
|
|
||||||
} else {
|
|
||||||
// use RPC node as source of netmap (with caching)
|
|
||||||
netmapSource = newCachedNetmapStorage(c.cfgNetmap.state, wrap)
|
|
||||||
}
|
|
||||||
|
|
||||||
c.netMapSource = netmapSource
|
|
||||||
c.cfgNetmap.wrapper = wrap
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func makeAndWaitNotaryDeposit(ctx context.Context, c *cfg) {
|
func makeAndWaitNotaryDeposit(ctx context.Context, c *cfg) {
|
||||||
|
|
Loading…
Reference in a new issue