{"action":"created","issue":{"url":"https://api.github.com/repos/ethereum/web3.js/issues/1079","repository_url":"https://api.github.com/repos/ethereum/web3.js","labels_url":"https://api.github.com/repos/ethereum/web3.js/issues/1079/labels{/name}","comments_url":"https://api.github.com/repos/ethereum/web3.js/issues/1079/comments","events_url":"https://api.github.com/repos/ethereum/web3.js/issues/1079/events","html_url":"https://github.com/ethereum/web3.js/pull/1079","id":260776435,"number":1079,"title":"Decouple wallet.length from other wallet functions (add, encrypt, clear)","user":{"login":"cmditch","id":15849320,"avatar_url":"https://avatars0.githubusercontent.com/u/15849320?v=4","gravatar_id":"","url":"https://api.github.com/users/cmditch","html_url":"https://github.com/cmditch","followers_url":"https://api.github.com/users/cmditch/followers","following_url":"https://api.github.com/users/cmditch/following{/other_user}","gists_url":"https://api.github.com/users/cmditch/gists{/gist_id}","starred_url":"https://api.github.com/users/cmditch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cmditch/subscriptions","organizations_url":"https://api.github.com/users/cmditch/orgs","repos_url":"https://api.github.com/users/cmditch/repos","events_url":"https://api.github.com/users/cmditch/events{/privacy}","received_events_url":"https://api.github.com/users/cmditch/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-09-26T21:30:10Z","updated_at":"2017-09-27T05:29:21Z","closed_at":null,"author_association":"NONE","pull_request":{"url":"https://api.github.com/repos/ethereum/web3.js/pulls/1079","html_url":"https://github.com/ethereum/web3.js/pull/1079","diff_url":"https://github.com/ethereum/web3.js/pull/1079.diff","patch_url":"https://github.com/ethereum/web3.js/pull/1079.patch"},"body":"#1077 \r\n\r\nThis adds a new function `web3.eth.accounts.wallet._findSafeIndex` which recursively counts up from 0 and finds the first unused index in the wallet, where `web3.eth.accounts.wallet.add()` will inject a new account.\r\n\r\nA alternative fix for this error can be seen [here](https://github.com/cmditch/web3.js/commit/fd18778fdcc44e0c16f0ac0f8b2c410cd8c02f18), where instead of a new function, a new variable is added `wallet.pointerIndex` to keep track of a safe lower limit for future indexes.\r\n\r\nDespite this recursive fix being O(n), and the alternative fix (linked above) and original `web3.eth.accounts.wallet.add()` being O(1), they all benchmark around the same @ ~1000ms for `wallet.create(500)`.\r\n\r\nEDIT - \r\n\r\nTurns out `wallet.length`'s coupling to other primary wallet functions causes issues if `wallet.remove` has been used. \r\n\r\nThis PR adds two new functions, `wallet._findSafeIndex` & `wallet._currentIndexes`, to help address these issues. `wallet.add`, `wallet.enrypt`, & `wallet.clear` refactored accordingly.\r\n\r\nTests have been added as well.\r\n\r\nChai version number was bumped to utilize chai's new array equality assertions."},"comment":{"url":"https://api.github.com/repos/ethereum/web3.js/issues/comments/332412917","html_url":"https://github.com/ethereum/web3.js/pull/1079#issuecomment-332412917","issue_url":"https://api.github.com/repos/ethereum/web3.js/issues/1079","id":332412917,"user":{"login":"coveralls","id":2354108,"avatar_url":"https://avatars1.githubusercontent.com/u/2354108?v=4","gravatar_id":"","url":"https://api.github.com/users/coveralls","html_url":"https://github.com/coveralls","followers_url":"https://api.github.com/users/coveralls/followers","following_url":"https://api.github.com/users/coveralls/following{/other_user}","gists_url":"https://api.github.com/users/coveralls/gists{/gist_id}","starred_url":"https://api.github.com/users/coveralls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coveralls/subscriptions","organizations_url":"https://api.github.com/users/coveralls/orgs","repos_url":"https://api.github.com/users/coveralls/repos","events_url":"https://api.github.com/users/coveralls/events{/privacy}","received_events_url":"https://api.github.com/users/coveralls/received_events","type":"User","site_admin":false},"created_at":"2017-09-27T05:29:21Z","updated_at":"2017-09-27T05:29:21Z","author_association":"NONE","body":"\n[![Coverage Status](https://coveralls.io/builds/13449311/badge)](https://coveralls.io/builds/13449311)\n\nCoverage increased (+0.5%) to 85.776% when pulling **bdd40b0e9767ec3dd506345c946c01de7ea5ab96 on cmditch:wallet-hole-plugger-fix** into **e633406de34b130dfb969ccb162350b885f722b5 on ethereum:1.0**.\n"}}
{"actor":{"display_login":"coveralls"}}