solana-go/rpc/getEpochInfo.go

40 lines
931 B
Go
Raw Normal View History

2021-07-01 05:29:35 -07:00
package rpc
import (
"context"
bin "github.com/dfuse-io/binary"
)
// GetEpochInfo returns information about the current epoch.
func (cl *Client) GetEpochInfo(
ctx context.Context,
commitment CommitmentType, // optional
2021-07-01 05:29:35 -07:00
) (out *GetEpochInfoResult, err error) {
2021-07-09 08:36:53 -07:00
params := []interface{}{}
2021-07-01 05:29:35 -07:00
if commitment != "" {
params = append(params, M{"commitment": commitment})
}
err = cl.rpcClient.CallFor(&out, "getEpochInfo", params)
return
}
type GetEpochInfoResult struct {
// The current slot.
AbsoluteSlot bin.Uint64 `json:"absoluteSlot"`
// The current block height.
BlockHeight bin.Uint64 `json:"blockHeight"`
// The current epoch.
Epoch bin.Uint64 `json:"epoch"`
// The current slot relative to the start of the current epoch.
SlotIndex bin.Uint64 `json:"slotIndex"`
// The number of slots in this epoch.
SlotsInEpoch bin.Uint64 `json:"slotsInEpoch"`
TransactionCount bin.Uint64 `json:"transactionCount"`
}