{"action":"created","comment":{"url":"https://api.github.com/repos/golemfactory/concent/pulls/comments/173336087","pull_request_review_id":102512147,"id":173336087,"diff_hunk":"@@ -1241,6 +1209,604 @@ def store_message_and_message_status(\n         receive_message_status.save()\n \n \n+def store_subtask(\n+    task_id:                        str,\n+    subtask_id:                     str,\n+    provider_public_key:            bytes,\n+    requestor_public_key:           bytes,\n+    state:                          Enum,\n+    next_deadline:                  int,\n+    task_to_compute:                message.TaskToCompute                = None,\n+    report_computed_task:           message.ReportComputedTask           = None,\n+    force_get_task_result:          message.concents.ForceGetTaskResult  = None,\n+    ack_report_computed_task:       message.AckReportComputedTask        = None,\n+    reject_report_computed_task:    message.RejectReportComputedTask     = None,\n+    subtask_results_accepted:       message.tasks.SubtaskResultsAccepted = None,\n+    subtask_results_rejected:       message.tasks.SubtaskResultsRejected = None,\n+):\n+    assert isinstance(task_id,              str)\n+    assert isinstance(subtask_id,           str)\n+    assert isinstance(provider_public_key,  bytes)\n+    assert isinstance(requestor_public_key, bytes)\n+    assert state in Subtask.SubtaskState\n+\n+    if state in Subtask.SUBTASK_ACTIVE_STATES:\n+        assert next_deadline is not None\n+    elif state in Subtask.SUBTASK_PASSIVE_STATES:\n+        assert next_deadline is None\n+\n+    provider  = Client.objects.get_or_create_full_clean(provider_public_key)\n+    requestor = Client.objects.get_or_create_full_clean(requestor_public_key)\n+\n+    subtask = Subtask(\n+        task_id         = task_id,\n+        subtask_id      = subtask_id,\n+        provider        = provider,\n+        requestor       = requestor,\n+        state           = state.name,\n+        next_deadline   = datetime.datetime.fromtimestamp(next_deadline, timezone.utc),\n+    )\n+\n+    add_messages_to_subtask(\n+        subtask,\n+        task_to_compute,\n+        report_computed_task,\n+        force_get_task_result,\n+        ack_report_computed_task,\n+        reject_report_computed_task,\n+        subtask_results_accepted,\n+        subtask_results_rejected,\n+    )\n+\n+    subtask.full_clean()\n+    subtask.save()\n+    return subtask\n+\n+\n+def update_file_status(\n+    client_public_key: bytes,\n+):\n+    force_get_task_result_list = PendingResponse.objects.filter(\n+        Q(subtask__requestor__public_key = b64encode(client_public_key)) | Q(subtask__provider__public_key = b64encode(client_public_key)),\n+        subtask__state                   = Subtask.SubtaskState.FORCING_RESULT_TRANSFER.name,  # pylint: disable=no-member\n+    )\n+\n+    for pending_reponse in force_get_task_result_list:\n+        report_computed_task    = deserialize_message(pending_reponse.subtask.report_computed_task.data.tobytes())\n+        file_transfer_token     = create_file_transfer_token(\n+            report_computed_task,\n+            client_public_key,\n+        )\n+        if get_file_status(file_transfer_token):\n+            subtask         = pending_reponse.subtask\n+            subtask.state   = Subtask.SubtaskState.RESULT_UPLOADED.name  # pylint: disable=no-member\n+            subtask.full_clean()\n+            subtask.save()\n+            mark_message_as_delivered(pending_reponse)\n+\n+            store_message_inbox(\n+                response_type       = PendingResponse.ResponseType.ForceGetTaskResultUpload,\n+                client_public_key   = subtask.provider.public_key_bytes,\n+                queue               = PendingResponse.PendingResponseType.Receive,\n+                subtask             = subtask,\n+            )\n+            store_message_inbox(\n+                response_type       = PendingResponse.ResponseType.ForceGetTaskResultUpload,\n+                client_public_key   = subtask.requestor.public_key_bytes,\n+                queue               = PendingResponse.PendingResponseType.Receive,\n+                subtask             = subtask,\n+            )\n+","path":"concent_api/core/views.py","position":710,"original_position":710,"commit_id":"49499593d9ab51117a60c2bb1ffcdf34d7ab0d09","original_commit_id":"49499593d9ab51117a60c2bb1ffcdf34d7ab0d09","user":{"login":"rwrzesien","id":10088909,"avatar_url":"https://avatars0.githubusercontent.com/u/10088909?v=4","gravatar_id":"","url":"https://api.github.com/users/rwrzesien","html_url":"https://github.com/rwrzesien","followers_url":"https://api.github.com/users/rwrzesien/followers","following_url":"https://api.github.com/users/rwrzesien/following{/other_user}","gists_url":"https://api.github.com/users/rwrzesien/gists{/gist_id}","starred_url":"https://api.github.com/users/rwrzesien/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwrzesien/subscriptions","organizations_url":"https://api.github.com/users/rwrzesien/orgs","repos_url":"https://api.github.com/users/rwrzesien/repos","events_url":"https://api.github.com/users/rwrzesien/events{/privacy}","received_events_url":"https://api.github.com/users/rwrzesien/received_events","type":"User","site_admin":false},"body":"Some logging would be nice here.","created_at":"2018-03-09T00:36:28Z","updated_at":"2018-03-09T00:36:28Z","html_url":"https://github.com/golemfactory/concent/pull/162#discussion_r173336087","pull_request_url":"https://api.github.com/repos/golemfactory/concent/pulls/162","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/golemfactory/concent/pulls/comments/173336087"},"html":{"href":"https://github.com/golemfactory/concent/pull/162#discussion_r173336087"},"pull_request":{"href":"https://api.github.com/repos/golemfactory/concent/pulls/162"}}},"pull_request":{"url":"https://api.github.com/repos/golemfactory/concent/pulls/162","id":172315371,"html_url":"https://github.com/golemfactory/concent/pull/162","diff_url":"https://github.com/golemfactory/concent/pull/162.diff","patch_url":"https://github.com/golemfactory/concent/pull/162.patch","issue_url":"https://api.github.com/repos/golemfactory/concent/issues/162","number":162,"state":"open","locked":false,"title":"Feature update state transistions","user":{"login":"kbeker","id":26469852,"avatar_url":"https://avatars3.githubusercontent.com/u/26469852?v=4","gravatar_id":"","url":"https://api.github.com/users/kbeker","html_url":"https://github.com/kbeker","followers_url":"https://api.github.com/users/kbeker/followers","following_url":"https://api.github.com/users/kbeker/following{/other_user}","gists_url":"https://api.github.com/users/kbeker/gists{/gist_id}","starred_url":"https://api.github.com/users/kbeker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbeker/subscriptions","organizations_url":"https://api.github.com/users/kbeker/orgs","repos_url":"https://api.github.com/users/kbeker/repos","events_url":"https://api.github.com/users/kbeker/events{/privacy}","received_events_url":"https://api.github.com/users/kbeker/received_events","type":"User","site_admin":false},"body":"Resolves https://github.com/golemfactory/concent/issues/142.\r\nResolves https://github.com/golemfactory/concent/issues/143.\r\nResolves https://github.com/golemfactory/concent/issues/137.","created_at":"2018-03-01T18:23:55Z","updated_at":"2018-03-09T00:36:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a9758f81f74c7b6486b1196bee1671df609101c5","assignee":{"login":"kbeker","id":26469852,"avatar_url":"https://avatars3.githubusercontent.com/u/26469852?v=4","gravatar_id":"","url":"https://api.github.com/users/kbeker","html_url":"https://github.com/kbeker","followers_url":"https://api.github.com/users/kbeker/followers","following_url":"https://api.github.com/users/kbeker/following{/other_user}","gists_url":"https://api.github.com/users/kbeker/gists{/gist_id}","starred_url":"https://api.github.com/users/kbeker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbeker/subscriptions","organizations_url":"https://api.github.com/users/kbeker/orgs","repos_url":"https://api.github.com/users/kbeker/repos","events_url":"https://api.github.com/users/kbeker/events{/privacy}","received_events_url":"https://api.github.com/users/kbeker/received_events","type":"User","site_admin":false},"assignees":[{"login":"kbeker","id":26469852,"avatar_url":"https://avatars3.githubusercontent.com/u/26469852?v=4","gravatar_id":"","url":"https://api.github.com/users/kbeker","html_url":"https://github.com/kbeker","followers_url":"https://api.github.com/users/kbeker/followers","following_url":"https://api.github.com/users/kbeker/following{/other_user}","gists_url":"https://api.github.com/users/kbeker/gists{/gist_id}","starred_url":"https://api.github.com/users/kbeker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kbeker/subscriptions","organizations_url":"https://api.github.com/users/kbeker/orgs","repos_url":"https://api.github.com/users/kbeker/repos","events_url":"https://api.github.com/users/kbeker/events{/privacy}","received_events_url":"https://api.github.com/users/kbeker/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/golemfactory/concent/pulls/162/commits","review_comments_url":"https://api.github.com/repos/golemfactory/concent/pulls/162/comments","review_comment_url":"https://api.github.com/repos/golemfactory/concent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/golemfactory/concent/issues/162/comments","statuses_url":"https://api.github.com/repos/golemfactory/concent/statuses/49499593d9ab51117a60c2bb1ffcdf34d7ab0d09","head":{"label":"golemfactory:feature-update-state-transistions","ref":"feature-update-state-transistions","sha":"49499593d9ab51117a60c2bb1ffcdf34d7ab0d09","user":{"login":"golemfactory","id":23193179,"avatar_url":"https://avatars1.githubusercontent.com/u/23193179?v=4","gravatar_id":"","url":"https://api.github.com/users/golemfactory","html_url":"https://github.com/golemfactory","followers_url":"https://api.github.com/users/golemfactory/followers","following_url":"https://api.github.com/users/golemfactory/following{/other_user}","gists_url":"https://api.github.com/users/golemfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/golemfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/golemfactory/subscriptions","organizations_url":"https://api.github.com/users/golemfactory/orgs","repos_url":"https://api.github.com/users/golemfactory/repos","events_url":"https://api.github.com/users/golemfactory/events{/privacy}","received_events_url":"https://api.github.com/users/golemfactory/received_events","type":"Organization","site_admin":false},"repo":{"id":108836885,"name":"concent","full_name":"golemfactory/concent","owner":{"login":"golemfactory","id":23193179,"avatar_url":"https://avatars1.githubusercontent.com/u/23193179?v=4","gravatar_id":"","url":"https://api.github.com/users/golemfactory","html_url":"https://github.com/golemfactory","followers_url":"https://api.github.com/users/golemfactory/followers","following_url":"https://api.github.com/users/golemfactory/following{/other_user}","gists_url":"https://api.github.com/users/golemfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/golemfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/golemfactory/subscriptions","organizations_url":"https://api.github.com/users/golemfactory/orgs","repos_url":"https://api.github.com/users/golemfactory/repos","events_url":"https://api.github.com/users/golemfactory/events{/privacy}","received_events_url":"https://api.github.com/users/golemfactory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/golemfactory/concent","description":"Repository for Concent Service sources","fork":false,"url":"https://api.github.com/repos/golemfactory/concent","forks_url":"https://api.github.com/repos/golemfactory/concent/forks","keys_url":"https://api.github.com/repos/golemfactory/concent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/golemfactory/concent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/golemfactory/concent/teams","hooks_url":"https://api.github.com/repos/golemfactory/concent/hooks","issue_events_url":"https://api.github.com/repos/golemfactory/concent/issues/events{/number}","events_url":"https://api.github.com/repos/golemfactory/concent/events","assignees_url":"https://api.github.com/repos/golemfactory/concent/assignees{/user}","branches_url":"https://api.github.com/repos/golemfactory/concent/branches{/branch}","tags_url":"https://api.github.com/repos/golemfactory/concent/tags","blobs_url":"https://api.github.com/repos/golemfactory/concent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/golemfactory/concent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/golemfactory/concent/git/refs{/sha}","trees_url":"https://api.github.com/repos/golemfactory/concent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/golemfactory/concent/statuses/{sha}","languages_url":"https://api.github.com/repos/golemfactory/concent/languages","stargazers_url":"https://api.github.com/repos/golemfactory/concent/stargazers","contributors_url":"https://api.github.com/repos/golemfactory/concent/contributors","subscribers_url":"https://api.github.com/repos/golemfactory/concent/subscribers","subscription_url":"https://api.github.com/repos/golemfactory/concent/subscription","commits_url":"https://api.github.com/repos/golemfactory/concent/commits{/sha}","git_commits_url":"https://api.github.com/repos/golemfactory/concent/git/commits{/sha}","comments_url":"https://api.github.com/repos/golemfactory/concent/comments{/number}","issue_comment_url":"https://api.github.com/repos/golemfactory/concent/issues/comments{/number}","contents_url":"https://api.github.com/repos/golemfactory/concent/contents/{+path}","compare_url":"https://api.github.com/repos/golemfactory/concent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/golemfactory/concent/merges","archive_url":"https://api.github.com/repos/golemfactory/concent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/golemfactory/concent/downloads","issues_url":"https://api.github.com/repos/golemfactory/concent/issues{/number}","pulls_url":"https://api.github.com/repos/golemfactory/concent/pulls{/number}","milestones_url":"https://api.github.com/repos/golemfactory/concent/milestones{/number}","notifications_url":"https://api.github.com/repos/golemfactory/concent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/golemfactory/concent/labels{/name}","releases_url":"https://api.github.com/repos/golemfactory/concent/releases{/id}","deployments_url":"https://api.github.com/repos/golemfactory/concent/deployments","created_at":"2017-10-30T10:41:44Z","updated_at":"2018-02-23T23:12:15Z","pushed_at":"2018-03-08T23:23:28Z","git_url":"git://github.com/golemfactory/concent.git","ssh_url":"git@github.com:golemfactory/concent.git","clone_url":"https://github.com/golemfactory/concent.git","svn_url":"https://github.com/golemfactory/concent","homepage":null,"size":638,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":51,"license":null,"forks":0,"open_issues":51,"watchers":1,"default_branch":"master"}},"base":{"label":"golemfactory:master","ref":"master","sha":"cd4b8b59fdd1f4f3e8b49451bcb45c13e76a3a83","user":{"login":"golemfactory","id":23193179,"avatar_url":"https://avatars1.githubusercontent.com/u/23193179?v=4","gravatar_id":"","url":"https://api.github.com/users/golemfactory","html_url":"https://github.com/golemfactory","followers_url":"https://api.github.com/users/golemfactory/followers","following_url":"https://api.github.com/users/golemfactory/following{/other_user}","gists_url":"https://api.github.com/users/golemfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/golemfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/golemfactory/subscriptions","organizations_url":"https://api.github.com/users/golemfactory/orgs","repos_url":"https://api.github.com/users/golemfactory/repos","events_url":"https://api.github.com/users/golemfactory/events{/privacy}","received_events_url":"https://api.github.com/users/golemfactory/received_events","type":"Organization","site_admin":false},"repo":{"id":108836885,"name":"concent","full_name":"golemfactory/concent","owner":{"login":"golemfactory","id":23193179,"avatar_url":"https://avatars1.githubusercontent.com/u/23193179?v=4","gravatar_id":"","url":"https://api.github.com/users/golemfactory","html_url":"https://github.com/golemfactory","followers_url":"https://api.github.com/users/golemfactory/followers","following_url":"https://api.github.com/users/golemfactory/following{/other_user}","gists_url":"https://api.github.com/users/golemfactory/gists{/gist_id}","starred_url":"https://api.github.com/users/golemfactory/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/golemfactory/subscriptions","organizations_url":"https://api.github.com/users/golemfactory/orgs","repos_url":"https://api.github.com/users/golemfactory/repos","events_url":"https://api.github.com/users/golemfactory/events{/privacy}","received_events_url":"https://api.github.com/users/golemfactory/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/golemfactory/concent","description":"Repository for Concent Service sources","fork":false,"url":"https://api.github.com/repos/golemfactory/concent","forks_url":"https://api.github.com/repos/golemfactory/concent/forks","keys_url":"https://api.github.com/repos/golemfactory/concent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/golemfactory/concent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/golemfactory/concent/teams","hooks_url":"https://api.github.com/repos/golemfactory/concent/hooks","issue_events_url":"https://api.github.com/repos/golemfactory/concent/issues/events{/number}","events_url":"https://api.github.com/repos/golemfactory/concent/events","assignees_url":"https://api.github.com/repos/golemfactory/concent/assignees{/user}","branches_url":"https://api.github.com/repos/golemfactory/concent/branches{/branch}","tags_url":"https://api.github.com/repos/golemfactory/concent/tags","blobs_url":"https://api.github.com/repos/golemfactory/concent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/golemfactory/concent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/golemfactory/concent/git/refs{/sha}","trees_url":"https://api.github.com/repos/golemfactory/concent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/golemfactory/concent/statuses/{sha}","languages_url":"https://api.github.com/repos/golemfactory/concent/languages","stargazers_url":"https://api.github.com/repos/golemfactory/concent/stargazers","contributors_url":"https://api.github.com/repos/golemfactory/concent/contributors","subscribers_url":"https://api.github.com/repos/golemfactory/concent/subscribers","subscription_url":"https://api.github.com/repos/golemfactory/concent/subscription","commits_url":"https://api.github.com/repos/golemfactory/concent/commits{/sha}","git_commits_url":"https://api.github.com/repos/golemfactory/concent/git/commits{/sha}","comments_url":"https://api.github.com/repos/golemfactory/concent/comments{/number}","issue_comment_url":"https://api.github.com/repos/golemfactory/concent/issues/comments{/number}","contents_url":"https://api.github.com/repos/golemfactory/concent/contents/{+path}","compare_url":"https://api.github.com/repos/golemfactory/concent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/golemfactory/concent/merges","archive_url":"https://api.github.com/repos/golemfactory/concent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/golemfactory/concent/downloads","issues_url":"https://api.github.com/repos/golemfactory/concent/issues{/number}","pulls_url":"https://api.github.com/repos/golemfactory/concent/pulls{/number}","milestones_url":"https://api.github.com/repos/golemfactory/concent/milestones{/number}","notifications_url":"https://api.github.com/repos/golemfactory/concent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/golemfactory/concent/labels{/name}","releases_url":"https://api.github.com/repos/golemfactory/concent/releases{/id}","deployments_url":"https://api.github.com/repos/golemfactory/concent/deployments","created_at":"2017-10-30T10:41:44Z","updated_at":"2018-02-23T23:12:15Z","pushed_at":"2018-03-08T23:23:28Z","git_url":"git://github.com/golemfactory/concent.git","ssh_url":"git@github.com:golemfactory/concent.git","clone_url":"https://github.com/golemfactory/concent.git","svn_url":"https://github.com/golemfactory/concent","homepage":null,"size":638,"stargazers_count":1,"watchers_count":1,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":51,"license":null,"forks":0,"open_issues":51,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/golemfactory/concent/pulls/162"},"html":{"href":"https://github.com/golemfactory/concent/pull/162"},"issue":{"href":"https://api.github.com/repos/golemfactory/concent/issues/162"},"comments":{"href":"https://api.github.com/repos/golemfactory/concent/issues/162/comments"},"review_comments":{"href":"https://api.github.com/repos/golemfactory/concent/pulls/162/comments"},"review_comment":{"href":"https://api.github.com/repos/golemfactory/concent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/golemfactory/concent/pulls/162/commits"},"statuses":{"href":"https://api.github.com/repos/golemfactory/concent/statuses/49499593d9ab51117a60c2bb1ffcdf34d7ab0d09"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rwrzesien"}}