nano-rspow-web 0.5.10 → 0.5.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +21 -2
- package/nano_rspow_web_bg.wasm +0 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,6 +30,19 @@ console.log("Is GPU:", result.is_gpu); // true/false
|
|
|
30
30
|
const isValid = validate_work(hash, result.nonce, threshold); // true
|
|
31
31
|
```
|
|
32
32
|
|
|
33
|
+
## Benchmarking Dashboard
|
|
34
|
+
|
|
35
|
+
<img align="right" src="assets/benchmark-ui.png" width="480" alt="Benchmarking Dashboard" />
|
|
36
|
+
An interactive benchmarking dashboard is included in `browser-demo/index.html` to measure WebGPU and CPU WebAssembly performance.
|
|
37
|
+
|
|
38
|
+
Try it out for yourself: **[https://casualsecurityinc.github.io/nano-rspow/](https://casualsecurityinc.github.io/nano-rspow/)**
|
|
39
|
+
|
|
40
|
+
<br clear="right" />
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
|
|
33
46
|
## API Reference
|
|
34
47
|
|
|
35
48
|
### `init(module_or_path)`
|
|
@@ -38,8 +51,8 @@ Initializes the WASM loader. Must be awaited before calling other functions.
|
|
|
38
51
|
### `generate_work(hash_hex: string, threshold_hex: string): Promise<GenerateResult>`
|
|
39
52
|
Asynchronously generates Proof of Work for a 32-byte block hash. Tries WebGPU first, falling back to CPU WebAssembly.
|
|
40
53
|
|
|
41
|
-
### `generate_work_gpu(hash_hex: string, threshold_hex: string): Promise<GenerateResult>`
|
|
42
|
-
Forces WebGPU PoW generation. Rejects if WebGPU is unavailable.
|
|
54
|
+
### `generate_work_gpu(hash_hex: string, threshold_hex: string, cancel_token: WasmCancelToken): Promise<GenerateResult>`
|
|
55
|
+
Forces WebGPU PoW generation. Rejects if WebGPU is unavailable or if the cancellation token is triggered.
|
|
43
56
|
|
|
44
57
|
### `generate_work_cpu(hash_hex: string, threshold_hex: string): GenerateResult`
|
|
45
58
|
Synchronously generates PoW forcing single-threaded CPU WebAssembly.
|
|
@@ -47,6 +60,12 @@ Synchronously generates PoW forcing single-threaded CPU WebAssembly.
|
|
|
47
60
|
### `validate_work(hash_hex: string, nonce_hex: string, threshold_hex: string): boolean`
|
|
48
61
|
Synchronously validates whether a nonce meets the difficulty threshold for the given block hash.
|
|
49
62
|
|
|
63
|
+
### `WasmCancelToken`
|
|
64
|
+
A class utilized to signal cancellation to the asynchronous GPU solver loop.
|
|
65
|
+
* `new WasmCancelToken()`: Instantiates a new token.
|
|
66
|
+
* `cancel()`: Aborts the ongoing GPU compute loop.
|
|
67
|
+
|
|
68
|
+
|
|
50
69
|
---
|
|
51
70
|
|
|
52
71
|
## Browser Compatibility
|
package/nano_rspow_web_bg.wasm
CHANGED
|
Binary file
|