Add RPC/getBlocksWithLimit
This commit is contained in:
parent
9f58c50f96
commit
3f3f7e87db
|
@ -6,7 +6,7 @@ import (
|
|||
bin "github.com/dfuse-io/binary"
|
||||
)
|
||||
|
||||
type GetBlocksResult []bin.Uint64
|
||||
type BlocksResult []bin.Uint64
|
||||
|
||||
// GetBlocks returns a list of confirmed blocks between two slots.
|
||||
// NEW: This method is only available in solana-core v1.7 or newer.
|
||||
|
@ -19,7 +19,7 @@ func (cl *Client) GetBlocks(
|
|||
startSlot uint64,
|
||||
endSlot *uint64,
|
||||
commitment CommitmentType,
|
||||
) (out *GetBlocksResult, err error) {
|
||||
) (out *BlocksResult, err error) {
|
||||
params := []interface{}{startSlot}
|
||||
if endSlot != nil {
|
||||
params = append(params, endSlot)
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package rpc
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
// GetBlocksWithLimit returns a list of confirmed blocks starting at the given slot.
|
||||
// NEW: This method is only available in solana-core v1.7 or newer.
|
||||
// Please use getConfirmedBlocksWithLimit for solana-core v1.6
|
||||
// The result field will be an array of u64 integers listing
|
||||
// confirmed blocks starting at startSlot for up to limit blocks, inclusive.
|
||||
func (cl *Client) GetBlocksWithLimit(
|
||||
ctx context.Context,
|
||||
startSlot uint64,
|
||||
limit uint64,
|
||||
commitment CommitmentType, // "processed" is not supported. If parameter not provided, the default is "finalized".
|
||||
) (out *BlocksResult, err error) {
|
||||
params := []interface{}{startSlot, limit}
|
||||
if commitment != "" {
|
||||
params = append(params,
|
||||
M{"commitment": commitment},
|
||||
)
|
||||
}
|
||||
err = cl.rpcClient.CallFor(&out, "getBlocksWithLimit", params...)
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue