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 #48 from SaitoTech/develop
Browse files Browse the repository at this point in the history
wasm bug fixing
  • Loading branch information
SankaD authored Aug 15, 2023
2 parents 01e6a12 + 1f05459 commit 49cbf41
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
13 changes: 10 additions & 3 deletions lib/blockchain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,18 @@ export default class Blockchain extends WasmWrapper<WasmBlockchain> {
let callbackIndices = this.callbackIndices.get(block_hash);
let confirmations = this.confirmations.get(block_hash) || BigInt(-1);
console.log(
`running callbacks. callbacks : ${callbacks?.length} confirmations : ${confirmations}`
`running callbacks for ${block_hash}. callbacks : ${callbacks?.length} confirmations : ${confirmations}`
);
if (Number(confirmations) && callbacks && callbackIndices) {
for (let i = Number(confirmations) + 1; i < from_blocks_back; i++) {
for (let j = 0; j < callbacks.length; ++j) {
for (let j = 0; j < callbacks.length; j++) {
try {
if (callbacks[j] && callbackIndices[j]) {
await callbacks[j](block, block.transactions[callbackIndices[j]], i);
} else {
console.log(
`callback ${j} is ${!!callbacks[j]} callbackIndices is ${!!callbackIndices[j]}`
);
}
} catch (error) {
console.error(error);
Expand All @@ -58,6 +62,8 @@ export default class Blockchain extends WasmWrapper<WasmBlockchain> {
}
}
}
} else {
console.log(`confirmations : ${confirmations}`);
}
this.confirmations.set(block_hash, from_blocks_back);
} catch (error) {
Expand Down Expand Up @@ -137,9 +143,10 @@ export default class Blockchain extends WasmWrapper<WasmBlockchain> {
let callback_block_hash = await this.instance.get_longest_chain_hash_at(
block_id_in_which_to_delete_callbacks + BigInt(1) // because block ring starts from 1
);
console.log(`deleting callbacks for : ${callback_block_hash}`);
this.callbacks.delete(callback_block_hash);
this.callbackIndices.delete(callback_block_hash);
this.confirmations.delete(callback_block_hash);
// this.confirmations.delete(callback_block_hash);
}
}

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.45",
"version": "0.0.46",
"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 49cbf41

Please sign in to comment.