-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Context
Currently, the watcher is associated with and coupled to a channel. One local instance of watcher must be started for each channel.
However, for the use case of IoT use cases (described in proposal#3), it is desirable to have a watcher that can
- Run either locally or as a remote service.
- Is not associated with any specific client/channel. Channels can be associated with/dissociated from a watcher dynamically during runtime.
The design for such a watcher was described in proposal#4. This is an umbrella issue to cover the changes for refactoring the watcher component based on the design in the proposal.
Details
Changes required in usage of watcher
- Earlier, user need not initialize a watcher. But now, they should initialize and pass it on as an additional argument to
client.New. - Usage of watcher will remain the same. User should call
ch.Watch()in a go-routine after establishing the channel.
Preparatory steps
-
1.
Adjudicator.Subscribeshould take onlych.Idas a parameter instead ofchannel.Params. As the ID is sufficient for subscribing to events on the blockchain (Adjudicator.Subscribe takeschannel.Paramswhile onlychannel.IDis needed #173). -
2. Define smaller interfaces for methods in
Adjudicator(Define smaller interfaces for methods in Adjudicator #184).
Implementation steps
- Set 1 (Implement the local watcher #174)
- Define the interfaces for watcher in
go-perun/watcherpackage. - Implement a local watcher in
go-perun/localpackage.
- Set 2 (Integrate statesPub interface into client. #197, part1)
- Add
statesPubfield andsetStatesPubmethod on watcher and callch.statesPub.Publishwhenever a new state is created.
- Set 3 (Integrate statesPub interface into client. #197, part2)
- Update the
client.NewAPI to take a new watcher instance and store it. - Update the
ch.Watchfunction to use the watcher instance stored in the client.