Implemented POW on each image upload

This commit is contained in:
Mawoka
2022-06-23 21:17:45 +02:00
parent 5900719913
commit 6e04dfc60d
2 changed files with 23 additions and 0 deletions
+19
View File
@@ -4,17 +4,35 @@
import { dataSchema } from '$lib/yupSchemas';
import Spinner from '../Spinner.svelte';
import { fade } from 'svelte/transition';
import { mint } from '$lib/hashcash';
export let data: EditorData;
export let selected_question: number;
export let edit_id: string;
export let pow_data;
let pow_salt: string;
const empty_answer: Answer = {
right: false,
answer: ''
};
let uppyOpen = false;
const computePOW = async (salt: string) => {
console.log('Called!');
if (pow_salt === undefined) {
return;
}
console.log('Computing POW');
pow_data = await mint(salt, 17, '', 8, false);
pow_salt = undefined;
return;
};
$: {
pow_salt;
computePOW(pow_salt);
}
/*eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }]*/
const correctTimeInput = (_) => {
let time = data.questions[selected_question].time;
@@ -82,6 +100,7 @@
bind:data
bind:selected_question
bind:pow_data
bind:pow_salt
/>
{/await}
{/if}