2021-06-23 06:38:05 +00:00
|
|
|
package txpool
|
2021-06-21 14:06:30 +00:00
|
|
|
|
|
|
|
import (
|
2021-07-12 18:39:35 +00:00
|
|
|
"github.com/tendermint/tendermint/libs/log"
|
|
|
|
|
2021-06-21 14:06:30 +00:00
|
|
|
"github.com/ethereum/go-ethereum/common/hexutil"
|
2021-07-12 18:39:35 +00:00
|
|
|
|
2022-05-02 06:26:24 +00:00
|
|
|
"github.com/tharsis/ethermint/rpc/types"
|
2021-06-21 14:06:30 +00:00
|
|
|
)
|
|
|
|
|
2021-06-23 06:38:05 +00:00
|
|
|
// PublicAPI offers and API for the transaction pool. It only operates on data that is non-confidential.
|
2021-06-21 14:06:30 +00:00
|
|
|
// NOTE: For more info about the current status of this endpoints see https://github.com/tharsis/ethermint/issues/124
|
2021-06-23 06:38:05 +00:00
|
|
|
type PublicAPI struct {
|
2021-06-21 14:06:30 +00:00
|
|
|
logger log.Logger
|
|
|
|
}
|
|
|
|
|
2021-06-23 06:38:05 +00:00
|
|
|
// NewPublicAPI creates a new tx pool service that gives information about the transaction pool.
|
2021-07-12 18:39:35 +00:00
|
|
|
func NewPublicAPI(logger log.Logger) *PublicAPI {
|
2021-06-23 06:38:05 +00:00
|
|
|
return &PublicAPI{
|
2021-07-12 18:39:35 +00:00
|
|
|
logger: logger.With("module", "txpool"),
|
2021-06-21 14:06:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Content returns the transactions contained within the transaction pool
|
2021-06-23 06:38:05 +00:00
|
|
|
func (api *PublicAPI) Content() (map[string]map[string]map[string]*types.RPCTransaction, error) {
|
2021-06-21 14:06:30 +00:00
|
|
|
api.logger.Debug("txpool_content")
|
|
|
|
content := map[string]map[string]map[string]*types.RPCTransaction{
|
|
|
|
"pending": make(map[string]map[string]*types.RPCTransaction),
|
|
|
|
"queued": make(map[string]map[string]*types.RPCTransaction),
|
|
|
|
}
|
|
|
|
return content, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Inspect returns the content of the transaction pool and flattens it into an
|
2021-06-23 06:38:05 +00:00
|
|
|
func (api *PublicAPI) Inspect() (map[string]map[string]map[string]string, error) {
|
2021-06-21 14:06:30 +00:00
|
|
|
api.logger.Debug("txpool_inspect")
|
|
|
|
content := map[string]map[string]map[string]string{
|
|
|
|
"pending": make(map[string]map[string]string),
|
|
|
|
"queued": make(map[string]map[string]string),
|
|
|
|
}
|
|
|
|
return content, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
// Status returns the number of pending and queued transaction in the pool.
|
2021-06-23 06:38:05 +00:00
|
|
|
func (api *PublicAPI) Status() map[string]hexutil.Uint {
|
2021-06-21 14:06:30 +00:00
|
|
|
api.logger.Debug("txpool_status")
|
|
|
|
return map[string]hexutil.Uint{
|
|
|
|
"pending": hexutil.Uint(0),
|
|
|
|
"queued": hexutil.Uint(0),
|
|
|
|
}
|
|
|
|
}
|