Skip to content

Commit

Permalink
add detection job
Browse files Browse the repository at this point in the history
  • Loading branch information
RaaCT0R committed Nov 11, 2024
1 parent eb5293e commit 7383baa
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/configs/Configs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ class Configs {
static multiSigCleanUpInterval = 120; // seconds
static tssInstanceRestartGap = 5; // seconds
static tssUpdateInterval = 10; // seconds
static detectionUpdateInterval = 10; // seconds
static timeoutProcessorInterval = getConfigIntKeyOrDefault(
'intervals.timeoutProcessorInterval',
3600
Expand Down
20 changes: 20 additions & 0 deletions src/jobs/runProcessors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import ColdStorageConfig from '../coldStorage/ColdStorageConfig';
import TxAgreement from '../agreement/TxAgreement';
import ArbitraryProcessor from '../arbitrary/ArbitraryProcessor';
import EventSynchronization from '../synchronization/EventSynchronization';
import DetectionHandler from '../handlers/DetectionHandler';
import { DefaultLoggerFactory } from '@rosen-bridge/abstract-logger';

const logger = DefaultLoggerFactory.getInstance().getLogger(import.meta.url);

/**
* sends generated tx to agreement
Expand Down Expand Up @@ -119,6 +123,21 @@ const eventSyncJob = async () => {
setTimeout(eventSyncJob, Configs.eventSyncInterval * 1000);
};

/**
* runs Detection update job
*/
const detectionUpdateJob = () => {
DetectionHandler.getInstance()
.update()
.then(() =>
setTimeout(detectionUpdateJob, Configs.detectionUpdateInterval * 1000)
)
.catch((e) => {
logger.error(`Detection update job failed with error: ${e}`);
setTimeout(detectionUpdateJob, Configs.detectionUpdateInterval * 1000);
});
};

/**
* runs all processors and their related jobs
*/
Expand All @@ -133,6 +152,7 @@ const runProcessors = () => {
Configs.requeueWaitingEventsInterval * 1000
);
setTimeout(eventSyncJob, Configs.eventSyncInterval * 1000);
setTimeout(detectionUpdateJob, Configs.detectionUpdateInterval * 1000);
};

export { runProcessors };

0 comments on commit 7383baa

Please sign in to comment.