Skip to content

Commit

Permalink
Merge pull request #63 from kaleido-io/since-0
Browse files Browse the repository at this point in the history
Fix event subscription when since is 0
  • Loading branch information
peterbroadhurst authored Dec 20, 2021
2 parents 726e19e + 9f3bf98 commit d601efb
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions internal/fabric/client/eventsubscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func (e *eventClientWrapper) subscribeEvent(subInfo *eventsapi.SubscriptionInfo,
if err != nil {
return nil, nil, nil, errors.Errorf("Failed to subscribe to chaincode %s events. %s", subInfo.Filter.ChaincodeId, err)
}
log.Infof("Subscribed to events in channel %s chaincode %s from block %d (0 means newest)", subInfo.ChannelId, subInfo.Filter.ChaincodeId, since)
log.Infof("Subscribed to events in channel %s chaincode %s from block %d", subInfo.ChannelId, subInfo.Filter.ChaincodeId, since)
regWrapper := &RegistrationWrapper{
registration: reg,
eventClient: eventClient,
Expand All @@ -82,7 +82,7 @@ func (e *eventClientWrapper) subscribeEvent(subInfo *eventsapi.SubscriptionInfo,
if err != nil {
return nil, nil, nil, errors.Errorf("Failed to subscribe to block events. %s", err)
}
log.Infof("Subscribed to events in channel %s from block %d (0 means newest)", subInfo.ChannelId, since)
log.Infof("Subscribed to events in channel %s from block %d", subInfo.ChannelId, since)
regWrapper := &RegistrationWrapper{
registration: reg,
eventClient: eventClient,
Expand All @@ -101,9 +101,8 @@ func (e *eventClientWrapper) getEventClient(channelId, signer string, since uint
if eventClient == nil {
eventOpts := []event.ClientOption{
event.WithBlockEvents(),
}
if since != 0 {
eventOpts = append(eventOpts, event.WithSeekType(seek.FromBlock), event.WithBlockNum(since))
event.WithSeekType(seek.FromBlock),
event.WithBlockNum(since),
}
channelProvider := e.sdk.ChannelContext(channelId, fabsdk.WithOrg(e.idClient.GetClientOrg()), fabsdk.WithUser(signer))
eventClient, err = e.eventClientCreator(channelProvider, eventOpts...)
Expand Down

0 comments on commit d601efb

Please sign in to comment.