Skip to content

Commit 7b8ee77

Browse files
committed
Initializing msg index by 0
1 parent 1360891 commit 7b8ee77

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

engine/access/rest/websockets/data_providers/account_statuses_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ func (p *AccountStatusesDataProvider) createSubscription(ctx context.Context, ar
9999
// No errors are expected during normal operations.
100100
func (p *AccountStatusesDataProvider) handleResponse() func(accountStatusesResponse *backend.AccountStatusesResponse) error {
101101
blocksSinceLastMessage := uint64(0)
102-
messageIndex := counters.NewMonotonousCounter(1)
102+
messageIndex := counters.NewMonotonousCounter(0)
103103

104104
return func(accountStatusesResponse *backend.AccountStatusesResponse) error {
105105
// check if there are any events in the response. if not, do not send a message unless the last
@@ -112,10 +112,10 @@ func (p *AccountStatusesDataProvider) handleResponse() func(accountStatusesRespo
112112
blocksSinceLastMessage = 0
113113
}
114114

115-
index := messageIndex.Value()
116115
if ok := messageIndex.Set(messageIndex.Value() + 1); !ok {
117116
return status.Errorf(codes.Internal, "message index already incremented to %d", messageIndex.Value())
118117
}
118+
index := messageIndex.Value()
119119

120120
p.send <- &models.AccountStatusesResponse{
121121
BlockID: accountStatusesResponse.BlockID.String(),

engine/access/rest/websockets/data_providers/events_provider.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ func (p *EventsDataProvider) Run() error {
8585
// No errors are expected during normal operations.
8686
func (p *EventsDataProvider) handleResponse() func(eventsResponse *backend.EventsResponse) error {
8787
blocksSinceLastMessage := uint64(0)
88-
messageIndex := counters.NewMonotonousCounter(1)
88+
messageIndex := counters.NewMonotonousCounter(0)
8989

9090
return func(eventsResponse *backend.EventsResponse) error {
9191
// check if there are any events in the response. if not, do not send a message unless the last
@@ -98,10 +98,10 @@ func (p *EventsDataProvider) handleResponse() func(eventsResponse *backend.Event
9898
blocksSinceLastMessage = 0
9999
}
100100

101-
index := messageIndex.Value()
102101
if ok := messageIndex.Set(messageIndex.Value() + 1); !ok {
103102
return fmt.Errorf("message index already incremented to: %d", messageIndex.Value())
104103
}
104+
index := messageIndex.Value()
105105

106106
p.send <- &models.EventResponse{
107107
BlockId: eventsResponse.BlockID.String(),

0 commit comments

Comments
 (0)