-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathclient_debug.go
67 lines (57 loc) · 2.49 KB
/
client_debug.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
64
65
66
67
package sdk
import (
"fmt"
"github.com/Conflux-Chain/go-conflux-sdk/types"
sdkErrors "github.com/Conflux-Chain/go-conflux-sdk/types/errors"
)
// RpcDebugClient used to access debug namespace RPC of Conflux blockchain.
type RpcDebugClient struct {
core *Client
}
// NewRpcDebugClient creates a new RpcDebugClient instance.
func NewRpcDebugClient(core *Client) RpcDebugClient {
return RpcDebugClient{core}
}
// TxpoolGetAccountTransactions returns account ready + deferred transactions
func (c *RpcDebugClient) TxpoolGetAccountTransactions(address types.Address) (val []types.Transaction, err error) {
err = c.core.CallRPC(&val, "txpool_accountTransactions", address)
return
}
// GetEpochReceiptsByEpochNumber returns epoch receipts by epoch number
func (c *RpcDebugClient) GetEpochReceipts(epoch types.EpochOrBlockHash, include_eth_recepits ...bool) (receipts [][]types.TransactionReceipt, err error) {
includeEth := get1stBoolIfy(include_eth_recepits)
err = c.core.CallRPC(&receipts, "cfx_getEpochReceipts", epoch, includeEth)
if ok, code := sdkErrors.DetectErrorCode(err); ok {
err = sdkErrors.BusinessError{Code: code, Inner: err}
}
return
}
// GetEpochReceiptsByPivotBlockHash returns epoch receipts by pivot block hash
func (c *RpcDebugClient) GetEpochReceiptsByPivotBlockHash(hash types.Hash) (receipts [][]types.TransactionReceipt, err error) {
err = c.core.CallRPC(&receipts, "cfx_getEpochReceipts", fmt.Sprintf("hash:%v", hash))
if ok, code := sdkErrors.DetectErrorCode(err); ok {
err = sdkErrors.BusinessError{Code: code, Inner: err}
}
return
}
func (c *RpcDebugClient) GetEpochReceiptProofByTransaction(hash types.Hash) (proof *types.EpochReceiptProof, err error) {
err = c.core.CallRPC(&proof, "debug_getEpochReceiptProofByTransaction", hash)
if ok, code := sdkErrors.DetectErrorCode(err); ok {
err = sdkErrors.BusinessError{Code: code, Inner: err}
}
return
}
func (c *RpcDebugClient) GetTransactionsByEpoch(epoch types.Epoch) (wrapTransactions []types.WrapTransaction, err error) {
err = c.core.CallRPC(&wrapTransactions, "debug_getTransactionsByEpoch", epoch)
if ok, code := sdkErrors.DetectErrorCode(err); ok {
err = sdkErrors.BusinessError{Code: code, Inner: err}
}
return
}
func (c *RpcDebugClient) GetTransactionsByBlock(hash types.Hash) (wrapTransactions []types.WrapTransaction, err error) {
err = c.core.CallRPC(&wrapTransactions, "debug_getTransactionsByBlock", hash)
if ok, code := sdkErrors.DetectErrorCode(err); ok {
err = sdkErrors.BusinessError{Code: code, Inner: err}
}
return
}