Skip to content

Commit

Permalink
Merge pull request #61 from HathorNetwork/dev
Browse files Browse the repository at this point in the history
Release v1.4.0-alpha
  • Loading branch information
andreabadesso authored Jul 13, 2022
2 parents c0e12ea + aec8d95 commit ad315e2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
2 changes: 1 addition & 1 deletion 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,5 +1,5 @@
{
"version": "1.3.2-alpha",
"version": "1.4.0-alpha",
"license": "MIT",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export interface Meta {
height: number;
validation?: string;
first_block?: string | null;
first_block_height?: number | null;
}

export interface RawTxResponse {
Expand Down
10 changes: 8 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,17 @@ export const recursivelyDownloadTx = async (

// Transaction was already confirmed by a different block
if (meta.first_block && meta.first_block !== blockId) {
const firstBlockResponse = await downloadTx(meta.first_block);
let firstBlockHeight = meta.first_block_height;

// This should never happen
// Using == to include `undefined` on this check
if (firstBlockHeight == null) {
throw new Error('Transaction was confirmed by a block but we were unable to detect its height');
}

// If the transaction was confirmed by an older block, ignore it as it was
// already sent to the wallet-service
if (firstBlockResponse.tx.height < blockHeight) {
if (firstBlockHeight < blockHeight) {
return recursivelyDownloadTx(blockId, blockHeight, txIds, data);
}
}
Expand Down

0 comments on commit ad315e2

Please sign in to comment.