Skip to content

Commit c28a661

Browse files
committed
Support TextTxAccept RPC
1 parent 07c9fc8 commit c28a661

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

rpc/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ type Client interface {
152152
// SendTransaction send new transaction into transaction pool.
153153
SendTransaction(ctx context.Context, tx *types.Transaction) (*types.Hash, error)
154154

155+
/// Test if a transaction can be accepted by the transaction pool without inserting it into the pool or rebroadcasting it to peers.
156+
/// The parameters and errors of this method are the same as `send_transaction`.
157+
TestTxPoolAccept(ctx context.Context, tx *types.Transaction) (*types.EntryCompleted, error)
158+
155159
// TxPoolInfo return the transaction pool information
156160
TxPoolInfo(ctx context.Context) (*types.TxPoolInfo, error)
157161

@@ -671,6 +675,17 @@ func (cli *client) SendTransaction(ctx context.Context, tx *types.Transaction) (
671675
return &result, err
672676
}
673677

678+
// TestTxPoolAccept(ctx context.Context, tx *types.Transaction) (*types.EntryCompleted, error)
679+
func (cli *client) TestTxPoolAccept(ctx context.Context, tx *types.Transaction) (*types.EntryCompleted, error) {
680+
var result types.EntryCompleted
681+
682+
err := cli.c.CallContext(ctx, &result, "test_tx_pool_accept", *tx, "passthrough")
683+
if err != nil {
684+
return nil, err
685+
}
686+
return &result, nil
687+
}
688+
674689
func (cli *client) GetPoolTxDetailInfo(ctx context.Context, hash types.Hash) (*types.PoolTxDetailInfo, error) {
675690
var result types.PoolTxDetailInfo
676691
err := cli.c.CallContext(ctx, &result, "get_pool_tx_detail", hash)

types/pool.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ type PoolTxDetailInfo struct {
3434
ScoreSortKey AncestorsScoreSortKey `json:"score_sortkey"`
3535
Timestamp uint64 `json:"timestamp"`
3636
}
37+
38+
type EntryCompleted struct {
39+
// Cached tx cycles
40+
cycles uint64 `json:"cycles"`
41+
// Cached tx fee
42+
fee uint64 `json:"fee"`
43+
}

0 commit comments

Comments
 (0)