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 #39 from SaitoTech/develop
Browse files Browse the repository at this point in the history
wasm bug fixing
  • Loading branch information
SankaD committed Aug 4, 2023
2 parents 743f120 + 4a8cb06 commit a272c89
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
6 changes: 5 additions & 1 deletion lib/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import WasmWrapper from "./wasm_wrapper";
import Saito from "../saito";
import Block from "./block";
import Transaction from "./transaction";
import { DefaultEmptyBlockHash } from "./wallet";

export default class Blockchain extends WasmWrapper<WasmBlockchain> {
public static Type: any;
Expand All @@ -24,6 +25,9 @@ export default class Blockchain extends WasmWrapper<WasmBlockchain> {
public async affixCallbacks(block: Block) {}

public async runCallbacks(block_hash: string, from_blocks_back: bigint) {
if (block_hash === DefaultEmptyBlockHash) {
return;
}
let block = await Saito.getInstance().getBlock(block_hash);
let callbacks = this.callbacks.get(block_hash);
let callbackIndices = this.callbackIndices.get(block_hash);
Expand Down Expand Up @@ -93,7 +97,7 @@ export default class Blockchain extends WasmWrapper<WasmBlockchain> {

if (run_callbacks) {
let callback_block_hash = await this.instance.get_longest_chain_hash_at(i);
if (callback_block_hash !== "") {
if (callback_block_hash !== "" && callback_block_hash !== DefaultEmptyBlockHash) {
await this.runCallbacks(callback_block_hash, confirmation_count);
}
}
Expand Down
4 changes: 4 additions & 0 deletions lib/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ import { fromBase58, toBase58 } from "./util";

export const DefaultEmptyPrivateKey =
"0000000000000000000000000000000000000000000000000000000000000000";

export const DefaultEmptyPublicKey =
"000000000000000000000000000000000000000000000000000000000000000000";

export const DefaultEmptyBlockHash =
"0000000000000000000000000000000000000000000000000000000000000000";

export default class Wallet extends WasmWrapper<WasmWallet> {
public static Type: any;

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "saito-js",
"version": "0.0.36",
"version": "0.0.37",
"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 Expand Up @@ -36,7 +36,7 @@
"morgan": "~1.10.0",
"node-fetch": "^2.6.1",
"process": "^0.11.10",
"saito-wasm": "^0.0.24",
"saito-wasm": "^0.0.25",
"url": "^0.11.0",
"util": "^0.12.5",
"ws": "^8.13.0"
Expand Down

0 comments on commit a272c89

Please sign in to comment.