Skip to content

Commit

Permalink
Fix some rpc response type should be hexstring
Browse files Browse the repository at this point in the history
Signed-off-by: Eval EXEC <execvy@gmail.com>
  • Loading branch information
eval-exec committed Dec 22, 2024
1 parent 1107c77 commit 4b494f7
Show file tree
Hide file tree
Showing 4 changed files with 483 additions and 14 deletions.
11 changes: 6 additions & 5 deletions indexer/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ const (
)

type SearchKey struct {
Script *types.Script `json:"script"`
ScriptType types.ScriptType `json:"script_type"`
ScriptSearchMode types.ScriptSearchMode `json:"script_search_mode,omitempty"`
Filter *Filter `json:"filter,omitempty"`
WithData bool `json:"with_data"`
Script *types.Script `json:"script"`
ScriptType types.ScriptType `json:"script_type"`
ScriptSearchMode types.ScriptSearchMode `json:"script_search_mode,omitempty"`
Filter *Filter `json:"filter,omitempty"`
WithData bool `json:"with_data"`
GroupByTransaction *bool `json:"group_by_transaction,omitempty"`
}

type Filter struct {
Expand Down
25 changes: 17 additions & 8 deletions rpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,16 @@ type Client interface {

RemoveTransaction(ctx context.Context, tx_hash types.Hash) (bool, error)

SendAlert(ctx context.Context, alert types.AlertMessage) error
SendAlert(ctx context.Context, alert types.Alert) error

GetBlockTemplate(ctx context.Context) (types.BlockTemplate, error)

TxPoolReady(ctx context.Context) (bool, error)

// GetRawTxPool Returns all transaction ids in tx pool as a json array of string transaction ids.
GetRawTxPool(ctx context.Context, verbose *bool) (*types.RawTxPool, error)
GetRawTxPool(ctx context.Context) (*types.RawTxPool, error)
// GetRawTxPool Returns all transaction ids in tx pool as a json array of string transaction ids.
GetRawTxPoolVerbose(ctx context.Context) (*types.RawTxPoolVerbose, error)

// ClearTxPool Removes all transactions from the transaction pool.
ClearTxPool(ctx context.Context) error
Expand Down Expand Up @@ -774,14 +776,21 @@ func (cli *client) TxPoolInfo(ctx context.Context) (*types.TxPoolInfo, error) {
return &result, nil
}

func (cli *client) GetRawTxPool(ctx context.Context, verbose *bool) (*types.RawTxPool, error) {
func (cli *client) GetRawTxPool(ctx context.Context) (*types.RawTxPool, error) {
var txPool types.RawTxPool

if verbose == nil {
defaultVerbose := false
verbose = &defaultVerbose
err := cli.c.CallContext(ctx, &txPool, "get_raw_tx_pool")
if err != nil {
return nil, err
}
err := cli.c.CallContext(ctx, &txPool, "get_raw_tx_pool", verbose)

return &txPool, err
}

func (cli *client) GetRawTxPoolVerbose(ctx context.Context) (*types.RawTxPoolVerbose, error) {
var txPool types.RawTxPool

err := cli.c.CallContext(ctx, &txPool, "get_raw_tx_pool", true)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -996,7 +1005,7 @@ func (cli *client) RemoveTransaction(ctx context.Context, tx_hash types.Hash) (b
return result, nil
}

func (cli *client) SendAlert(ctx context.Context, alert types.AlertMessage) error {
func (cli *client) SendAlert(ctx context.Context, alert types.Alert) error {
return cli.c.CallContext(ctx, nil, "send_alert", alert)
}

Expand Down
Loading

0 comments on commit 4b494f7

Please sign in to comment.