diff --git a/cmd/wasm/main.go b/cmd/wasm/main.go index d582ba9..4ef07ad 100644 --- a/cmd/wasm/main.go +++ b/cmd/wasm/main.go @@ -14,11 +14,9 @@ const Bits = 1024 func main() { fmt.Printf("Hello %s\n", "World") - js.Global().Set("runTLP", tlpWrapped()) js.Global().Set("generateTLP", generateTLP()) js.Global().Set("solveTLP", solveTLP()) - js.Global().Set("runLHTLP", lhtlpWrapped()) js.Global().Set("generateLHTLP", generateLHTLP()) js.Global().Set("solveLHTLP", solveLHTLP()) @@ -75,26 +73,6 @@ func solveTLP() js.Func { }) } -func tlpWrapped() js.Func { - return js.FuncOf(func(this js.Value, args []js.Value) any { - if len(args) != 2 { - return "Invalid number of arguments passed." - } - - message := args[0].Int() - difficulty := args[1].Int() - - fmt.Printf("Bits: %d\n", Bits) - fmt.Printf("Message: %d\n", message) - fmt.Printf("Difficulty: %d\n", difficulty) - - puzzle := tlp.Generate(Bits, message, difficulty) - solution := tlp.Solve(puzzle) - - return solution.String() - }) -} - func generateLHTLP() js.Func { return js.FuncOf(func(this js.Value, args []js.Value) any { if len(args) != 3 { @@ -152,30 +130,3 @@ func solveLHTLP() js.Func { return solution.String() }) } - -func lhtlpWrapped() js.Func { - return js.FuncOf(func(this js.Value, args []js.Value) any { - if len(args) != 3 { - return "Invalid number of arguments passed." - } - - message1 := args[0].Int() - message2 := args[1].Int() - difficulty := args[2].Int() - - fmt.Printf("Bits: %d\n", Bits) - fmt.Printf("Message #1: %d\n", message1) - fmt.Printf("Message #2: %d\n", message2) - fmt.Printf("Difficulty: %d\n", difficulty) - - params := lhtlp.NewParams(Bits, difficulty) - puzzle1 := lhtlp.NewPuzzle(*params, message1) - puzzle2 := lhtlp.NewPuzzle(*params, message2) - - puzzle3 := puzzle1.Add(*puzzle2) - - solution := lhtlp.Solve(*puzzle3) - - return solution.String() - }) -} diff --git a/frontend/src/assets/main.wasm b/frontend/src/assets/main.wasm index d691885..9bf205f 100755 Binary files a/frontend/src/assets/main.wasm and b/frontend/src/assets/main.wasm differ diff --git a/frontend/src/constants.js b/frontend/src/constants.js index 0fec39b..ae02662 100644 --- a/frontend/src/constants.js +++ b/frontend/src/constants.js @@ -3,8 +3,6 @@ export const TLP_PATH = "/tlp"; export const LHTLP_PATH = "/lhtlp"; export const RESULT = "RESULT"; export const INITIALIZED = "INITIALIZED"; -export const CALL_RUN_TLP = "CALL_RUN_TLP"; -export const CALL_RUN_LHTLP = "CALL_RUN_LHTLP"; export const GENERATE_TLP = "GENERATE_TLP"; export const GENERATE_LHTLP = "GENERATE_LHTLP"; export const SOLVE_TLP = "SOLVE_TLP"; diff --git a/frontend/src/hooks.js b/frontend/src/hooks.js index b6bbdd3..c7f069e 100644 --- a/frontend/src/hooks.js +++ b/frontend/src/hooks.js @@ -5,8 +5,6 @@ import { useEffect, useState } from "preact/hooks"; import WasmWorker from "./worker.js?worker"; import { RESULT, - CALL_RUN_TLP, - CALL_RUN_LHTLP, GENERATE_TLP, SOLVE_TLP, GENERATE_LHTLP, @@ -37,26 +35,6 @@ export function useWorker() { } } - function runTLP(message, difficulty) { - worker.postMessage({ - id: getId(), - type: CALL_RUN_TLP, - data: [message, difficulty], - }); - - return id; - } - - function runLHTLP(message1, message2, difficulty) { - worker.postMessage({ - id: getId(), - type: CALL_RUN_LHTLP, - data: [message1, message2, difficulty], - }); - - return id; - } - function generateTLP(message, difficulty) { worker.postMessage({ id: getId(), @@ -107,8 +85,6 @@ export function useWorker() { return { results, - runTLP, - runLHTLP, generateTLP, solveTLP, generateLHTLP, diff --git a/frontend/src/worker.js b/frontend/src/worker.js index ab0a0d7..16f8eec 100644 --- a/frontend/src/worker.js +++ b/frontend/src/worker.js @@ -6,8 +6,6 @@ import wasmURL from "./assets/main.wasm"; import * as _ from "./assets/wasm_exec.js?inline"; import { RESULT, - CALL_RUN_TLP, - CALL_RUN_LHTLP, GENERATE_TLP, SOLVE_TLP, GENERATE_LHTLP, @@ -40,23 +38,7 @@ self.addEventListener( console.log("worker.js - event.data", event.data); - if (type === CALL_RUN_TLP) { - const result = self.runTLP(...data); - - self.postMessage({ - id, - type: RESULT, - data: result, - }); - } else if (type === CALL_RUN_LHTLP) { - const result = self.runLHTLP(...data); - - self.postMessage({ - id, - type: RESULT, - data: result, - }); - } else if (type === GENERATE_TLP) { + if (type === GENERATE_TLP) { const result = self.generateTLP(...data); self.postMessage({