Skip to content

Commit

Permalink
Align FinalisedEventWatcher with changes in PR#90 (Consensys#92)
Browse files Browse the repository at this point in the history
* Align FinalisedEventWatcher with changes in PR#90
  • Loading branch information
ermyas authored Feb 3, 2022
1 parent 5330ea5 commit 13f2e68
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (

// EventWatcher listens to blockchain events
type EventWatcher interface {
Watch()
Watch() error
}

type EventWatcherConfig struct {
Expand Down Expand Up @@ -111,7 +111,7 @@ type SFCCrossCallFinalisedEventWatcher struct {

// Watch subscribes and starts listening to 'CrossCall' events from a given Simple Function Call contract.
// Once an events receives sufficient block confirmations, it is passed to an event handler for processing.
func (l *SFCCrossCallFinalisedEventWatcher) Watch() {
func (l *SFCCrossCallFinalisedEventWatcher) Watch() error {
l.nextBlockToProcess = l.Start
headers := make(chan *types.Header)

Expand All @@ -122,14 +122,13 @@ func (l *SFCCrossCallFinalisedEventWatcher) Watch() {
for {
select {
case err := <-sub.Err():
// TODO: communicate this to the calling context
logging.Error("error in log subscription %v", err)
return fmt.Errorf("error in log subscription %v", err)
case latestHead := <-headers:
// TODO: communicate err to the calling context
l.processFinalisedEvents(latestHead)
case <-l.end:
logging.Info("Stop watching %v.", l.SfcContract)
return
return nil
}
}
}
Expand Down

0 comments on commit 13f2e68

Please sign in to comment.