forked from lmittmann/w3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
status.go
37 lines (31 loc) · 801 Bytes
/
status.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
package txpool
import (
"encoding/json"
"github.com/ethereum/go-ethereum/common/hexutil"
"github.com/meltingclock/w3/internal/module"
"github.com/meltingclock/w3/w3types"
)
// Status requests the number of pending and queued transactions in the transaction pool.
func Status() w3types.RPCCallerFactory[StatusResponse] {
return module.NewFactory[StatusResponse](
"txpool_status",
nil,
)
}
type StatusResponse struct {
Pending uint
Queued uint
}
func (s *StatusResponse) UnmarshalJSON(data []byte) error {
type statusResponse struct {
Pending hexutil.Uint `json:"pending"`
Queued hexutil.Uint `json:"queued"`
}
var dec statusResponse
if err := json.Unmarshal(data, &dec); err != nil {
return err
}
s.Pending = uint(dec.Pending)
s.Queued = uint(dec.Queued)
return nil
}