{"action":"created","issue":{"url":"https://api.github.com/repos/wibsonorg/buyer-sdk/issues/101","repository_url":"https://api.github.com/repos/wibsonorg/buyer-sdk","labels_url":"https://api.github.com/repos/wibsonorg/buyer-sdk/issues/101/labels{/name}","comments_url":"https://api.github.com/repos/wibsonorg/buyer-sdk/issues/101/comments","events_url":"https://api.github.com/repos/wibsonorg/buyer-sdk/issues/101/events","html_url":"https://github.com/wibsonorg/buyer-sdk/pull/101","id":383154676,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMyNjkyMjg4","number":101,"title":"Pause the transaction queue when there is not enough balance to operate","user":{"login":"nicoayala","id":850636,"node_id":"MDQ6VXNlcjg1MDYzNg==","avatar_url":"https://avatars0.githubusercontent.com/u/850636?v=4","gravatar_id":"","url":"https://api.github.com/users/nicoayala","html_url":"https://github.com/nicoayala","followers_url":"https://api.github.com/users/nicoayala/followers","following_url":"https://api.github.com/users/nicoayala/following{/other_user}","gists_url":"https://api.github.com/users/nicoayala/gists{/gist_id}","starred_url":"https://api.github.com/users/nicoayala/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nicoayala/subscriptions","organizations_url":"https://api.github.com/users/nicoayala/orgs","repos_url":"https://api.github.com/users/nicoayala/repos","events_url":"https://api.github.com/users/nicoayala/events{/privacy}","received_events_url":"https://api.github.com/users/nicoayala/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-21T14:54:03Z","updated_at":"2018-11-21T15:07:27Z","closed_at":null,"author_association":"MEMBER","pull_request":{"url":"https://api.github.com/repos/wibsonorg/buyer-sdk/pulls/101","html_url":"https://github.com/wibsonorg/buyer-sdk/pull/101","diff_url":"https://github.com/wibsonorg/buyer-sdk/pull/101.diff","patch_url":"https://github.com/wibsonorg/buyer-sdk/pull/101.patch"},"body":"### What does this Pull Request do?\r\nAdds a balance check (WIB and ETH) and pauses the transaction when conditions are not met.\r\n\r\n### Are there points in the code the reviewer needs to double check?\r\nThe check is done at the beginning of the processing of every job: If there is not enough balance to start processing another job the transaction queue will finish with the current job and it will not start with another one until the transaction queue is manually resumed.\r\n\r\nThe pausing mechanism will prevent the queue from processing new jobs but it will allow to enqueue new ones. When the queue is resumed priorities and arrival order are respected.\r\n\r\n#### Manually resume the transaction queue\r\nOn development:\r\n```sh\r\n$ npm run task -- txqueue:resume\r\n```\r\n\r\nOn production:\r\n```sh\r\n$ npm run task:production -- txqueue:resume\r\n```\r\n\r\n#### Edge cases\r\nThe fact that the tx queue will do its best to finish with the current job introduces the risk of\r\nwasting ETH and loosing the transaction if there is not enough balance. The strategy to prevent this is to have an abundant minimum WIB, so that the transaction that is being processed can do transfers if needed (the case of `CloseDataResponse`). \r\n\r\nAnother thing that can be done to have a more robust solution is to check balance before enqueueing. This can be implemented inside the facades that need to do transfers and can be retried without problem.\r\n\r\n### Does this Pull Request meet the acceptance criteria?\r\n- [x] I have read the [Contribution guidelines](https://github.com/wibsonorg/buyer-sdk/CONTRIBUTING.md).\r\n- [x] I have read the [Code of Conduct](https://github.com/wibsonorg/buyer-sdk/CODE_OF_CONDUCT.md).\r\n- [x] I have updated the documentation accordingly.\r\n- [x] I have added tests to cover my changes.\r\n"},"comment":{"url":"https://api.github.com/repos/wibsonorg/buyer-sdk/issues/comments/440697056","html_url":"https://github.com/wibsonorg/buyer-sdk/pull/101#issuecomment-440697056","issue_url":"https://api.github.com/repos/wibsonorg/buyer-sdk/issues/101","id":440697056,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0MDY5NzA1Ng==","user":{"login":"Agus","id":4080111,"node_id":"MDQ6VXNlcjQwODAxMTE=","avatar_url":"https://avatars0.githubusercontent.com/u/4080111?v=4","gravatar_id":"","url":"https://api.github.com/users/Agus","html_url":"https://github.com/Agus","followers_url":"https://api.github.com/users/Agus/followers","following_url":"https://api.github.com/users/Agus/following{/other_user}","gists_url":"https://api.github.com/users/Agus/gists{/gist_id}","starred_url":"https://api.github.com/users/Agus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Agus/subscriptions","organizations_url":"https://api.github.com/users/Agus/orgs","repos_url":"https://api.github.com/users/Agus/repos","events_url":"https://api.github.com/users/Agus/events{/privacy}","received_events_url":"https://api.github.com/users/Agus/received_events","type":"User","site_admin":false},"created_at":"2018-11-21T15:07:27Z","updated_at":"2018-11-21T15:07:27Z","author_association":"COLLABORATOR","body":"> The strategy to prevent this is to have an abundant minimum WIB, so that the transaction that is being processed can do transfers if needed\r\n\r\nI like this one, is just a matter of communicating and setting a convenient amount of \"minimum ETH/WIB\""}}
{"actor":{"display_login":"Agus"}}