Skip to content

Commit

Permalink
fix: make nonce generator singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
amalcaraz committed Oct 30, 2024
1 parent 199f071 commit 97057d8
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 5 deletions.
5 changes: 5 additions & 0 deletions packages/ethereum/src/services/indexer/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
IndexableEntityType,
IndexerMsClient,
IndexerWorkerDomainI,
NonceTimestamp,
ParserMsClient,
} from '@aleph-indexer/framework'
import { EthereumParsedLog, EthereumParsedTransaction } from '../parser/src/types.js'
Expand Down Expand Up @@ -46,13 +47,16 @@ export async function ethereumIndexerFactory(

// Instances

const nonce = new NonceTimestamp()

const transactionFetcher = new EthereumIndexerTransactionFetcher(
blockchainId,
fetcherMsClient,
transactionRequestDAL,
transactionRequestIncomingEntityDAL,
transactionRequestPendingSignatureDAL,
transactionRequestResponseDAL,
nonce
)

const transactionFetcherMain = new BaseEntityIndexer(
Expand All @@ -73,6 +77,7 @@ export async function ethereumIndexerFactory(
logRequestIncomingEntityDAL,
logRequestPendingSignatureDAL,
logRequestResponseDAL,
nonce
)

const logFetcherMain = new BaseEntityIndexer(
Expand Down
2 changes: 1 addition & 1 deletion packages/ethereum/src/services/indexer/src/logFetcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class EthereumIndexerLogFetcher extends BaseIndexerEntityFetcher<Ethereum
protected logRequestIncomingLogDAL: EntityRequestIncomingEntityStorage<EthereumParsedLog>,
protected logRequestPendingSignatureDAL: EntityRequestPendingEntityStorage,
protected logRequestResponseDAL: EntityRequestResponseStorage<EthereumParsedLog>,
protected nonce: NonceTimestamp = new NonceTimestamp(),
protected nonce: NonceTimestamp,
) {
super(
blockchainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class EthereumIndexerTransactionFetcher extends BaseIndexerEntityFetcher<
protected transactionRequestIncomingTransactionDAL: EntityRequestIncomingEntityStorage<EthereumParsedTransaction>,
protected transactionRequestPendingSignatureDAL: EntityRequestPendingEntityStorage,
protected transactionRequestResponseDAL: EntityRequestResponseStorage<EthereumParsedTransaction>,
protected nonce: NonceTimestamp = new NonceTimestamp(),
protected nonce: NonceTimestamp,
) {
super(
blockchainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export abstract class BaseIndexerEntityFetcher<
protected entityRequestIncomingEntityDAL: EntityRequestIncomingEntityStorage<T>,
protected entityRequestPendingEntityDAL: EntityRequestPendingEntityStorage,
protected entityRequestResponseDAL: EntityRequestResponseStorage<T>,
protected nonce: NonceTimestamp = new NonceTimestamp(),
protected nonce: NonceTimestamp,
) {
this.incomingEntities = new PendingWorkPool({
id: `${type}-indexer-incoming-entities`,
Expand Down
6 changes: 5 additions & 1 deletion packages/solana/src/services/indexer/factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
IndexerWorkerDomainI,
ParserMsClient,
BaseEntityIndexer,
BaseIndexer
BaseIndexer,
NonceTimestamp
} from '@aleph-indexer/framework'
import { SolanaParsedTransaction } from '../../types.js'
import { SolanaIndexerTransactionFetcher } from './src/transactionFetcher.js'
Expand All @@ -36,13 +37,16 @@ export async function solanaIndexerFactory(
const transactionRequestResponseDAL = createEntityRequestResponseDAL(basePath, IndexableEntityType.Transaction)
const transactionIndexerStateDAL = createEntityIndexerStateDAL(basePath, IndexableEntityType.Transaction)

const nonce = new NonceTimestamp()

const transactionFetcher = new SolanaIndexerTransactionFetcher(
blockchainId,
fetcherMsClient,
transactionRequestDAL,
transactionRequestIncomingTransactionDAL,
transactionRequestPendingSignatureDAL,
transactionRequestResponseDAL,
nonce
)

const transactionFetcherMain = new BaseEntityIndexer(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class SolanaIndexerTransactionFetcher extends BaseIndexerEntityFetcher<So
protected transactionRequestIncomingTransactionDAL: EntityRequestIncomingEntityStorage<SolanaParsedTransaction>,
protected transactionRequestPendingSignatureDAL: EntityRequestPendingEntityStorage,
protected transactionRequestResponseDAL: EntityRequestResponseStorage<SolanaParsedTransaction>,
protected nonce: NonceTimestamp = new NonceTimestamp(),
protected nonce: NonceTimestamp,
) {
super(
blockchainId,
Expand Down

0 comments on commit 97057d8

Please sign in to comment.