Location
[client]
Context
Refactor of watcher for IoT use cases is described in umbrella issue: #172. To integrate the refactored watcher into the client, each channel should publish the off-chain transactions to the watcher via StatesPub interface.
type StatesPub interface {
Publish(channel.Transaction) error
}
Details
New states are created for the Channel when enabling newer off-chain states. In this place, the newer state should be published to the watcher.
However, the statesPub instance will be available only after a channel is initialized and the client registers the channel with the watcher. Therefore,
- Add a field
Publisher with type func(channel.Transaction) error to the client.Channel type.
- Implement a
NoopPublisher that always returns nil.
- When initializing the channel, set the
Publisher to a NoopPublisher.
- Publish the states on the Publisher when enabling newer off-chain states.
In an upcoming pull request, NoopPublisher will be replaced by the Publisher associated with the watcher when client registers the channel with the watcher.
Location
[client]
Context
Refactor of watcher for IoT use cases is described in umbrella issue: #172. To integrate the refactored watcher into the client, each channel should publish the off-chain transactions to the watcher via
StatesPubinterface.Details
New states are created for the Channel when enabling newer off-chain states. In this place, the newer state should be published to the watcher.
However, the
statesPubinstance will be available only after a channel is initialized and the client registers the channel with the watcher. Therefore,Publisherwith typefunc(channel.Transaction) errorto theclient.Channeltype.NoopPublisherthat always returns nil.Publisherto aNoopPublisher.In an upcoming pull request,
NoopPublisherwill be replaced by thePublisherassociated with the watcher when client registers the channel with the watcher.