{"action":"created","comment":{"url":"https://api.github.com/repos/poetapp/node/pulls/comments/215440007","pull_request_review_id":152703138,"id":215440007,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNTQ0MDAwNw==","diff_hunk":"@@ -0,0 +1,61 @@\n+import { Claim } from '@po.et/poet-js'\n+import { inject, injectable } from 'inversify'\n+import { Collection, Db } from 'mongodb'\n+import { lensProp, lensPath, view, isNil, pipeP } from 'ramda'\n+\n+import { Database } from './Database'\n+\n+const L = {\n+  id: lensProp('id'),\n+  valueClaim: lensPath(['value', 'claim']),\n+}\n+\n+const MAX_STORAGE_ATTEMPTS = 10\n+\n+@injectable()\n+export class DatabaseMongo implements Database {\n+  private readonly claims: Collection\n+  private readonly errors: Collection\n+\n+  constructor(@inject('DB') db: Db) {\n+    this.claims = db.collection('storageWriterClaims')\n+    this.errors = db.collection('storageWriterErrors')\n+  }\n+\n+  public readonly start = async () => {\n+    await this.claims.createIndex({ claimId: 1 }, { unique: true })\n+  }\n+\n+  public readonly addError = async (error: object) => {\n+    await this.errors.insertOne(error)\n+  }\n+\n+  public readonly addClaim = async (claim: Claim) => {\n+    await this.claims.insertOne({ claimId: view(L.id, claim), claim, storageAttempts: 0, ipfsFileHash: null })\n+  }\n+\n+  public readonly addClaimHash = async (claimId: string, ipfsFileHash: string) => {","path":"src/StorageWriter/DatabaseMongo.ts","position":37,"original_position":37,"commit_id":"7ac82b6b802afdf165ba8a758008f5f6ecbcd1e4","original_commit_id":"7ac82b6b802afdf165ba8a758008f5f6ecbcd1e4","user":{"login":"wzalazar","id":5795257,"node_id":"MDQ6VXNlcjU3OTUyNTc=","avatar_url":"https://avatars1.githubusercontent.com/u/5795257?v=4","gravatar_id":"","url":"https://api.github.com/users/wzalazar","html_url":"https://github.com/wzalazar","followers_url":"https://api.github.com/users/wzalazar/followers","following_url":"https://api.github.com/users/wzalazar/following{/other_user}","gists_url":"https://api.github.com/users/wzalazar/gists{/gist_id}","starred_url":"https://api.github.com/users/wzalazar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wzalazar/subscriptions","organizations_url":"https://api.github.com/users/wzalazar/orgs","repos_url":"https://api.github.com/users/wzalazar/repos","events_url":"https://api.github.com/users/wzalazar/events{/privacy}","received_events_url":"https://api.github.com/users/wzalazar/received_events","type":"User","site_admin":false},"body":"do we need `try/catch`? what's happen if there are any error","created_at":"2018-09-05T22:03:27Z","updated_at":"2018-09-05T22:07:14Z","html_url":"https://github.com/poetapp/node/pull/396#discussion_r215440007","pull_request_url":"https://api.github.com/repos/poetapp/node/pulls/396","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/poetapp/node/pulls/comments/215440007"},"html":{"href":"https://github.com/poetapp/node/pull/396#discussion_r215440007"},"pull_request":{"href":"https://api.github.com/repos/poetapp/node/pulls/396"}}},"pull_request":{"url":"https://api.github.com/repos/poetapp/node/pulls/396","id":212256157,"node_id":"MDExOlB1bGxSZXF1ZXN0MjEyMjU2MTU3","html_url":"https://github.com/poetapp/node/pull/396","diff_url":"https://github.com/poetapp/node/pull/396.diff","patch_url":"https://github.com/poetapp/node/pull/396.patch","issue_url":"https://api.github.com/repos/poetapp/node/issues/396","number":396,"state":"open","locked":false,"title":"StorageWriter retries","user":{"login":"kennylavender","id":5175120,"node_id":"MDQ6VXNlcjUxNzUxMjA=","avatar_url":"https://avatars1.githubusercontent.com/u/5175120?v=4","gravatar_id":"","url":"https://api.github.com/users/kennylavender","html_url":"https://github.com/kennylavender","followers_url":"https://api.github.com/users/kennylavender/followers","following_url":"https://api.github.com/users/kennylavender/following{/other_user}","gists_url":"https://api.github.com/users/kennylavender/gists{/gist_id}","starred_url":"https://api.github.com/users/kennylavender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennylavender/subscriptions","organizations_url":"https://api.github.com/users/kennylavender/orgs","repos_url":"https://api.github.com/users/kennylavender/repos","events_url":"https://api.github.com/users/kennylavender/events{/privacy}","received_events_url":"https://api.github.com/users/kennylavender/received_events","type":"User","site_admin":false},"body":"[PR Process](https://github.com/poetapp/documentation/blob/master/process/pr-review.md#pr-process) - [PR Review Checklist](https://github.com/poetapp/documentation/blob/master/process/pr-review.md#pr-review-checklist)\r\n\r\n## Description of Changes\r\n\r\ncloses #119 \r\n\r\nConverts StorageWriter to upload claims to IPFS asynchronously with retries.\r\n\r\n- Add Service for upload intervals\r\n- Add `uploadClaimIntervalInSeconds` configuration setting\r\n- Adjust Router.ts and Messaging to support the new interval\r\n- Removed brittle new/instance of unit tests ( I might undo this, and maybe redo in another PR )\r\n- Split out DB functionality into its own Class to simplify the Claim Controller.\r\n- Gave errors their own collection so that we can store as many errors as we need without weighing down the claims collection. It also allows for easier filtering of errors by type.\r\n- Created `uploadClaimError` error function that creates the specific object format and type. Another error function will be used for #177\r\n- Adjusted the ClaimController to handle the new logic. I tried to really split the functions into 'do one thing' functions including error handling and make use of pipeP. I feel like there is still room for improvement. It feels difficult to come up with a good format around classes, arrow functions, and pipeP. \r\n- I also tried to tackle QE concerns while balancing it with avoiding to much change to the architecture. I tried to only stick with changes that I have discussed with @lautarodragan in the past, please let me know if I went too far anywhere.\r\n- Put logging in the ClaimControler into pipeP, I think this gets rid of lots of the noise of having the repeated logging setup in the main functions of the ClaimController. Let me know if you don't like this @lautarodragan and I will revert it, or ideas to improve it welcome as well.\r\n- Used lenses to modify the flow data, this is sort of a stepping stone towards better composition and less unit tested logic, but I think we could take it further still in the future.\r\n\r\n## Issues\r\n\r\n### TSLint\r\n- TSLint complains about public arrow functions being after private arrow functions in Classes. This is a requirement though of arrow function use in Classes.\r\n- TSLint complains about public functions being created with pipeP being placed after private properties and attempts to move them above the constructor and private properties.\r\n\r\nI will fix these TSLint issues in another PR either before or after merging this PR, for now just using comments to disable its complaints.\r\n\r\n\r\n","created_at":"2018-08-31T02:06:15Z","updated_at":"2018-09-05T22:07:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ba5e3fdddf65f873b6d53f5e772592ee8a921dec","assignee":{"login":"kennylavender","id":5175120,"node_id":"MDQ6VXNlcjUxNzUxMjA=","avatar_url":"https://avatars1.githubusercontent.com/u/5175120?v=4","gravatar_id":"","url":"https://api.github.com/users/kennylavender","html_url":"https://github.com/kennylavender","followers_url":"https://api.github.com/users/kennylavender/followers","following_url":"https://api.github.com/users/kennylavender/following{/other_user}","gists_url":"https://api.github.com/users/kennylavender/gists{/gist_id}","starred_url":"https://api.github.com/users/kennylavender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennylavender/subscriptions","organizations_url":"https://api.github.com/users/kennylavender/orgs","repos_url":"https://api.github.com/users/kennylavender/repos","events_url":"https://api.github.com/users/kennylavender/events{/privacy}","received_events_url":"https://api.github.com/users/kennylavender/received_events","type":"User","site_admin":false},"assignees":[{"login":"kennylavender","id":5175120,"node_id":"MDQ6VXNlcjUxNzUxMjA=","avatar_url":"https://avatars1.githubusercontent.com/u/5175120?v=4","gravatar_id":"","url":"https://api.github.com/users/kennylavender","html_url":"https://github.com/kennylavender","followers_url":"https://api.github.com/users/kennylavender/followers","following_url":"https://api.github.com/users/kennylavender/following{/other_user}","gists_url":"https://api.github.com/users/kennylavender/gists{/gist_id}","starred_url":"https://api.github.com/users/kennylavender/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kennylavender/subscriptions","organizations_url":"https://api.github.com/users/kennylavender/orgs","repos_url":"https://api.github.com/users/kennylavender/repos","events_url":"https://api.github.com/users/kennylavender/events{/privacy}","received_events_url":"https://api.github.com/users/kennylavender/received_events","type":"User","site_admin":false}],"requested_reviewers":[{"login":"lautarodragan","id":2279687,"node_id":"MDQ6VXNlcjIyNzk2ODc=","avatar_url":"https://avatars2.githubusercontent.com/u/2279687?v=4","gravatar_id":"","url":"https://api.github.com/users/lautarodragan","html_url":"https://github.com/lautarodragan","followers_url":"https://api.github.com/users/lautarodragan/followers","following_url":"https://api.github.com/users/lautarodragan/following{/other_user}","gists_url":"https://api.github.com/users/lautarodragan/gists{/gist_id}","starred_url":"https://api.github.com/users/lautarodragan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lautarodragan/subscriptions","organizations_url":"https://api.github.com/users/lautarodragan/orgs","repos_url":"https://api.github.com/users/lautarodragan/repos","events_url":"https://api.github.com/users/lautarodragan/events{/privacy}","received_events_url":"https://api.github.com/users/lautarodragan/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/poetapp/node/pulls/396/commits","review_comments_url":"https://api.github.com/repos/poetapp/node/pulls/396/comments","review_comment_url":"https://api.github.com/repos/poetapp/node/pulls/comments{/number}","comments_url":"https://api.github.com/repos/poetapp/node/issues/396/comments","statuses_url":"https://api.github.com/repos/poetapp/node/statuses/7ac82b6b802afdf165ba8a758008f5f6ecbcd1e4","head":{"label":"poetapp:storage-writer-retries-#119","ref":"storage-writer-retries-#119","sha":"7ac82b6b802afdf165ba8a758008f5f6ecbcd1e4","user":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"repo":{"id":108142666,"node_id":"MDEwOlJlcG9zaXRvcnkxMDgxNDI2NjY=","name":"node","full_name":"poetapp/node","owner":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/poetapp/node","description":"The Po.et Node allows you to timestamp documents in a decentralized manner.","fork":false,"url":"https://api.github.com/repos/poetapp/node","forks_url":"https://api.github.com/repos/poetapp/node/forks","keys_url":"https://api.github.com/repos/poetapp/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poetapp/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poetapp/node/teams","hooks_url":"https://api.github.com/repos/poetapp/node/hooks","issue_events_url":"https://api.github.com/repos/poetapp/node/issues/events{/number}","events_url":"https://api.github.com/repos/poetapp/node/events","assignees_url":"https://api.github.com/repos/poetapp/node/assignees{/user}","branches_url":"https://api.github.com/repos/poetapp/node/branches{/branch}","tags_url":"https://api.github.com/repos/poetapp/node/tags","blobs_url":"https://api.github.com/repos/poetapp/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poetapp/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poetapp/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/poetapp/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poetapp/node/statuses/{sha}","languages_url":"https://api.github.com/repos/poetapp/node/languages","stargazers_url":"https://api.github.com/repos/poetapp/node/stargazers","contributors_url":"https://api.github.com/repos/poetapp/node/contributors","subscribers_url":"https://api.github.com/repos/poetapp/node/subscribers","subscription_url":"https://api.github.com/repos/poetapp/node/subscription","commits_url":"https://api.github.com/repos/poetapp/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/poetapp/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/poetapp/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/poetapp/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/poetapp/node/contents/{+path}","compare_url":"https://api.github.com/repos/poetapp/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poetapp/node/merges","archive_url":"https://api.github.com/repos/poetapp/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poetapp/node/downloads","issues_url":"https://api.github.com/repos/poetapp/node/issues{/number}","pulls_url":"https://api.github.com/repos/poetapp/node/pulls{/number}","milestones_url":"https://api.github.com/repos/poetapp/node/milestones{/number}","notifications_url":"https://api.github.com/repos/poetapp/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poetapp/node/labels{/name}","releases_url":"https://api.github.com/repos/poetapp/node/releases{/id}","deployments_url":"https://api.github.com/repos/poetapp/node/deployments","created_at":"2017-10-24T14:58:14Z","updated_at":"2018-09-05T05:27:02Z","pushed_at":"2018-09-05T21:30:03Z","git_url":"git://github.com/poetapp/node.git","ssh_url":"git@github.com:poetapp/node.git","clone_url":"https://github.com/poetapp/node.git","svn_url":"https://github.com/poetapp/node","homepage":"","size":2771,"stargazers_count":139,"watchers_count":139,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":59,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":24,"open_issues":59,"watchers":139,"default_branch":"master"}},"base":{"label":"poetapp:master","ref":"master","sha":"d0f284b8c88e18614089e40a4395f8f32198f61d","user":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"repo":{"id":108142666,"node_id":"MDEwOlJlcG9zaXRvcnkxMDgxNDI2NjY=","name":"node","full_name":"poetapp/node","owner":{"login":"poetapp","id":24881331,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI0ODgxMzMx","avatar_url":"https://avatars0.githubusercontent.com/u/24881331?v=4","gravatar_id":"","url":"https://api.github.com/users/poetapp","html_url":"https://github.com/poetapp","followers_url":"https://api.github.com/users/poetapp/followers","following_url":"https://api.github.com/users/poetapp/following{/other_user}","gists_url":"https://api.github.com/users/poetapp/gists{/gist_id}","starred_url":"https://api.github.com/users/poetapp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/poetapp/subscriptions","organizations_url":"https://api.github.com/users/poetapp/orgs","repos_url":"https://api.github.com/users/poetapp/repos","events_url":"https://api.github.com/users/poetapp/events{/privacy}","received_events_url":"https://api.github.com/users/poetapp/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/poetapp/node","description":"The Po.et Node allows you to timestamp documents in a decentralized manner.","fork":false,"url":"https://api.github.com/repos/poetapp/node","forks_url":"https://api.github.com/repos/poetapp/node/forks","keys_url":"https://api.github.com/repos/poetapp/node/keys{/key_id}","collaborators_url":"https://api.github.com/repos/poetapp/node/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/poetapp/node/teams","hooks_url":"https://api.github.com/repos/poetapp/node/hooks","issue_events_url":"https://api.github.com/repos/poetapp/node/issues/events{/number}","events_url":"https://api.github.com/repos/poetapp/node/events","assignees_url":"https://api.github.com/repos/poetapp/node/assignees{/user}","branches_url":"https://api.github.com/repos/poetapp/node/branches{/branch}","tags_url":"https://api.github.com/repos/poetapp/node/tags","blobs_url":"https://api.github.com/repos/poetapp/node/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/poetapp/node/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/poetapp/node/git/refs{/sha}","trees_url":"https://api.github.com/repos/poetapp/node/git/trees{/sha}","statuses_url":"https://api.github.com/repos/poetapp/node/statuses/{sha}","languages_url":"https://api.github.com/repos/poetapp/node/languages","stargazers_url":"https://api.github.com/repos/poetapp/node/stargazers","contributors_url":"https://api.github.com/repos/poetapp/node/contributors","subscribers_url":"https://api.github.com/repos/poetapp/node/subscribers","subscription_url":"https://api.github.com/repos/poetapp/node/subscription","commits_url":"https://api.github.com/repos/poetapp/node/commits{/sha}","git_commits_url":"https://api.github.com/repos/poetapp/node/git/commits{/sha}","comments_url":"https://api.github.com/repos/poetapp/node/comments{/number}","issue_comment_url":"https://api.github.com/repos/poetapp/node/issues/comments{/number}","contents_url":"https://api.github.com/repos/poetapp/node/contents/{+path}","compare_url":"https://api.github.com/repos/poetapp/node/compare/{base}...{head}","merges_url":"https://api.github.com/repos/poetapp/node/merges","archive_url":"https://api.github.com/repos/poetapp/node/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/poetapp/node/downloads","issues_url":"https://api.github.com/repos/poetapp/node/issues{/number}","pulls_url":"https://api.github.com/repos/poetapp/node/pulls{/number}","milestones_url":"https://api.github.com/repos/poetapp/node/milestones{/number}","notifications_url":"https://api.github.com/repos/poetapp/node/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/poetapp/node/labels{/name}","releases_url":"https://api.github.com/repos/poetapp/node/releases{/id}","deployments_url":"https://api.github.com/repos/poetapp/node/deployments","created_at":"2017-10-24T14:58:14Z","updated_at":"2018-09-05T05:27:02Z","pushed_at":"2018-09-05T21:30:03Z","git_url":"git://github.com/poetapp/node.git","ssh_url":"git@github.com:poetapp/node.git","clone_url":"https://github.com/poetapp/node.git","svn_url":"https://github.com/poetapp/node","homepage":"","size":2771,"stargazers_count":139,"watchers_count":139,"language":"TypeScript","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":24,"mirror_url":null,"archived":false,"open_issues_count":59,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":24,"open_issues":59,"watchers":139,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/poetapp/node/pulls/396"},"html":{"href":"https://github.com/poetapp/node/pull/396"},"issue":{"href":"https://api.github.com/repos/poetapp/node/issues/396"},"comments":{"href":"https://api.github.com/repos/poetapp/node/issues/396/comments"},"review_comments":{"href":"https://api.github.com/repos/poetapp/node/pulls/396/comments"},"review_comment":{"href":"https://api.github.com/repos/poetapp/node/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/poetapp/node/pulls/396/commits"},"statuses":{"href":"https://api.github.com/repos/poetapp/node/statuses/7ac82b6b802afdf165ba8a758008f5f6ecbcd1e4"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"wzalazar"}}