Skip to content

Conversation

@MatusKysel
Copy link
Collaborator

No description provided.

@MatusKysel MatusKysel requested a review from kstdl July 24, 2024 12:23
Comment on lines +58 to +75
switch slot := subscriptionData["slot"].(type) {
case float64:
// JSON numbers are decoded into float64 by default
r.onFinalizedEpoch <- common.GetEpochFromSlot(int64(slot))
case int:
// Handle int if by any chance it's parsed as such
r.onFinalizedEpoch <- common.GetEpochFromSlot(int64(slot))
case string:
// If "epoch" is provided as a string, parse it to an integer
if slotVal, err := strconv.ParseUint(slot, 10, 64); err == nil {
r.onFinalizedEpoch <- common.GetEpochFromSlot(int64(slotVal))
r.log.WithField("slot", slotVal).Debug("Slot value")
} else {
r.log.WithError(err).Error("Error converting epoch from string to uint64")
}
default:
r.log.WithField("data", subscriptionData).Warn("Epoch value is of an unrecognized type")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this convertion to a separate method and leave something like r.onFinalizedEpoch <- common.ToInt64(slot) here?

@kstdl kstdl marked this pull request as draft July 29, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants