Skip to content

Create factory for PendingTransactionStorage selection #4502

@konstantinabl

Description

@konstantinabl

Problem

Storage selection logic lives in Relay:

const storage = this.redisClient
  ? new RedisPendingTransactionStorage(this.redisClient)
  : new LocalPendingTransactionStorage();

Relay shouldn't know about storage implementation details.

Solution

Add factory method:

export class PendingTransactionStorageFactory {
  static create(redisClient?: RedisClientType): PendingTransactionStorage {
    return redisClient 
      ? new RedisPendingTransactionStorage(redisClient)
      : new LocalPendingTransactionStorage();
  }
}

// In Relay
const storage = PendingTransactionStorageFactory.create(this.redisClient);

Benefits

  • Encapsulates storage selection logic where it belongs
  • Relay stays focused on orchestration
  • Easier to add new storage types

Acceptance Criteria

  • Factory method created
  • Relay uses factory
  • Tests passing

Metadata

Metadata

Assignees

Labels

Technical DebtIssue which resolves technical debtinternalFor changes that affect the project's internal workings but not its outward-facing functionality.

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions