diff --git a/cmd/neofs-node/morph.go b/cmd/neofs-node/morph.go index 9cb2dfe601..cb70a63e07 100644 --- a/cmd/neofs-node/morph.go +++ b/cmd/neofs-node/morph.go @@ -190,7 +190,6 @@ func listenMorphNotifications(c *cfg) { Log: c.log, Endpoint: endpoints[i], DialTimeout: timeout, - RPCInitTimeout: 10 * time.Second, StartFromBlock: fromSideChainBlock, }) if err == nil { diff --git a/pkg/innerring/innerring.go b/pkg/innerring/innerring.go index 68bebb69e3..2ea5bf716a 100644 --- a/pkg/innerring/innerring.go +++ b/pkg/innerring/innerring.go @@ -7,7 +7,6 @@ import ( "fmt" "io" "net" - "time" "github.com/nspcc-dev/neo-go/pkg/core/block" "github.com/nspcc-dev/neo-go/pkg/core/transaction" @@ -895,7 +894,6 @@ func createListener(ctx context.Context, p *chainParams) (event.Listener, error) Log: p.log, Endpoint: p.cfg.GetString(p.name + ".endpoint.notification"), DialTimeout: p.cfg.GetDuration(p.name + ".dial_timeout"), - RPCInitTimeout: 10 * time.Second, StartFromBlock: p.from, }) if err != nil { diff --git a/pkg/morph/subscriber/subscriber.go b/pkg/morph/subscriber/subscriber.go index 7edaa53546..e144b9e711 100644 --- a/pkg/morph/subscriber/subscriber.go +++ b/pkg/morph/subscriber/subscriber.go @@ -43,7 +43,6 @@ type ( Log *zap.Logger Endpoint string DialTimeout time.Duration - RPCInitTimeout time.Duration StartFromBlock uint32 } ) @@ -198,7 +197,7 @@ func New(ctx context.Context, p *Params) (Subscriber, error) { zap.String("endpoint", p.Endpoint), zap.Uint32("min_block_height", p.StartFromBlock)) - err = awaitHeight(wsClient, p.StartFromBlock, p.RPCInitTimeout) + err = awaitHeight(wsClient, p.StartFromBlock) if err != nil { return nil, err } @@ -226,23 +225,19 @@ func New(ctx context.Context, p *Params) (Subscriber, error) { // This function is required to avoid connections to unsynced RPC nodes, because // they can produce events from the past that should not be processed by // NeoFS nodes. -func awaitHeight(wsClient *client.WSClient, startFrom uint32, timeout time.Duration) error { +func awaitHeight(wsClient *client.WSClient, startFrom uint32) error { if startFrom == 0 { return nil } - for ch := time.After(timeout); ; { - select { - case <-ch: - return fmt.Errorf("could not init ws client: didn't reach expected height %d", startFrom) - default: - } - height, err := wsClient.GetBlockCount() - if err != nil { - return fmt.Errorf("could not get block height: %w", err) - } else if height >= startFrom { - return nil - } - time.Sleep(100 * time.Millisecond) + height, err := wsClient.GetBlockCount() + if err != nil { + return fmt.Errorf("could not get block height: %w", err) } + + if height < startFrom { + return fmt.Errorf("RPC block counter %d didn't reach expected height %d", height, startFrom) + } + + return nil }