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

Coin selection memory exhaustion #786

Open
braydonf opened this issue May 31, 2019 · 1 comment
Open

Coin selection memory exhaustion #786

braydonf opened this issue May 31, 2019 · 1 comment
Labels
memory Memory issues wallet Wallet related
Milestone

Comments

@braydonf
Copy link
Contributor

Versions
bcoin 0551096 (May 31st, 2019)

Expected

For coins to be selected via a database query as to not load all coins into memory.

Actual

Coins are selected by loading all coins for an account and sorted random, age or by value. For an account or wallet with many coins (exact amount depending on available memory), will exhaust the available memory usage. There are also likely performance impact that could be improved.

Solutions

Index coins by age and value for the walletdb, and load only the necessary coins into memory. Random selection can be done by choosing random min value with a range query, and limit of 1.

@braydonf
Copy link
Contributor Author

braydonf commented Jun 12, 2019

As part of resolving this, it'll be useful to update the GET /wallet/:id/coin endpoint to support querying sets of results (pages), as is similar to GET /tx/address/:address.

With this issue solved, it could be worthwhile to only mark a coin/credit as spent (and not delete) when a block is confirmed, as is currently the case for unconfirmed transactions for a wallet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
memory Memory issues wallet Wallet related
Projects
None yet
Development

No branches or pull requests

1 participant