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