All files / src/monitor/tasks TaskValidate.ts

44.44% Statements 4/9
0% Branches 0/4
0% Functions 0/3
44.44% Lines 4/9

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  28x     28x 28x         28x                                            
import { WalletMonitor } from '../WalletMonitor';
import { WalletMonitorTask } from './WalletMonitorTask';
 
 
export class TaskValidate extends WalletMonitorTask {
    static taskName = 'Validate';
 
    /**
     * Set to true to trigger running this task
     */
    static checkNow = false;
 
    constructor(monitor: WalletMonitor, public triggerMsecs = 0) {
        super(monitor, TaskValidate.taskName);
    }
 
    trigger(nowMsecsSinceEpoch: number): { run: boolean; } {
        return {
            run: (
                TaskValidate.checkNow ||
                this.triggerMsecs > 0 && nowMsecsSinceEpoch - this.lastRunMsecsSinceEpoch > this.triggerMsecs
            )
        };
    }
 
    async runTask(): Promise<void> {
        TaskValidate.checkNow = false;
 
        //await this.monitor.validate(ValidateWhat.All, 'fix')
        console.log("Validate done");
    }
}