/
rpc_is_blockhash_valid.go
53 lines (45 loc) · 1.5 KB
/
rpc_is_blockhash_valid.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package client
import (
"context"
"github.com/portto/solana-go-sdk/rpc"
)
type IsBlockhashValidConfig struct {
Commitment rpc.Commitment
}
func (c IsBlockhashValidConfig) toRpc() rpc.IsBlockhashValidConfig {
return rpc.IsBlockhashValidConfig{
Commitment: c.Commitment,
}
}
func (c *Client) IsBlockhashValid(ctx context.Context, blockhash string) (bool, error) {
return process(
func() (rpc.JsonRpcResponse[rpc.ValueWithContext[bool]], error) {
return c.RpcClient.IsBlockhashValid(ctx, blockhash)
},
value[bool],
)
}
func (c *Client) IsBlockhashValidWithConfig(ctx context.Context, blockhash string, cfg IsBlockhashValidConfig) (bool, error) {
return process(
func() (rpc.JsonRpcResponse[rpc.ValueWithContext[bool]], error) {
return c.RpcClient.IsBlockhashValidWithConfig(ctx, blockhash, cfg.toRpc())
},
value[bool],
)
}
func (c *Client) IsBlockhashValidAndContext(ctx context.Context, blockhash string) (rpc.ValueWithContext[bool], error) {
return process(
func() (rpc.JsonRpcResponse[rpc.ValueWithContext[bool]], error) {
return c.RpcClient.IsBlockhashValid(ctx, blockhash)
},
forward[rpc.ValueWithContext[bool]],
)
}
func (c *Client) IsBlockhashValidAndContextWithConfig(ctx context.Context, blockhash string, cfg IsBlockhashValidConfig) (rpc.ValueWithContext[bool], error) {
return process(
func() (rpc.JsonRpcResponse[rpc.ValueWithContext[bool]], error) {
return c.RpcClient.IsBlockhashValidWithConfig(ctx, blockhash, cfg.toRpc())
},
forward[rpc.ValueWithContext[bool]],
)
}