forked from metachris/flashbotsrpc
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathoptions.go
57 lines (48 loc) · 1.25 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
package flashbotsrpc
import (
"io"
"net/http"
)
type httpClient interface {
Post(url string, contentType string, body io.Reader) (*http.Response, error)
Do(req *http.Request) (*http.Response, error)
}
type logger interface {
Println(v ...interface{})
}
// WithHttpClient set custom http client
func WithHttpClient(client httpClient) func(rpc *FlashbotsRPC) {
return func(rpc *FlashbotsRPC) {
rpc.client = client
}
}
// WithLogger set custom logger
func WithLogger(l logger) func(rpc *FlashbotsRPC) {
return func(rpc *FlashbotsRPC) {
rpc.log = l
}
}
// WithDebug set debug flag
func WithDebug(enabled bool) func(rpc *FlashbotsRPC) {
return func(rpc *FlashbotsRPC) {
rpc.Debug = enabled
}
}
// BroadcastRPC WithLogger set custom logger
func BroadcastRPCWithLogger(l logger) func(rpc *BuilderBroadcastRPC) {
return func(rpc *BuilderBroadcastRPC) {
rpc.log = l
}
}
// BroadcastRPC WithHttpClient set custom http client
func BroadcastRPCWithHttpClient(client httpClient) func(rpc *BuilderBroadcastRPC) {
return func(rpc *BuilderBroadcastRPC) {
rpc.client = client
}
}
// BroadcastRPC WithDebug set debug flag
func BroadcastRPCWithDebug(enabled bool) func(rpc *BuilderBroadcastRPC) {
return func(rpc *BuilderBroadcastRPC) {
rpc.Debug = enabled
}
}