forked from manxiaqu/txpoolWatcher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.go
47 lines (37 loc) · 1.04 KB
/
client.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
package main
import (
"context"
"github.com/ethereum/go-ethereum/rpc"
)
const defaultRpcUrl = "http://127.0.0.1:8545"
type Client struct {
client *rpc.Client
}
func DialDefault() (*Client, error) {
return Dial(defaultRpcUrl)
}
func Dial(url string) (*Client, error) {
c, err := rpc.DialContext(context.Background(), url)
if err != nil {
return nil, err
}
return NewClient(c), nil
}
func NewClient(c *rpc.Client) *Client {
return &Client{c}
}
func (c *Client) TxPoolContent() (map[string]map[string]map[string]interface{}, error) {
var result map[string]map[string]map[string]interface{}
err := c.client.Call(&result, "txpool_content", nil)
return result, err
}
func (c *Client) TxPoolInspect() (map[string]map[string]map[string]string, error) {
var result map[string]map[string]map[string]string
err := c.client.Call(&result, "txpool_inspect", "")
return result, err
}
func (c *Client) TxPoolStatus() (map[string]string, error) {
var result map[string]string
err := c.client.Call(&result, "txpool_status", nil)
return result, err
}