2021-07-01 04:18:42 -07:00
|
|
|
package rpc
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
bin "github.com/dfuse-io/binary"
|
|
|
|
)
|
|
|
|
|
2021-07-01 04:27:39 -07:00
|
|
|
type BlocksResult []bin.Uint64
|
2021-07-01 04:18:42 -07:00
|
|
|
|
|
|
|
// GetBlocks returns a list of confirmed blocks between two slots.
|
|
|
|
// NEW: This method is only available in solana-core v1.7 or newer.
|
|
|
|
// Please use getConfirmedBlocks for solana-core v1.6.
|
|
|
|
// The result will be an array of u64 integers listing confirmed blocks
|
|
|
|
// between start_slot and either end_slot, if provided, or latest
|
|
|
|
// confirmed block, inclusive. Max range allowed is 500,000 slots.
|
|
|
|
func (cl *Client) GetBlocks(
|
|
|
|
ctx context.Context,
|
|
|
|
startSlot uint64,
|
|
|
|
endSlot *uint64,
|
|
|
|
commitment CommitmentType,
|
2021-07-01 04:27:39 -07:00
|
|
|
) (out *BlocksResult, err error) {
|
2021-07-01 04:18:42 -07:00
|
|
|
params := []interface{}{startSlot}
|
|
|
|
if endSlot != nil {
|
|
|
|
params = append(params, endSlot)
|
|
|
|
}
|
|
|
|
if commitment != "" {
|
|
|
|
params = append(params,
|
|
|
|
M{"commitment": commitment},
|
|
|
|
)
|
|
|
|
}
|
|
|
|
err = cl.rpcClient.CallFor(&out, "getBlocks", params...)
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|