{"action":"created","issue":{"url":"https://api.github.com/repos/bcoin-org/bcoin/issues/109","repository_url":"https://api.github.com/repos/bcoin-org/bcoin","labels_url":"https://api.github.com/repos/bcoin-org/bcoin/issues/109/labels{/name}","comments_url":"https://api.github.com/repos/bcoin-org/bcoin/issues/109/comments","events_url":"https://api.github.com/repos/bcoin-org/bcoin/issues/109/events","html_url":"https://github.com/bcoin-org/bcoin/issues/109","id":192881073,"number":109,"title":"Browser will never fully sync","user":{"login":"mcelrath","id":1746780,"avatar_url":"https://avatars.githubusercontent.com/u/1746780?v=3","gravatar_id":"","url":"https://api.github.com/users/mcelrath","html_url":"https://github.com/mcelrath","followers_url":"https://api.github.com/users/mcelrath/followers","following_url":"https://api.github.com/users/mcelrath/following{/other_user}","gists_url":"https://api.github.com/users/mcelrath/gists{/gist_id}","starred_url":"https://api.github.com/users/mcelrath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcelrath/subscriptions","organizations_url":"https://api.github.com/users/mcelrath/orgs","repos_url":"https://api.github.com/users/mcelrath/repos","events_url":"https://api.github.com/users/mcelrath/events{/privacy}","received_events_url":"https://api.github.com/users/mcelrath/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":3,"created_at":"2016-12-01T15:41:17Z","updated_at":"2016-12-01T21:32:13Z","closed_at":null,"body":"Due to limitations in browser-based storage, bcoin in the browser will never fully sync the blockchain, even in SPV mode.  After some time the browser will throw:\r\n\r\n    DOMException: An attempt was made to add something to storage that exceeded the quota.\r\n\r\nThe db on the browser uses IndexedDB by default, which is limited to around 5MB.  Testnet spv mode stalls around block 180000. \r\n\r\nTherefore an alternative db backend will be required for any browser-based usage, and bcoin will never be fully usable in its current form in a \"regular\" browser.  Other ways to use bcoin in the browser are [Chrome Apps](https://developer.chrome.com) and [Apache Cordova](http://cordova.apache.org) oh and [React Native](https://facebook.github.io/react-native/).\r\n\r\nWe are using Cordova for a mobile phone app using bcoin.  There is no readily available leveldb plugin for Cordova, but there is a sqlite plugin, and in general sqlite is widely available.  Therefore I propose to create a sqlite db backend.  (But I'm open to suggestions here)  This is somewhat ugly because the browser's indexedDB is simpler and likely faster, but I haven't found any way to modify its built-in quotas.  indexedDB is also difficult because there is no straightforward way to distribute the block headers bundled with a browser-based app.  A sqlite file for distributing the block headers would be straightforward, though sqlite is overkill for the simple key-value store needed by bcoin.\r\n\r\nFYI, on a related note, there is also the [chrome-net](https://github.com/feross/chrome-net) plugin and [cordova-chrome-net](https://github.com/theveloped/cordova-chrome-net) which provides a replacement for the nodejs `net` module for browser-based apps.  We have this working, which replaces the `socket.io` based approach in the bcoin tree.  Might be worth mentioning this in the docs somewhere."},"comment":{"url":"https://api.github.com/repos/bcoin-org/bcoin/issues/comments/264301677","html_url":"https://github.com/bcoin-org/bcoin/issues/109#issuecomment-264301677","issue_url":"https://api.github.com/repos/bcoin-org/bcoin/issues/109","id":264301677,"user":{"login":"mcelrath","id":1746780,"avatar_url":"https://avatars.githubusercontent.com/u/1746780?v=3","gravatar_id":"","url":"https://api.github.com/users/mcelrath","html_url":"https://github.com/mcelrath","followers_url":"https://api.github.com/users/mcelrath/followers","following_url":"https://api.github.com/users/mcelrath/following{/other_user}","gists_url":"https://api.github.com/users/mcelrath/gists{/gist_id}","starred_url":"https://api.github.com/users/mcelrath/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mcelrath/subscriptions","organizations_url":"https://api.github.com/users/mcelrath/orgs","repos_url":"https://api.github.com/users/mcelrath/repos","events_url":"https://api.github.com/users/mcelrath/events{/privacy}","received_events_url":"https://api.github.com/users/mcelrath/received_events","type":"User","site_admin":false},"created_at":"2016-12-01T21:32:13Z","updated_at":"2016-12-01T21:32:13Z","body":"We're using Cordova, so it's using whatever native browser is available.  My comments above refer to my Samsung Galaxy Note 4 running android 6.0.\r\n\r\nI tried plugging in sqlite via sqldown module (instead of leveldown), and it's ridiculously slow running in nodejs...it appears to be committing to disk with every write or something.  Do you have any insight there?"}}
{"actor":{"display_login":"mcelrath"}}