Skip to content

Commit

Permalink
vms/platformvm: Remove EnableAdding and DisableAdding from `Mem…
Browse files Browse the repository at this point in the history
…pool` interface (#2463)
  • Loading branch information
dhrubabasu authored Dec 11, 2023
1 parent 159aafb commit 4e5b20e
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 47 deletions.
2 changes: 0 additions & 2 deletions vms/platformvm/block/builder/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,9 +192,7 @@ func (b *builder) ShutdownBlockTimer() {
// This method removes the transactions from the returned
// blocks from the mempool.
func (b *builder) BuildBlock(context.Context) (snowman.Block, error) {
b.Mempool.DisableAdding()
defer func() {
b.Mempool.EnableAdding()
// If we need to advance the chain's timestamp in a standard block, but
// we build an invalid block, then we need to re-trigger block building.
//
Expand Down
21 changes: 0 additions & 21 deletions vms/platformvm/txs/mempool/mempool.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ var (
)

type Mempool interface {
// we may want to be able to stop valid transactions
// from entering the mempool, e.g. during blocks creation
EnableAdding()
DisableAdding()

Add(tx *txs.Tx) error
Has(txID ids.ID) bool
Get(txID ids.ID) *txs.Tx
Expand Down Expand Up @@ -86,9 +81,6 @@ type Mempool interface {
// Transactions from clients that have not yet been put into blocks and added to
// consensus
type mempool struct {
// If true, drop transactions added to the mempool via Add.
dropIncoming bool

bytesAvailableMetric prometheus.Gauge
bytesAvailable int

Expand Down Expand Up @@ -137,24 +129,11 @@ func New(

droppedTxIDs: &cache.LRU[ids.ID, error]{Size: droppedTxIDsCacheSize},
consumedUTXOs: set.NewSet[ids.ID](initialConsumedUTXOsSize),
dropIncoming: false, // enable tx adding by default
toEngine: toEngine,
}, nil
}

func (m *mempool) EnableAdding() {
m.dropIncoming = false
}

func (m *mempool) DisableAdding() {
m.dropIncoming = true
}

func (m *mempool) Add(tx *txs.Tx) error {
if m.dropIncoming {
return fmt.Errorf("tx %s not added because mempool is closed", tx.ID())
}

switch tx.Unsigned.(type) {
case *txs.AdvanceTimeTx:
return errCantIssueAdvanceTimeTx
Expand Down
24 changes: 0 additions & 24 deletions vms/platformvm/txs/mempool/mock_mempool.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4e5b20e

Please sign in to comment.