11package txpool
22
33import (
4+ "github.com/ethereum/go-ethereum/common"
45 "github.com/ethereum/go-ethereum/common/hexutil"
56
7+ "github.com/cosmos/evm/rpc/backend"
68 "github.com/cosmos/evm/rpc/types"
79
810 "cosmossdk.io/log"
@@ -11,41 +13,38 @@ import (
1113// PublicAPI offers and API for the transaction pool. It only operates on data that is non-confidential.
1214// NOTE: For more info about the current status of this endpoints see https://github.com/evmos/ethermint/issues/124
1315type PublicAPI struct {
14- logger log.Logger
16+ logger log.Logger
17+ backend backend.EVMBackend
1518}
1619
1720// NewPublicAPI creates a new tx pool service that gives information about the transaction pool.
18- func NewPublicAPI (logger log.Logger ) * PublicAPI {
21+ func NewPublicAPI (logger log.Logger , backend backend. EVMBackend ) * PublicAPI {
1922 return & PublicAPI {
20- logger : logger .With ("module" , "txpool" ),
23+ logger : logger .With ("module" , "txpool" ),
24+ backend : backend ,
2125 }
2226}
2327
2428// Content returns the transactions contained within the transaction pool
2529func (api * PublicAPI ) Content () (map [string ]map [string ]map [string ]* types.RPCTransaction , error ) {
2630 api .logger .Debug ("txpool_content" )
27- content := map [string ]map [string ]map [string ]* types.RPCTransaction {
28- "pending" : make (map [string ]map [string ]* types.RPCTransaction ),
29- "queued" : make (map [string ]map [string ]* types.RPCTransaction ),
30- }
31- return content , nil
31+ return api .backend .Content ()
32+ }
33+
34+ // ContentFrom returns the transactions contained within the transaction pool
35+ func (api * PublicAPI ) ContentFrom (address common.Address ) (map [string ]map [string ]map [string ]* types.RPCTransaction , error ) {
36+ api .logger .Debug ("txpool_contentFrom" )
37+ return api .backend .ContentFrom (address )
3238}
3339
34- // Inspect returns the content of the transaction pool and flattens it into an
40+ // Inspect returns the content of the transaction pool and flattens it into an easily inspectable list
3541func (api * PublicAPI ) Inspect () (map [string ]map [string ]map [string ]string , error ) {
3642 api .logger .Debug ("txpool_inspect" )
37- content := map [string ]map [string ]map [string ]string {
38- "pending" : make (map [string ]map [string ]string ),
39- "queued" : make (map [string ]map [string ]string ),
40- }
41- return content , nil
43+ return api .backend .Inspect ()
4244}
4345
44- // Status returns the number of pending and queued transaction in the pool.
45- func (api * PublicAPI ) Status () map [string ]hexutil.Uint {
46+ // Status returns the number of pending and queued transaction in the pool
47+ func (api * PublicAPI ) Status () ( map [string ]hexutil.Uint , error ) {
4648 api .logger .Debug ("txpool_status" )
47- return map [string ]hexutil.Uint {
48- "pending" : hexutil .Uint (0 ),
49- "queued" : hexutil .Uint (0 ),
50- }
49+ return api .backend .Status ()
5150}
0 commit comments