rpc/ws: fix SlotsUpdatesResult timestamp resolution

This commit is contained in:
Leopold Schabel 2022-06-15 14:47:56 +02:00
parent 4540aed8d5
commit 25b9f3025b
2 changed files with 13 additions and 1 deletions

View File

@ -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"`
// Extra stats provided when a bank is frozen.

View File

@ -32,6 +32,18 @@ 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 {