Skip to content

Commit

Permalink
change order and not prepare the response in case it is a duplicate
Browse files Browse the repository at this point in the history
  • Loading branch information
zkokelj committed Nov 2, 2023
1 parent 08cf285 commit 05b0133
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tools/walletextension/subscriptions/subscriptions.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ func (sm *SubscriptionManager) HandleNewSubscriptions(clients []rpc.Client, req
func readFromChannelAndWriteToUserConn(channel chan common.IDAndLog, userConn userconn.UserConn, userSubscriptionID gethrpc.ID, logger gethlog.Logger) {
buffer := NewCircularBuffer(wecommon.DeduplicationBufferSize)
for data := range channel {
jsonResponse, err := prepareLogResponse(data, userSubscriptionID)
if err != nil {
logger.Error("could not marshal log response to JSON on subscription.", log.SubIDKey, data.SubID, log.ErrKey, err)
continue
}

// create unique identifier for current log
uniqueLogKey := LogKey{
BlockHash: data.Log.BlockHash,
Expand All @@ -94,6 +88,12 @@ func readFromChannelAndWriteToUserConn(channel chan common.IDAndLog, userConn us
continue
}

jsonResponse, err := prepareLogResponse(data, userSubscriptionID)
if err != nil {
logger.Error("could not marshal log response to JSON on subscription.", log.SubIDKey, data.SubID, log.ErrKey, err)
continue
}

// the current log is unique, and we want to add it to our buffer and proceed with forwarding to the user
buffer.Push(uniqueLogKey)

Expand Down

0 comments on commit 05b0133

Please sign in to comment.