From 0525b144b72e89488bd65509ddd62eba7dedd89a Mon Sep 17 00:00:00 2001 From: einhornimmond Date: Wed, 22 Oct 2025 10:38:40 +0200 Subject: [PATCH] remove not longer used stuff, fix lint workflow --- .github/workflows/lint.yml | 1 + .../graphql/resolver/TransactionResolver.ts | 2 - backend/src/index.ts | 4 -- backend/src/util/InterruptiveSleep.ts | 27 -------- backend/src/util/InterruptiveSleepManager.ts | 67 ------------------- 5 files changed, 1 insertion(+), 100 deletions(-) delete mode 100644 backend/src/util/InterruptiveSleep.ts delete mode 100644 backend/src/util/InterruptiveSleepManager.ts diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 99124cf34..df24c2b9f 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,6 +12,7 @@ jobs: backend: ${{ steps.backend.outputs.success }} database: ${{ steps.database.outputs.success }} dht-node: ${{ steps.dht-node.outputs.success }} + dlt-connector: ${{ steps.dlt-connector.outputs.success }} federation: ${{ steps.federation.outputs.success }} steps: - name: Checkout diff --git a/backend/src/graphql/resolver/TransactionResolver.ts b/backend/src/graphql/resolver/TransactionResolver.ts index 0bd77166c..4575a8b3e 100644 --- a/backend/src/graphql/resolver/TransactionResolver.ts +++ b/backend/src/graphql/resolver/TransactionResolver.ts @@ -185,8 +185,6 @@ export const executeTransaction = async ( await queryRunner.release() } - // notify dlt-connector loop for new work - // InterruptiveSleepManager.getInstance().interrupt(TRANSMIT_TO_IOTA_INTERRUPTIVE_SLEEP_KEY) await sendTransactionReceivedEmail({ firstName: recipient.firstName, lastName: recipient.lastName, diff --git a/backend/src/index.ts b/backend/src/index.ts index d7e883933..80d6d5d7e 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -20,10 +20,6 @@ async function main() { console.log(`GraphIQL available at http://localhost:${CONFIG.PORT}`) } }) - // task is running the whole time for transmitting transaction via dlt-connector to iota - // can be notified with InterruptiveSleepManager.getInstance().interrupt(TRANSMIT_TO_IOTA_INTERRUPTIVE_SLEEP_KEY) - // that a new transaction or user was stored in db - // void sendTransactionsToDltConnector() void startValidateCommunities(Number(CONFIG.FEDERATION_VALIDATE_COMMUNITY_TIMER)) } diff --git a/backend/src/util/InterruptiveSleep.ts b/backend/src/util/InterruptiveSleep.ts deleted file mode 100644 index 86afcf9b5..000000000 --- a/backend/src/util/InterruptiveSleep.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { delay } from 'core' - -/** - * Sleep, that can be interrupted - * call sleep only for msSteps and than check if interrupt was called - */ -export class InterruptiveSleep { - private interruptSleep = false - private msSteps = 10 - - constructor(msSteps: number) { - this.msSteps = msSteps - } - - public interrupt(): void { - this.interruptSleep = true - } - - public async sleep(ms: number): Promise { - let waited = 0 - this.interruptSleep = false - while (waited < ms && !this.interruptSleep) { - await delay(this.msSteps) - waited += this.msSteps - } - } -} diff --git a/backend/src/util/InterruptiveSleepManager.ts b/backend/src/util/InterruptiveSleepManager.ts deleted file mode 100644 index 246269623..000000000 --- a/backend/src/util/InterruptiveSleepManager.ts +++ /dev/null @@ -1,67 +0,0 @@ -import { LogError } from '@/server/LogError' - -import { InterruptiveSleep } from './InterruptiveSleep' - -// Source: https://refactoring.guru/design-patterns/singleton/typescript/example -// and ../federation/client/FederationClientFactory.ts -/** - * Managing Instances of interruptive sleep it is inspired from conditions from c++ multithreading - * It is used for separate worker threads which will go to sleep after they haven't anything todo left, - * but with this Manager and InterruptiveSleep Object it sleeps only stepSize and check if something interrupted his sleep, - * so he can check for new work - */ -export const TRANSMIT_TO_IOTA_INTERRUPTIVE_SLEEP_KEY = 'transmitToIota' - -// eslint-disable-next-line @typescript-eslint/no-extraneous-class -export class InterruptiveSleepManager { - // eslint-disable-next-line no-use-before-define - private static instance: InterruptiveSleepManager - private interruptiveSleep: Map = new Map() - private stepSizeMilliseconds = 10 - - /** - * The Singleton's constructor should always be private to prevent direct - * construction calls with the `new` operator. - */ - // eslint-disable-next-line no-useless-constructor, @typescript-eslint/no-empty-function - private constructor() {} - - /** - * The static method that controls the access to the singleton instance. - * - * This implementation let you subclass the Singleton class while keeping - * just one instance of each subclass around. - */ - public static getInstance(): InterruptiveSleepManager { - if (!InterruptiveSleepManager.instance) { - InterruptiveSleepManager.instance = new InterruptiveSleepManager() - } - return InterruptiveSleepManager.instance - } - - /** - * only for new created InterruptiveSleepManager Entries! - * @param step size in ms in which new! InterruptiveSleepManager check if they where triggered - */ - public setStepSize(ms: number) { - this.stepSizeMilliseconds = ms - } - - public interrupt(key: string): void { - const interruptiveSleep = this.interruptiveSleep.get(key) - if (interruptiveSleep) { - interruptiveSleep.interrupt() - } - } - - public sleep(key: string, ms: number): Promise { - if (!this.interruptiveSleep.has(key)) { - this.interruptiveSleep.set(key, new InterruptiveSleep(this.stepSizeMilliseconds)) - } - const interruptiveSleep = this.interruptiveSleep.get(key) - if (!interruptiveSleep) { - throw new LogError('map entry not exist after setting it') - } - return interruptiveSleep.sleep(ms) - } -}