{"action":"created","comment":{"url":"https://api.github.com/repos/status-im/status-go/pulls/comments/184064496","pull_request_review_id":115183012,"id":184064496,"diff_hunk":"@@ -2,30 +2,84 @@ package shhext\n \n import (\n \t\"context\"\n+\t\"crypto/ecdsa\"\n+\t\"encoding/binary\"\n+\t\"errors\"\n \t\"fmt\"\n+\t\"time\"\n \n \t\"github.com/ethereum/go-ethereum/common\"\n+\t\"github.com/ethereum/go-ethereum/log\"\n \t\"github.com/ethereum/go-ethereum/p2p/discover\"\n \twhisper \"github.com/ethereum/go-ethereum/whisper/whisperv6\"\n )\n \n-// NewPublicAPI returns instance of the public API.\n-func NewPublicAPI(w *whisper.Whisper, tracker *tracker) *PublicAPI {\n-\treturn &PublicAPI{\n-\t\tw:       w,\n-\t\ttracker: tracker,\n+const (\n+\t// defaultWorkTime is a work time reported in messages sent to MailServer nodes.\n+\tdefaultWorkTime = 5\n+)\n+\n+var (\n+\t// ErrInvalidMailServerPeer is returned when it fails to parse enode from params.\n+\tErrInvalidMailServerPeer = errors.New(\"invalid mailServerPeer value\")\n+\t// ErrInvalidSymKeyID is returned when it fails to get a symmetric key.\n+\tErrInvalidSymKeyID = errors.New(\"invalid symKeyID value\")\n+)\n+\n+// -----\n+// PAYLOADS\n+// -----\n+\n+// MessagesRequest is a payload send to a MailServer to get messages.\n+type MessagesRequest struct {\n+\t// MailServerPeer is MailServer's enode address.\n+\tMailServerPeer string `json:\"mailServerPeer\"`\n+\n+\t// From is a lower bound of time range (optional).\n+\t// Default is 24 hours back from now.\n+\tFrom uint32 `json:\"from\"`\n+\n+\t// To is a upper bound of time range (optional).\n+\t// Default is now.\n+\tTo uint32 `json:\"to\"`\n+\n+\t// Topic is a regular Whisper topic.\n+\tTopic whisper.TopicType `json:\"topic\"`\n+\n+\t// SymKeyID is an ID of a symmetric key to authenticate to MailServer.\n+\t// It's derived from MailServer password.\n+\tSymKeyID string `json:\"symKeyID\"`\n+}\n+\n+func (r *MessagesRequest) setDefaults() {\n+\t// set From and To defaults\n+\tif r.From == 0 && r.To == 0 {\n+\t\tr.From = uint32(time.Now().UTC().Add(-24 * time.Hour).Unix())\n+\t\tr.To = uint32(time.Now().UTC().Unix())\n \t}\n }\n \n+// -----","path":"services/shhext/api.go","position":68,"original_position":66,"commit_id":"d3aa7062c2b6974c0a4b32e92ef69a8b14695db3","original_commit_id":"32cecaba8a29067e0c826bf3be7f57bdb60d1c70","user":{"login":"themue","id":1633981,"avatar_url":"https://avatars0.githubusercontent.com/u/1633981?v=4","gravatar_id":"","url":"https://api.github.com/users/themue","html_url":"https://github.com/themue","followers_url":"https://api.github.com/users/themue/followers","following_url":"https://api.github.com/users/themue/following{/other_user}","gists_url":"https://api.github.com/users/themue/gists{/gist_id}","starred_url":"https://api.github.com/users/themue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themue/subscriptions","organizations_url":"https://api.github.com/users/themue/orgs","repos_url":"https://api.github.com/users/themue/repos","events_url":"https://api.github.com/users/themue/events{/privacy}","received_events_url":"https://api.github.com/users/themue/received_events","type":"User","site_admin":false},"body":"As long as the file is small enough it's IMHO okay. But later we've got to keep an eye on it, yes.\r\n\r\nHad seen these block building comments in larger projects and learned them as being quite helpful when later have to orient in a source code. So adopted them.","created_at":"2018-04-25T13:46:28Z","updated_at":"2018-04-25T13:46:28Z","html_url":"https://github.com/status-im/status-go/pull/862#discussion_r184064496","pull_request_url":"https://api.github.com/repos/status-im/status-go/pulls/862","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/status-im/status-go/pulls/comments/184064496"},"html":{"href":"https://github.com/status-im/status-go/pull/862#discussion_r184064496"},"pull_request":{"href":"https://api.github.com/repos/status-im/status-go/pulls/862"}},"in_reply_to_id":183980620},"pull_request":{"url":"https://api.github.com/repos/status-im/status-go/pulls/862","id":183772201,"html_url":"https://github.com/status-im/status-go/pull/862","diff_url":"https://github.com/status-im/status-go/pull/862.diff","patch_url":"https://github.com/status-im/status-go/pull/862.patch","issue_url":"https://api.github.com/repos/status-im/status-go/issues/862","number":862,"state":"open","locked":false,"title":"Move ssh_requestMessages to sshext_requestMessages","user":{"login":"themue","id":1633981,"avatar_url":"https://avatars0.githubusercontent.com/u/1633981?v=4","gravatar_id":"","url":"https://api.github.com/users/themue","html_url":"https://github.com/themue","followers_url":"https://api.github.com/users/themue/followers","following_url":"https://api.github.com/users/themue/following{/other_user}","gists_url":"https://api.github.com/users/themue/gists{/gist_id}","starred_url":"https://api.github.com/users/themue/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/themue/subscriptions","organizations_url":"https://api.github.com/users/themue/orgs","repos_url":"https://api.github.com/users/themue/repos","events_url":"https://api.github.com/users/themue/events{/privacy}","received_events_url":"https://api.github.com/users/themue/received_events","type":"User","site_admin":false},"body":"Moving `ssh_requestMessages` to `sshext` namespace.\r\n\r\nCloses #850 \r\n","created_at":"2018-04-24T15:15:41Z","updated_at":"2018-04-25T13:46:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78b56450690017920610e55eb18d82ffd41597db","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/status-im/status-go/pulls/862/commits","review_comments_url":"https://api.github.com/repos/status-im/status-go/pulls/862/comments","review_comment_url":"https://api.github.com/repos/status-im/status-go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/status-im/status-go/issues/862/comments","statuses_url":"https://api.github.com/repos/status-im/status-go/statuses/d3aa7062c2b6974c0a4b32e92ef69a8b14695db3","head":{"label":"status-im:issue-850/move-whisper-request","ref":"issue-850/move-whisper-request","sha":"d3aa7062c2b6974c0a4b32e92ef69a8b14695db3","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":61047867,"name":"status-go","full_name":"status-im/status-go","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-go","description":"The Status module that consumes go-ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-go","forks_url":"https://api.github.com/repos/status-im/status-go/forks","keys_url":"https://api.github.com/repos/status-im/status-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-go/teams","hooks_url":"https://api.github.com/repos/status-im/status-go/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-go/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-go/events","assignees_url":"https://api.github.com/repos/status-im/status-go/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-go/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-go/tags","blobs_url":"https://api.github.com/repos/status-im/status-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-go/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-go/languages","stargazers_url":"https://api.github.com/repos/status-im/status-go/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-go/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-go/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-go/subscription","commits_url":"https://api.github.com/repos/status-im/status-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-go/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-go/merges","archive_url":"https://api.github.com/repos/status-im/status-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-go/downloads","issues_url":"https://api.github.com/repos/status-im/status-go/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-go/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-go/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-go/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-go/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-go/deployments","created_at":"2016-06-13T15:32:03Z","updated_at":"2018-04-25T07:14:02Z","pushed_at":"2018-04-25T13:44:00Z","git_url":"git://github.com/status-im/status-go.git","ssh_url":"git@github.com:status-im/status-go.git","clone_url":"https://github.com/status-im/status-go.git","svn_url":"https://github.com/status-im/status-go","homepage":"https://status.im","size":38033,"stargazers_count":376,"watchers_count":376,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":123,"mirror_url":null,"archived":false,"open_issues_count":61,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":123,"open_issues":61,"watchers":376,"default_branch":"develop"}},"base":{"label":"status-im:develop","ref":"develop","sha":"f3e2631c1daa7e57d45944ef82c1ed57ac4fa644","user":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"repo":{"id":61047867,"name":"status-go","full_name":"status-im/status-go","owner":{"login":"status-im","id":11767950,"avatar_url":"https://avatars1.githubusercontent.com/u/11767950?v=4","gravatar_id":"","url":"https://api.github.com/users/status-im","html_url":"https://github.com/status-im","followers_url":"https://api.github.com/users/status-im/followers","following_url":"https://api.github.com/users/status-im/following{/other_user}","gists_url":"https://api.github.com/users/status-im/gists{/gist_id}","starred_url":"https://api.github.com/users/status-im/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/status-im/subscriptions","organizations_url":"https://api.github.com/users/status-im/orgs","repos_url":"https://api.github.com/users/status-im/repos","events_url":"https://api.github.com/users/status-im/events{/privacy}","received_events_url":"https://api.github.com/users/status-im/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/status-im/status-go","description":"The Status module that consumes go-ethereum","fork":false,"url":"https://api.github.com/repos/status-im/status-go","forks_url":"https://api.github.com/repos/status-im/status-go/forks","keys_url":"https://api.github.com/repos/status-im/status-go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/status-im/status-go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/status-im/status-go/teams","hooks_url":"https://api.github.com/repos/status-im/status-go/hooks","issue_events_url":"https://api.github.com/repos/status-im/status-go/issues/events{/number}","events_url":"https://api.github.com/repos/status-im/status-go/events","assignees_url":"https://api.github.com/repos/status-im/status-go/assignees{/user}","branches_url":"https://api.github.com/repos/status-im/status-go/branches{/branch}","tags_url":"https://api.github.com/repos/status-im/status-go/tags","blobs_url":"https://api.github.com/repos/status-im/status-go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/status-im/status-go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/status-im/status-go/git/refs{/sha}","trees_url":"https://api.github.com/repos/status-im/status-go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/status-im/status-go/statuses/{sha}","languages_url":"https://api.github.com/repos/status-im/status-go/languages","stargazers_url":"https://api.github.com/repos/status-im/status-go/stargazers","contributors_url":"https://api.github.com/repos/status-im/status-go/contributors","subscribers_url":"https://api.github.com/repos/status-im/status-go/subscribers","subscription_url":"https://api.github.com/repos/status-im/status-go/subscription","commits_url":"https://api.github.com/repos/status-im/status-go/commits{/sha}","git_commits_url":"https://api.github.com/repos/status-im/status-go/git/commits{/sha}","comments_url":"https://api.github.com/repos/status-im/status-go/comments{/number}","issue_comment_url":"https://api.github.com/repos/status-im/status-go/issues/comments{/number}","contents_url":"https://api.github.com/repos/status-im/status-go/contents/{+path}","compare_url":"https://api.github.com/repos/status-im/status-go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/status-im/status-go/merges","archive_url":"https://api.github.com/repos/status-im/status-go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/status-im/status-go/downloads","issues_url":"https://api.github.com/repos/status-im/status-go/issues{/number}","pulls_url":"https://api.github.com/repos/status-im/status-go/pulls{/number}","milestones_url":"https://api.github.com/repos/status-im/status-go/milestones{/number}","notifications_url":"https://api.github.com/repos/status-im/status-go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/status-im/status-go/labels{/name}","releases_url":"https://api.github.com/repos/status-im/status-go/releases{/id}","deployments_url":"https://api.github.com/repos/status-im/status-go/deployments","created_at":"2016-06-13T15:32:03Z","updated_at":"2018-04-25T07:14:02Z","pushed_at":"2018-04-25T13:44:00Z","git_url":"git://github.com/status-im/status-go.git","ssh_url":"git@github.com:status-im/status-go.git","clone_url":"https://github.com/status-im/status-go.git","svn_url":"https://github.com/status-im/status-go","homepage":"https://status.im","size":38033,"stargazers_count":376,"watchers_count":376,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":123,"mirror_url":null,"archived":false,"open_issues_count":61,"license":{"key":"mpl-2.0","name":"Mozilla Public License 2.0","spdx_id":"MPL-2.0","url":"https://api.github.com/licenses/mpl-2.0"},"forks":123,"open_issues":61,"watchers":376,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/status-im/status-go/pulls/862"},"html":{"href":"https://github.com/status-im/status-go/pull/862"},"issue":{"href":"https://api.github.com/repos/status-im/status-go/issues/862"},"comments":{"href":"https://api.github.com/repos/status-im/status-go/issues/862/comments"},"review_comments":{"href":"https://api.github.com/repos/status-im/status-go/pulls/862/comments"},"review_comment":{"href":"https://api.github.com/repos/status-im/status-go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/status-im/status-go/pulls/862/commits"},"statuses":{"href":"https://api.github.com/repos/status-im/status-go/statuses/d3aa7062c2b6974c0a4b32e92ef69a8b14695db3"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"themue"}}