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

Insert/pay should peek secrets until transaction is committed #9

Open
maaku opened this issue Mar 21, 2022 · 0 comments
Open

Insert/pay should peek secrets until transaction is committed #9

maaku opened this issue Mar 21, 2022 · 0 comments

Comments

@maaku
Copy link
Collaborator

maaku commented Mar 21, 2022

Right now the new secrets are allocated for a transaction regardless of whether the transaction confirms or not. So if you insert a secret into a wallet and the insertion fails, the replacement secret is still allocated.

This created an issue for me because I was inserting a batch of a few hundred secrets from webminer's webcash.log file. Unfortunately the my internet connection went out in the middle and so some secrets time out and weren't inserted. And because I am lazy I decided to just cat webcash.log | xargs -n 1 webcash insert the whole list again. I know, I know: bad on me for wasting server CPU time. But it got the job done since duplicate insertions are rejected by the server.

Only in the process my key counts increased by the size of the webcash.log file, even though only a few of them were valid. This means if I try to recover from a wallet backup it won't be successful, because I have a gap of 100's of secrets. It will still be recoverable, thankfully, but not with default options and not without an equivalently large drain of server resources.

Comparatively, miner.py "peeks" at the next secret and only commits if it actually finds a proof-of-work solution. This should be the behavior for all the wallet APIs: fetch a new secret to construct the transaction, but only commit it if the transaction confirms. Any error and the key counter is left at wherever it was before.

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

No branches or pull requests

1 participant