Permit multiple data subscriptions per original topic #128
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
closes #126
Motivation
When we add new data topics, we would map the block topic to a response topic on the subscriber. It is possible for multiple blocks to go out in one response, however, so the subscriptions would overwrite each other.
This PR first refactors the subscription system to remove the concept of mapping and replace it with the concept of data topics. It then modifies the subscriber to permit multiple data subscribers per topic and ensure that each of these data subscribers is notified when a topic event is published.
Proposed Changes
MappableSubscriber
interface because there only needs to be one implementation.TopicData
to slightly distinguish data subscriptions from the original topic subscription. This replaces the mappable topic.notifications.SubscribeOn
tonotifications.SubscribeWithData
for clarity.mappable.go
todata_subscriber.go
and renamemappableSubscriber
toTopicDataSubscriber
.Notifee
'stopic
with adata
field of typeTopicData
.mappableSubscriber
'sidMap
withTopicDataSubscriber
'sdata
which is now a map of topics to multipleTopicData
s.DataSubscriber
'sOnNext
and andOnClose
now call the corresponding methods on the internal subscriber once for eachTopicData
mapped to the original topic. This fixes block sent listener is not called for every block sent #126.RegisterBlockSentListener
will get called once for every block actually sent (i.e. that block sent listener is not called for every block sent #126 has been fixed). This test failed before the last two changes.cc @dirkmc