# All files / lib/chain ChainMemoryStore.ts

71.43% Statements 5/7
100% Branches 0/0
66.67% Functions 4/6
71.43% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35

    1x
    6x

    8x

    2x

    6x

     /* eslint-disable @typescript-eslint/require-await */
    import { DlcTransactions } from '../messages/DlcTransactions';
    import { IDlcStore } from './DlcStore';

    /**
     * In-memory implementation of the IDlcStore.
     */
    export class ChainMemoryStore implements IDlcStore {
      private _dlcTxs = new Map<Buffer, DlcTransactions>();

      public get dlcTransactionsListCount(): number {
        return this._dlcTxs.size;
      }

      public async findDlcTransactionsList(): Promise<DlcTransactions[]> {
        return Array.from(this._dlcTxs.values());
      }

      public async findDlcTransactions(
        contractId: Buffer,
      ): Promise<DlcTransactions> {
        return this._dlcTxs.get(contractId);
      }

      public async saveDlcTransactions(
        dlcTransactions: DlcTransactions,
      ): Promise<void> {
        this._dlcTxs.set(dlcTransactions.contractId, dlcTransactions);
      }

      public async deleteDlcTransactions(contractId: Buffer): Promise<void> {
        this._dlcTxs.delete(contractId);
      }
    }