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 36 37 38 39 40 41 42 43 44 45 46 47 48 | 28x 28x 28x 28x 28x | import { sdk } from '../..';
import { WalletMonitor } from '../WalletMonitor';
import { WalletMonitorTask } from './WalletMonitorTask';
export class TaskNotifyOfProofs extends WalletMonitorTask {
static taskName = 'NotifyOfProofs';
/**
* Set to true to trigger running this task
*/
static checkNow = false;
constructor(monitor: WalletMonitor, public triggerMsecs = 0) {
super(monitor, TaskNotifyOfProofs.taskName);
}
/**
* Normally triggered by checkNow getting set to true when a new proof is obtained.
*/
trigger(nowMsecsSinceEpoch: number): { run: boolean; } {
return {
run: (
TaskNotifyOfProofs.checkNow ||
this.triggerMsecs > 0 && nowMsecsSinceEpoch - this.lastRunMsecsSinceEpoch > this.triggerMsecs
)
};
}
async runTask(): Promise<void> {
TaskNotifyOfProofs.checkNow = false;
const limit = 100;
let offset = 0;
for (; ;) {
let log = '';
const reqs = await this.storage.findProvenTxReqs({ partial: { notified: false }, status: sdk.ProvenTxReqTerminalStatus, paged: { limit, offset } });
Iif (reqs.length === 0) break;
log += `NotifyOfProofs: ${reqs.length} reqs with notified false\n`;
const r = await this.monitor.notifyOfProvenTx(reqs, 2);
log += r.log;
console.log(log);
Iif (reqs.length < limit) break;
offset += limit;
}
}
}
|