node: neon watcher fix (#1694)

This commit is contained in:
bruce-riley 2022-10-07 13:45:37 -05:00 committed by GitHub
parent 1ebfa4ae95
commit 248fd5a588
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 8 deletions

View File

@ -2,6 +2,7 @@ package connectors
import (
"context"
"time"
celoAbi "github.com/certusone/wormhole/node/pkg/watchers/evm/connectors/celoabi"
ethAbi "github.com/certusone/wormhole/node/pkg/watchers/evm/connectors/ethabi"
@ -91,8 +92,10 @@ func (c *CeloConnector) GetGuardianSet(ctx context.Context, index uint32) (ethAb
}
func (c *CeloConnector) WatchLogMessagePublished(ctx context.Context, sink chan<- *ethAbi.AbiLogMessagePublished) (ethEvent.Subscription, error) {
timeout, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
messageC := make(chan *celoAbi.AbiLogMessagePublished, 2)
messageSub, err := c.filterer.WatchLogMessagePublished(&celoBind.WatchOpts{Context: ctx}, messageC, nil)
messageSub, err := c.filterer.WatchLogMessagePublished(&celoBind.WatchOpts{Context: timeout}, messageC, nil)
if err != nil {
return messageSub, err
}

View File

@ -2,6 +2,7 @@ package connectors
import (
"context"
"time"
ethAbi "github.com/certusone/wormhole/node/pkg/watchers/evm/connectors/ethabi"
@ -74,7 +75,9 @@ func (e *EthereumConnector) GetGuardianSet(ctx context.Context, index uint32) (e
}
func (e *EthereumConnector) WatchLogMessagePublished(ctx context.Context, sink chan<- *ethAbi.AbiLogMessagePublished) (ethEvent.Subscription, error) {
return e.filterer.WatchLogMessagePublished(&ethBind.WatchOpts{Context: ctx}, sink, nil)
timeout, cancel := context.WithTimeout(ctx, 15*time.Second)
defer cancel()
return e.filterer.WatchLogMessagePublished(&ethBind.WatchOpts{Context: timeout}, sink, nil)
}
func (e *EthereumConnector) TransactionReceipt(ctx context.Context, txHash ethCommon.Hash) (*ethTypes.Receipt, error) {

View File

@ -244,13 +244,10 @@ func (w *Watcher) Run(ctx context.Context) error {
}
}
// Timeout for initializing subscriptions
timeout, cancel = context.WithTimeout(ctx, 15*time.Second)
defer cancel()
// Subscribe to new message publications
// Subscribe to new message publications. We don't use a timeout here because the LogPollConnector
// will keep running. Other connectors will use a timeout internally if appropriate.
messageC := make(chan *ethabi.AbiLogMessagePublished, 2)
messageSub, err := w.ethConn.WatchLogMessagePublished(timeout, messageC)
messageSub, err := w.ethConn.WatchLogMessagePublished(ctx, messageC)
defer messageSub.Unsubscribe()
if err != nil {
ethConnectionErrors.WithLabelValues(w.networkName, "subscribe_error").Inc()