Skip to content
This repository has been archived by the owner on Aug 31, 2023. It is now read-only.

Commit

Permalink
Merge pull request #51 from SaitoTech/develop
Browse files Browse the repository at this point in the history
wasm bug fixing
  • Loading branch information
SankaD committed Aug 23, 2023
2 parents 7eb8510 + 2bb53a5 commit 7e7882c
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
11 changes: 8 additions & 3 deletions lib/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,14 @@ export default class Block extends WasmWrapper<WasmBlock> {
}

public get transactions(): Array<Transaction> {
return this.instance.transactions.map((tx) => {
return Saito.getInstance().factory.createTransaction(tx);
});
try {
return this.instance.transactions.map((tx) => {
return Saito.getInstance().factory.createTransaction(tx);
});
} catch (error) {
console.error(error);
return [];
}
}

public get id(): bigint {
Expand Down
5 changes: 4 additions & 1 deletion lib/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ export default class Blockchain extends WasmWrapper<WasmBlockchain> {
}
} catch (error) {
console.error(error);
console.log("callback index : " + callbackIndices[j]);
console.error("callback index : " + callbackIndices[j]);
console.error("block type : " + block.block_type);
console.error("block id : " + block.id);
console.error("block hash : " + block.hash);
console.error("tx causing error", block.transactions[callbackIndices[j]].msg);
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/custom/shared_methods.web.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ export default class WebSharedMethods extends CustomSharedMethods {
sendMessage(peerIndex: bigint, buffer: Uint8Array): void {
// console.debug("sending message to peer : " + peerIndex + " with size : " + buffer.byteLength);
let socket = Saito.getInstance().getSocket(peerIndex);
socket.send(buffer);
if (socket) {
socket.send(buffer);
}
}

sendMessageToAll(buffer: Uint8Array, exceptions: Array<bigint>): void {
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "saito-js",
"version": "0.0.48",
"version": "0.0.49",
"description": "js wrappings around saito-core using wasm",
"scripts": {
"test": "env TS_NODE_PROJECT=\"tsconfig.testing.json\" mocha --require ts-node/register 'tests/**/*.ts'",
Expand Down

0 comments on commit 7e7882c

Please sign in to comment.