import ITransactionStore from '../core/interfaces/ITransactionStore'; import TransactionModel from './models/TransactionModel'; /** * Implementation of ITransactionStore that stores the transaction data in a MongoDB database. */ export default class MongoDbTransactionStore implements ITransactionStore { private serverUrl; /** Default database name used if not specified in constructor. */ static readonly defaultDatabaseName: string; /** Collection name for transactions. */ static readonly transactionCollectionName: string; /** Database name used by this transaction store. */ readonly databaseName: string; private db; private transactionCollection; /** * Constructs a `MongoDbTransactionStore`; * @param retryExponentialDelayFactor * The exponential delay factor in milliseconds for retries of unresolvable transactions. * e.g. if it is set to 1 seconds, then the delays for retries will be 1 second, 2 seconds, 4 seconds... until the transaction can be resolved. */ constructor(serverUrl: string, databaseName?: string); /** * Initialize the MongoDB transaction store. */ initialize(): Promise; /** * Returns the number of transactions in the store. * Mainly used by tests. */ getTransactionsCount(): Promise; getTransaction(transactionNumber: number): Promise; getTransactionsLaterThan(transactionNumber: number | undefined, max: number): Promise; /** * Clears the transaction store. */ clearCollection(): Promise; addTransaction(transaction: TransactionModel): Promise; getLastTransaction(): Promise; getExponentiallySpacedTransactions(): Promise; removeTransactionsLaterThan(transactionNumber?: number): Promise; /** * Gets the list of processed transactions. * Mainly used for test purposes. */ getTransactions(): Promise; /** * Creates the `transaction` collection with indexes if it does not exists. * @returns The existing collection if exists, else the newly created collection. */ private static createTransactionCollectionIfNotExist; }