Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix dedduped hashes #53

Merged
merged 1 commit into from
May 8, 2019
Merged

Fix dedduped hashes #53

merged 1 commit into from
May 8, 2019

Conversation

nodech
Copy link
Member

@nodech nodech commented May 8, 2019

Instead of dedupping hashes, return all paths mapped to inputs.

Proper fix after this one will be to have specialized CoinView that has redeem and paths in it.
See: handshake-org/hsd#145

Instead of dedupping hashes, return all paths mapped to inputs.
@nodech nodech requested a review from tynes May 8, 2019 11:53
continue;
}

paths.push(path);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make sure that I understand, the fix here is to be certain that the resulting array is the same length as the mtx.inputs correct?

I also think that it will be the uncommon case that the cache hit happens, but it doesn't add very much complexity to use it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes.

Cache hits will happen if you are reusing addresses. So it depends on the way users use the wallet, for some it will happen more frequently (that use same address, e.g. donations)

path = table.get(hash);
}

if (!path) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code block is being explicit but I think that if await this.wallet.getPath is restricted to returning null or the path, then paths.push(path) will work exacty the same without this block that checks if (!path)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's fine to have explicit logic, especially if falsyness logic changes in that function (I doubt but still)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense to program defensively 👍

@nodech nodech merged commit 6ff4af6 into bcoin-org:master May 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants