Skip to content

Commit

Permalink
rpc/ws: fix SlotsUpdatesResult timestamp resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
leoluk committed Jun 15, 2022
1 parent 7886c8c commit 9a01ac4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rpc/ws/slotsUpdatesSubscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ type SlotsUpdatesResult struct {
// The newly updated slot.
Slot uint64 `json:"slot"`
// The Unix timestamp of the update.
Timestamp *solana.UnixTimeSeconds `json:"timestamp"`
Timestamp *solana.UnixTimeMilliseconds `json:"timestamp"`
// The update type.
Type SlotsUpdatesType `json:"type"`
}
Expand Down
11 changes: 11 additions & 0 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,17 @@ func (res UnixTimeSeconds) String() string {
return res.Time().String()
}

// UnixTimeMilliseconds represents a UNIX millisecond-resolution timestamp.
type UnixTimeMilliseconds int64

func (res UnixTimeMilliseconds) Time() time.Time {
return time.Unix(0, int64(res)*int64(time.Millisecond))
}

func (res UnixTimeMilliseconds) String() string {
return res.Time().String()
}

type DurationSeconds int64

func (res DurationSeconds) Duration() time.Duration {
Expand Down

0 comments on commit 9a01ac4

Please sign in to comment.