Skip to content

Commit 312b6af

Browse files
committed
small code improvement
1 parent aa02a36 commit 312b6af

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

yarn-project/p2p/src/mem_pools/tx_pool/eviction/invalid_txs_after_mining_rule.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { createLogger } from '@aztec/foundation/log';
22
import type { TxHash } from '@aztec/stdlib/tx';
33

44
import type { TxPoolOptions } from '../tx_pool.js';
5-
import type { EvictionContext, EvictionResult, EvictionRule, TxPoolOperations } from './eviction_strategy.js';
5+
import {
6+
type EvictionContext,
7+
EvictionEvent,
8+
type EvictionResult,
9+
type EvictionRule,
10+
type TxPoolOperations,
11+
} from './eviction_strategy.js';
612

713
/**
814
* Eviction rule that removes invalid transactions after a block is mined.
@@ -18,7 +24,7 @@ export class InvalidTxsAfterMiningRule implements EvictionRule {
1824
private log = createLogger('p2p:mempool:tx_pool:invalid_txs_after_mining_rule');
1925

2026
async evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult> {
21-
if (context.event !== 'block_mined') {
27+
if (context.event !== EvictionEvent.BLOCK_MINED) {
2228
return {
2329
reason: 'block_mined_invalid_txs',
2430
success: true,

yarn-project/p2p/src/mem_pools/tx_pool/eviction/invalid_txs_after_reorg_rule.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,13 @@ import { MerkleTreeId } from '@aztec/stdlib/trees';
44
import type { TxHash } from '@aztec/stdlib/tx';
55

66
import type { TxPoolOptions } from '../tx_pool.js';
7-
import type { EvictionContext, EvictionResult, EvictionRule, TxPoolOperations } from './eviction_strategy.js';
7+
import {
8+
type EvictionContext,
9+
EvictionEvent,
10+
type EvictionResult,
11+
type EvictionRule,
12+
type TxPoolOperations,
13+
} from './eviction_strategy.js';
814

915
/**
1016
* Eviction rule that removes invalid transactions after a blockchain reorganization.
@@ -21,7 +27,7 @@ export class InvalidTxsAfterReorgRule implements EvictionRule {
2127
public constructor(private worldState: ReadonlyWorldStateAccess) {}
2228

2329
async evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult> {
24-
if (context.event !== 'chain_pruned') {
30+
if (context.event !== EvictionEvent.CHAIN_PRUNED) {
2531
return {
2632
reason: 'reorg_invalid_txs',
2733
success: true,

yarn-project/p2p/src/mem_pools/tx_pool/eviction/low_priority_eviction_rule.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@ import { createLogger } from '@aztec/foundation/log';
22
import type { TxHash } from '@aztec/stdlib/tx';
33

44
import type { TxPoolOptions } from '../tx_pool.js';
5-
import type { EvictionContext, EvictionResult, EvictionRule, TxPoolOperations } from './eviction_strategy.js';
5+
import {
6+
type EvictionContext,
7+
EvictionEvent,
8+
type EvictionResult,
9+
type EvictionRule,
10+
type TxPoolOperations,
11+
} from './eviction_strategy.js';
612

713
export interface LowPriorityEvictionConfig {
814
/** Maximum number of pending transactions before eviction kicks in */
@@ -21,7 +27,7 @@ export class LowPriorityEvictionRule implements EvictionRule {
2127
constructor(private config: LowPriorityEvictionConfig) {}
2228

2329
public async evict(context: EvictionContext, txPool: TxPoolOperations): Promise<EvictionResult> {
24-
if (context.event !== 'txs_added') {
30+
if (context.event !== EvictionEvent.TXS_ADDED) {
2531
return {
2632
reason: 'low_priority',
2733
success: true,

0 commit comments

Comments
 (0)