-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1517 from 0chain/feat/wasm-worker
Web workers in wasm
- Loading branch information
Showing
29 changed files
with
1,437 additions
and
209 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
|
||
<head> | ||
<!-- for zcn.wasm--> | ||
<script src="https://cdn.jsdelivr.net/gh/herumi/bls-wasm@v1.0.0/browser/bls.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/herumi/bls-wasm@v1.1.1/browser/bls.js"></script> | ||
<script src="https://cdn.jsdelivr.net/gh/golang/[email protected]/misc/wasm/wasm_exec.js"></script> | ||
<script src="zcn.js"></script> | ||
|
||
|
@@ -211,7 +211,7 @@ <h2>please download zcn.wasm from https://github.com/0chain/gosdk/releases/lates | |
|
||
let network = query.get('network') | ||
if (!network || network == 'undefined') { | ||
network = "mainnet.zus.network" | ||
network = "mob.zus.network" | ||
} | ||
|
||
const blockWorker = 'https://' + network + '/dns'; | ||
|
@@ -457,12 +457,12 @@ <h2>please download zcn.wasm from https://github.com/0chain/gosdk/releases/lates | |
allocationId: allocationId, | ||
remotePath: `/${file.name}`, | ||
file: file, | ||
thumbnailBytes: await readBytes(file),//only for demo, don't upload original file as thumbnail in production | ||
// thumbnailBytes: await readBytes(file),//only for demo, don't upload original file as thumbnail in production | ||
encrypt: false, | ||
webstreaming: false, | ||
isUpdate: false, | ||
isRepair: false, | ||
numBlocks: 100, | ||
numBlocks: 120, | ||
callback: function (totalBytes, completedBytes, error) { | ||
console.log(file.name + " " + completedBytes + "/" + totalBytes + " err:" + error) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
importScripts('https://rawgit.com/satazor/SparkMD5/master/spark-md5.min.js'); | ||
|
||
self.addEventListener('message', (e) => { | ||
const file = e.data; | ||
const chunkSize = 128 * 1024;// 128KB | ||
//create fileReaderSync | ||
const totalParts = Math.ceil(file.size / chunkSize); | ||
const fileReaderSync = new FileReaderSync(); | ||
const spark = new self.SparkMD5.ArrayBuffer(); | ||
for (let i = 0; i < totalParts; i++) { | ||
const start = i * chunkSize; | ||
const end = Math.min(file.size, start + chunkSize); | ||
const buffer = fileReaderSync.readAsArrayBuffer(file.slice(start, end)); | ||
|
||
spark.append(buffer); | ||
} | ||
const hash = spark.end(); | ||
self.postMessage(hash); | ||
}); |
Oops, something went wrong.