forked from TrueCloudLab/frostfs-node
[#750] morph: Remove deprecated channel use
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>dump-police
parent
559ad58ab1
commit
fe1acf9e9a
|
@ -527,15 +527,6 @@ func (c *Client) IsValidScript(script []byte, signers []transaction.Signer) (val
|
|||
return res.State == vmstate.Halt.String(), nil
|
||||
}
|
||||
|
||||
// NotificationChannel returns channel than receives subscribed
|
||||
// notification from the connected RPC node.
|
||||
// Channel is closed when connection to the RPC node is lost.
|
||||
func (c *Client) NotificationChannel() <-chan rpcclient.Notification {
|
||||
c.switchLock.RLock()
|
||||
defer c.switchLock.RUnlock()
|
||||
return c.client.Notifications //lint:ignore SA1019 waits for neo-go v0.102.0 https://github.com/nspcc-dev/neo-go/pull/2980
|
||||
}
|
||||
|
||||
func (c *Client) Metrics() morphmetrics.Register {
|
||||
return c.metrics
|
||||
}
|
||||
|
|
|
@ -12,7 +12,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/block"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/neorpc/result"
|
||||
"github.com/nspcc-dev/neo-go/pkg/rpcclient"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
@ -183,8 +182,6 @@ func New(ctx context.Context, p *Params) (Subscriber, error) {
|
|||
|
||||
func (s *subscriber) routeNotifications(ctx context.Context) {
|
||||
var (
|
||||
// TODO: not needed after nspcc-dev/neo-go#2980.
|
||||
cliCh = s.client.NotificationChannel()
|
||||
restoreCh = make(chan bool)
|
||||
restoreInProgress bool
|
||||
)
|
||||
|
@ -220,8 +217,6 @@ routeloop:
|
|||
} else {
|
||||
connLost = true
|
||||
}
|
||||
case _, ok := <-cliCh:
|
||||
connLost = !ok
|
||||
case ok := <-restoreCh:
|
||||
restoreInProgress = false
|
||||
if !ok {
|
||||
|
@ -230,7 +225,7 @@ routeloop:
|
|||
}
|
||||
if connLost {
|
||||
if !restoreInProgress {
|
||||
restoreInProgress, cliCh = s.switchEndpoint(ctx, restoreCh)
|
||||
restoreInProgress = s.switchEndpoint(ctx, restoreCh)
|
||||
if !restoreInProgress {
|
||||
break routeloop
|
||||
}
|
||||
|
@ -249,15 +244,13 @@ routeloop:
|
|||
close(s.notaryChan)
|
||||
}
|
||||
|
||||
func (s *subscriber) switchEndpoint(ctx context.Context, finishCh chan<- bool) (bool, <-chan rpcclient.Notification) {
|
||||
func (s *subscriber) switchEndpoint(ctx context.Context, finishCh chan<- bool) bool {
|
||||
s.log.Info(logs.RPConnectionLost)
|
||||
if !s.client.SwitchRPC(ctx) {
|
||||
s.log.Error(logs.RPCNodeSwitchFailure)
|
||||
return false, nil
|
||||
return false
|
||||
}
|
||||
|
||||
cliCh := s.client.NotificationChannel()
|
||||
|
||||
s.Lock()
|
||||
chs := newSubChannels()
|
||||
go func() {
|
||||
|
@ -267,7 +260,7 @@ func (s *subscriber) switchEndpoint(ctx context.Context, finishCh chan<- bool) (
|
|||
s.Unlock()
|
||||
|
||||
s.client.Metrics().IncSwitchCount()
|
||||
return true, cliCh
|
||||
return true
|
||||
}
|
||||
|
||||
func newSubChannels() subChannels {
|
||||
|
|
Loading…
Reference in New Issue