From 3f3f7e87db092bc7a20b0160a82c9214594a6de0 Mon Sep 17 00:00:00 2001 From: Slavomir Date: Thu, 1 Jul 2021 13:27:39 +0200 Subject: [PATCH] Add RPC/getBlocksWithLimit --- rpc/getBlocks.go | 4 ++-- rpc/getBlocksWithLimit.go | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 rpc/getBlocksWithLimit.go diff --git a/rpc/getBlocks.go b/rpc/getBlocks.go index cc8c403..5c2ac3d 100644 --- a/rpc/getBlocks.go +++ b/rpc/getBlocks.go @@ -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) diff --git a/rpc/getBlocksWithLimit.go b/rpc/getBlocksWithLimit.go new file mode 100644 index 0000000..e9188c4 --- /dev/null +++ b/rpc/getBlocksWithLimit.go @@ -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 +}