-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathoptions.go
63 lines (53 loc) · 1.27 KB
/
options.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
54
55
56
57
58
59
60
61
62
63
package bn
import (
"time"
"github.com/libsv/go-bn/internal/service"
)
// BitcoinClientOptFunc for setting bitcoin client options.
type BitcoinClientOptFunc func(c *clientOpts)
type clientOpts struct {
timeout time.Duration
host string
rpc service.RPC
username string
password string
cache bool
isMainnet bool
}
// WithTimeout set the timeout for the http client.
func WithTimeout(seconds time.Duration) BitcoinClientOptFunc {
return func(c *clientOpts) {
c.timeout = seconds
}
}
// WithCache enable response caching.
func WithCache() BitcoinClientOptFunc {
return func(c *clientOpts) {
c.cache = true
}
}
// WithHost set the bitcoin node host.
func WithHost(host string) BitcoinClientOptFunc {
return func(c *clientOpts) {
c.host = host
}
}
// WithCreds set the bitcoin node credentials.
func WithCreds(username, password string) BitcoinClientOptFunc {
return func(c *clientOpts) {
c.username = username
c.password = password
}
}
// WithMainnet set whether or not the node is a mainnet node.
func WithMainnet() BitcoinClientOptFunc {
return func(c *clientOpts) {
c.isMainnet = true
}
}
// WithCustomRPC set a custom RPC client.
func WithCustomRPC(rpc service.RPC) BitcoinClientOptFunc {
return func(c *clientOpts) {
c.rpc = rpc
}
}