renaming mempool

This commit is contained in:
David Terpay 2023-08-15 11:28:02 -04:00
parent 80ac448d40
commit af85b86241
No known key found for this signature in database
GPG Key ID: 627EFB00DADF0CD1
6 changed files with 18 additions and 18 deletions

View File

@ -771,7 +771,7 @@ func (s *ProposalsTestSuite) setUpPanicLane(maxBlockSpace math.LegacyDec) *const
lane := constructor.NewLaneConstructor[string](
cfg,
"panic",
constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), cfg.TxEncoder, 0),
constructor.NewMempool[string](constructor.DefaultTxPriority(), cfg.TxEncoder, 0),
constructor.DefaultMatchHandler(),
)

View File

@ -16,7 +16,7 @@ type (
// It include's additional helper functions that allow users to determine if a
// transaction is already in the mempool and to compare the priority of two
// transactions.
ConstructorMempool[C comparable] struct {
Mempool[C comparable] struct {
// index defines an index of transactions.
index sdkmempool.Mempool
@ -79,9 +79,9 @@ func DefaultTxPriority() TxPriority[string] {
}
}
// NewConstructorMempool returns a new ConstructorMempool.
func NewConstructorMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *ConstructorMempool[C] {
return &ConstructorMempool[C]{
// NewMempool returns a new ConstructorMempool.
func NewMempool[C comparable](txPriority TxPriority[C], txEncoder sdk.TxEncoder, maxTx int) *Mempool[C] {
return &Mempool[C]{
index: NewPriorityMempool(
PriorityNonceMempoolConfig[C]{
TxPriority: txPriority,
@ -95,7 +95,7 @@ func NewConstructorMempool[C comparable](txPriority TxPriority[C], txEncoder sdk
}
// Insert inserts a transaction into the mempool.
func (cm *ConstructorMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error {
func (cm *Mempool[C]) Insert(ctx context.Context, tx sdk.Tx) error {
if err := cm.index.Insert(ctx, tx); err != nil {
return fmt.Errorf("failed to insert tx into auction index: %w", err)
}
@ -112,7 +112,7 @@ func (cm *ConstructorMempool[C]) Insert(ctx context.Context, tx sdk.Tx) error {
}
// Remove removes a transaction from the mempool.
func (cm *ConstructorMempool[C]) Remove(tx sdk.Tx) error {
func (cm *Mempool[C]) Remove(tx sdk.Tx) error {
if err := cm.index.Remove(tx); err != nil && !errors.Is(err, sdkmempool.ErrTxNotFound) {
return fmt.Errorf("failed to remove transaction from the mempool: %w", err)
}
@ -131,17 +131,17 @@ func (cm *ConstructorMempool[C]) Remove(tx sdk.Tx) error {
// remove a transaction from the mempool while iterating over the transactions,
// the iterator will not be aware of the removal and will continue to iterate
// over the removed transaction. Be sure to reset the iterator if you remove a transaction.
func (cm *ConstructorMempool[C]) Select(ctx context.Context, txs [][]byte) sdkmempool.Iterator {
func (cm *Mempool[C]) Select(ctx context.Context, txs [][]byte) sdkmempool.Iterator {
return cm.index.Select(ctx, txs)
}
// CountTx returns the number of transactions in the mempool.
func (cm *ConstructorMempool[C]) CountTx() int {
func (cm *Mempool[C]) CountTx() int {
return cm.index.CountTx()
}
// Contains returns true if the transaction is contained in the mempool.
func (cm *ConstructorMempool[C]) Contains(tx sdk.Tx) bool {
func (cm *Mempool[C]) Contains(tx sdk.Tx) bool {
_, txHashStr, err := utils.GetTxHashStr(cm.txEncoder, tx)
if err != nil {
return false
@ -152,7 +152,7 @@ func (cm *ConstructorMempool[C]) Contains(tx sdk.Tx) bool {
}
// Compare determines the relative priority of two transactions belonging in the same lane.
func (cm *ConstructorMempool[C]) Compare(ctx sdk.Context, this sdk.Tx, other sdk.Tx) int {
func (cm *Mempool[C]) Compare(ctx sdk.Context, this sdk.Tx, other sdk.Tx) int {
firstPriority := cm.txPriority.GetTxPriority(ctx, this)
secondPriority := cm.txPriority.GetTxPriority(ctx, other)
return cm.txPriority.Compare(firstPriority, secondPriority)

View File

@ -27,7 +27,7 @@ func NewDefaultLane(cfg block.LaneConfig) *DefaultLane {
lane := constructor.NewLaneConstructor[string](
cfg,
LaneName,
constructor.NewConstructorMempool[string](
constructor.NewMempool[string](
constructor.DefaultTxPriority(),
cfg.TxEncoder,
cfg.MaxTxs,

View File

@ -84,7 +84,7 @@ func (s *BaseTestSuite) TestCompareTxPriority() {
}
func (s *BaseTestSuite) TestInsert() {
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
mempool := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
s.Run("should be able to insert a transaction", func() {
tx, err := testutils.CreateRandomTx(
@ -136,7 +136,7 @@ func (s *BaseTestSuite) TestInsert() {
}
func (s *BaseTestSuite) TestRemove() {
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
mempool := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
s.Run("should be able to remove a transaction", func() {
tx, err := testutils.CreateRandomTx(
@ -174,7 +174,7 @@ func (s *BaseTestSuite) TestRemove() {
func (s *BaseTestSuite) TestSelect() {
s.Run("should be able to select transactions in the correct order", func() {
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
mempool := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,
@ -213,7 +213,7 @@ func (s *BaseTestSuite) TestSelect() {
})
s.Run("should be able to select a single transaction", func() {
mempool := constructor.NewConstructorMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
mempool := constructor.NewMempool[string](constructor.DefaultTxPriority(), s.encodingConfig.TxConfig.TxEncoder(), 3)
tx1, err := testutils.CreateRandomTx(
s.encodingConfig.TxConfig,

View File

@ -29,7 +29,7 @@ func NewFreeLane(
lane := constructor.NewLaneConstructor[string](
cfg,
LaneName,
constructor.NewConstructorMempool[string](
constructor.NewMempool[string](
txPriority,
cfg.TxEncoder,
cfg.MaxTxs,

View File

@ -52,7 +52,7 @@ func NewMEVLane(
LaneConstructor: constructor.NewLaneConstructor[string](
cfg,
LaneName,
constructor.NewConstructorMempool[string](
constructor.NewMempool[string](
TxPriority(factory),
cfg.TxEncoder,
cfg.MaxTxs,