/ tracker / transactions-cache.js
transactions-cache.js
 1  /*!
 2   * tracker/transactions-cache.js
 3   * Copyright © 2023 – Katana Cryptographic Ltd. All Rights Reserved.
 4   */
 5  
 6  import QuickLRU from 'quick-lru'
 7  
 8  /**
 9   * Cache of txids, for avoiding triple-check behavior.
10   * ZMQ sends the transaction twice:
11   * 1. When it enters the mempool
12   * 2. When it leaves the mempool (mined or orphaned)
13   * Additionally, the transaction comes in a block
14   * Orphaned transactions are deleted during the routine check
15   */
16  export const TransactionsCache = new QuickLRU({
17      // Maximum number of txids to store in cache
18      maxSize: 100000,
19      // Maximum age for items in the cache.
20      maxAge: 7 * 24 * 60 * 60 * 1000 // 7 days
21  })