mirror of
https://github.com/mCaptcha/mCaptcha.git
synced 2025-02-16 16:39:46 +03:00
fix: truncate pow compute time before submitting
This commit is contained in:
parent
3e5936cb83
commit
1b05cdc391
3 changed files with 2 additions and 9 deletions
|
@ -55,7 +55,7 @@ export const solveCaptchaRunner = async (e: Event): Promise<void> => {
|
|||
worker.onmessage = async (event: MessageEvent) => {
|
||||
const resp: ServiceWorkerWork = event.data;
|
||||
console.log(
|
||||
`Proof generated. Difficuly: ${config.difficulty_factor} Duration: ${resp.duration}`
|
||||
`Proof generated. Difficuly: ${config.difficulty_factor} Duration: ${resp.work.time}`
|
||||
);
|
||||
|
||||
const proof: Work = {
|
||||
|
@ -63,7 +63,7 @@ export const solveCaptchaRunner = async (e: Event): Promise<void> => {
|
|||
string: config.string,
|
||||
nonce: resp.work.nonce,
|
||||
result: resp.work.result,
|
||||
time: resp.work.time,
|
||||
time: Math.trunc(resp.work.time),
|
||||
worker_type: resp.work.worker_type,
|
||||
};
|
||||
|
||||
|
|
|
@ -19,15 +19,9 @@ onmessage = async (e) => {
|
|||
console.debug("message received at worker");
|
||||
const config: PoWConfig = e.data;
|
||||
|
||||
const t0 = performance.now();
|
||||
const work = await prove(config);
|
||||
|
||||
const t1 = performance.now();
|
||||
const duration = t1 - t0;
|
||||
|
||||
const res: ServiceWorkerWork = {
|
||||
work,
|
||||
duration,
|
||||
};
|
||||
|
||||
postMessage(res);
|
||||
|
|
|
@ -32,7 +32,6 @@ export type WasmWork = {
|
|||
|
||||
export type ServiceWorkerWork = {
|
||||
work: SubmitWork;
|
||||
duration: number;
|
||||
};
|
||||
|
||||
export type PoWConfig = {
|
||||
|
|
Loading…
Add table
Reference in a new issue