{"action":"created","comment":{"url":"https://api.github.com/repos/LevenLabs/saturn/pulls/comments/40011559","id":40011559,"diff_hunk":"@@ -48,54 +57,135 @@ func advertise() {\n \n \t\tllog.Info(\"connecting to skyapi\", llog.KV{\"resolvedAddr\": skyapiAddr, \"thisAddr\": config.ListenAddr})\n \n-\t\tgo func() {\n-\t\t\terr := client.ProvideOpts(client.Opts{\n-\t\t\t\tSkyAPIAddr:        skyapiAddr,\n-\t\t\t\tService:           \"saturn\",\n-\t\t\t\tThisAddr:          config.ListenAddr,\n-\t\t\t\tReconnectAttempts: 3,\n-\t\t\t})\n-\t\t\tllog.Fatal(\"skyapi giving up reconnecting\", llog.KV{\n-\t\t\t\t\"addr\":         config.SkyAPIAddr,\n-\t\t\t\t\"resolvedAddr\": skyapiAddr,\n-\t\t\t\t\"err\":          err,\n-\t\t\t})\n-\t\t}()\n+\t\terr = client.ProvideOpts(client.Opts{\n+\t\t\tSkyAPIAddr:        skyapiAddr,\n+\t\t\tService:           \"saturn\",\n+\t\t\tThisAddr:          config.ListenAddr,\n+\t\t\tReconnectAttempts: 3,\n+\t\t})\n+\t\tllog.Fatal(\"skyapi giving up reconnecting\", llog.KV{\n+\t\t\t\"addr\":         config.SkyAPIAddr,\n+\t\t\t\"resolvedAddr\": skyapiAddr,\n+\t\t\t\"err\":          err,\n+\t\t})\n+\t}\n+}\n+\n+func marshalAndWrite(msg proto.Message, c *net.UDPConn, dst *net.UDPAddr, kv llog.KV) bool {\n+\tb, err := proto.Marshal(msg)\n+\tif err != nil {\n+\t\tkv[\"err\"] = err\n+\t\tllog.Error(\"error marshaling msg\", kv)\n+\t\treturn false\n+\t}\n+\n+\tif dst == nil {\n+\t\t_, err = c.Write(b)\n+\t} else {\n+\t\t_, err = c.WriteToUDP(b, dst)\n+\t}\n+\n+\tif err != nil {\n+\t\tkv[\"err\"] = err\n+\t\tllog.Error(\"error writing msg\", kv)\n+\t\treturn false\n \t}\n+\treturn true\n+}\n+\n+func readAndUnmarshal(c *net.UDPConn, kv llog.KV) (*lproto.TxMsg, *net.UDPAddr, bool) {\n+\tb := make([]byte, 1024)\n+\tn, addr, err := c.ReadFromUDP(b)\n+\tif err != nil {\n+\t\tkv[\"err\"] = err\n+\t\tllog.Error(\"error reading from udp socket\", kv)\n+\t\treturn nil, nil, false\n+\t}\n+\n+\tvar msg lproto.TxMsg\n+\tif err := proto.Unmarshal(b[:n], &msg); err != nil {\n+\t\tkv[\"err\"] = err\n+\t\tllog.Error(\"error unmarshaling proto msg\", kv)\n+\t\treturn nil, nil, false\n+\t}\n+\treturn &msg, addr, true\n }\n \n func reportSpin() {\n-\tvar masterAddr string\n-\tvar serverAddr *net.UDPAddr\n-\tvar err error\n-\tfor range time.Tick(10 * time.Second) {\n-\t\tmasterAddr = lookupMaster()\n-\t\tserverAddr, err = net.ResolveUDPAddr(\"udp\", masterAddr)\n-\t\tif err != nil {\n-\t\t\tllog.Fatal(\"error resolving UDP addr\", llog.KV{\"err\": err, \"addr\": masterAddr})\n+\tdoSlaveReport()\n+\tfor _ = range time.Tick(time.Duration(config.Interval) * time.Second) {\n+\t\tdoSlaveReport()\n+\t}\n+}\n+\n+func doSlaveReport() {\n+\tmasterAddr := lookupMaster()\n+\tkv := llog.KV{\"addr\": masterAddr}\n+\tllog.Info(\"beginning transaction\", kv)\n+\n+\tc, err := net.DialUDP(\"udp\", nil, masterAddr)\n+\tif err != nil {\n+\t\tkv[\"err\"] = err\n+\t\tllog.Error(\"error connecting to master\", kv)\n+\t\treturn\n+\t}\n+\tdefer c.Close()\n+\n+\tfirstMsg := transaction.Initiate()\n+\tkv[\"txID\"] = firstMsg.Id","path":"main.go","position":161,"original_position":161,"commit_id":"f042c9572c7cfdb72665de7d096329df4c6f3dbb","original_commit_id":"f042c9572c7cfdb72665de7d096329df4c6f3dbb","user":{"login":"mediocregopher","id":933154,"avatar_url":"https://avatars.githubusercontent.com/u/933154?v=3","gravatar_id":"","url":"https://api.github.com/users/mediocregopher","html_url":"https://github.com/mediocregopher","followers_url":"https://api.github.com/users/mediocregopher/followers","following_url":"https://api.github.com/users/mediocregopher/following{/other_user}","gists_url":"https://api.github.com/users/mediocregopher/gists{/gist_id}","starred_url":"https://api.github.com/users/mediocregopher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mediocregopher/subscriptions","organizations_url":"https://api.github.com/users/mediocregopher/orgs","repos_url":"https://api.github.com/users/mediocregopher/repos","events_url":"https://api.github.com/users/mediocregopher/events{/privacy}","received_events_url":"https://api.github.com/users/mediocregopher/received_events","type":"User","site_admin":false},"body":"I believe it does, it makes a `UDPConn` which ought to have the local address on it.\r\n\r\nI think just upping the number of random bits to something high would address both of our problems. How did you feel about that?","created_at":"2015-09-21T19:04:06Z","updated_at":"2015-09-21T19:04:06Z","html_url":"https://github.com/LevenLabs/saturn/pull/3#discussion_r40011559","pull_request_url":"https://api.github.com/repos/LevenLabs/saturn/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/LevenLabs/saturn/pulls/comments/40011559"},"html":{"href":"https://github.com/LevenLabs/saturn/pull/3#discussion_r40011559"},"pull_request":{"href":"https://api.github.com/repos/LevenLabs/saturn/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/LevenLabs/saturn/pulls/3","id":45511526,"html_url":"https://github.com/LevenLabs/saturn/pull/3","diff_url":"https://github.com/LevenLabs/saturn/pull/3.diff","patch_url":"https://github.com/LevenLabs/saturn/pull/3.patch","issue_url":"https://api.github.com/repos/LevenLabs/saturn/issues/3","number":3,"state":"open","locked":false,"title":"Refactor","user":{"login":"fastest963","id":112555,"avatar_url":"https://avatars.githubusercontent.com/u/112555?v=3","gravatar_id":"","url":"https://api.github.com/users/fastest963","html_url":"https://github.com/fastest963","followers_url":"https://api.github.com/users/fastest963/followers","following_url":"https://api.github.com/users/fastest963/following{/other_user}","gists_url":"https://api.github.com/users/fastest963/gists{/gist_id}","starred_url":"https://api.github.com/users/fastest963/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fastest963/subscriptions","organizations_url":"https://api.github.com/users/fastest963/orgs","repos_url":"https://api.github.com/users/fastest963/repos","events_url":"https://api.github.com/users/fastest963/events{/privacy}","received_events_url":"https://api.github.com/users/fastest963/received_events","type":"User","site_admin":false},"body":"@mediocregopher ","created_at":"2015-09-21T03:10:52Z","updated_at":"2015-09-21T19:04:06Z","closed_at":null,"merged_at":null,"merge_commit_sha":"415b4ed54fe312d8aec42c6a877618124e5ca422","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/LevenLabs/saturn/pulls/3/commits","review_comments_url":"https://api.github.com/repos/LevenLabs/saturn/pulls/3/comments","review_comment_url":"https://api.github.com/repos/LevenLabs/saturn/pulls/comments{/number}","comments_url":"https://api.github.com/repos/LevenLabs/saturn/issues/3/comments","statuses_url":"https://api.github.com/repos/LevenLabs/saturn/statuses/f042c9572c7cfdb72665de7d096329df4c6f3dbb","head":{"label":"LevenLabs:refactor","ref":"refactor","sha":"f042c9572c7cfdb72665de7d096329df4c6f3dbb","user":{"login":"LevenLabs","id":13338552,"avatar_url":"https://avatars.githubusercontent.com/u/13338552?v=3","gravatar_id":"","url":"https://api.github.com/users/LevenLabs","html_url":"https://github.com/LevenLabs","followers_url":"https://api.github.com/users/LevenLabs/followers","following_url":"https://api.github.com/users/LevenLabs/following{/other_user}","gists_url":"https://api.github.com/users/LevenLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/LevenLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LevenLabs/subscriptions","organizations_url":"https://api.github.com/users/LevenLabs/orgs","repos_url":"https://api.github.com/users/LevenLabs/repos","events_url":"https://api.github.com/users/LevenLabs/events{/privacy}","received_events_url":"https://api.github.com/users/LevenLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":41949072,"name":"saturn","full_name":"LevenLabs/saturn","owner":{"login":"LevenLabs","id":13338552,"avatar_url":"https://avatars.githubusercontent.com/u/13338552?v=3","gravatar_id":"","url":"https://api.github.com/users/LevenLabs","html_url":"https://github.com/LevenLabs","followers_url":"https://api.github.com/users/LevenLabs/followers","following_url":"https://api.github.com/users/LevenLabs/following{/other_user}","gists_url":"https://api.github.com/users/LevenLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/LevenLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LevenLabs/subscriptions","organizations_url":"https://api.github.com/users/LevenLabs/orgs","repos_url":"https://api.github.com/users/LevenLabs/repos","events_url":"https://api.github.com/users/LevenLabs/events{/privacy}","received_events_url":"https://api.github.com/users/LevenLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LevenLabs/saturn","description":"Simple time checker across a set of servers","fork":false,"url":"https://api.github.com/repos/LevenLabs/saturn","forks_url":"https://api.github.com/repos/LevenLabs/saturn/forks","keys_url":"https://api.github.com/repos/LevenLabs/saturn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LevenLabs/saturn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LevenLabs/saturn/teams","hooks_url":"https://api.github.com/repos/LevenLabs/saturn/hooks","issue_events_url":"https://api.github.com/repos/LevenLabs/saturn/issues/events{/number}","events_url":"https://api.github.com/repos/LevenLabs/saturn/events","assignees_url":"https://api.github.com/repos/LevenLabs/saturn/assignees{/user}","branches_url":"https://api.github.com/repos/LevenLabs/saturn/branches{/branch}","tags_url":"https://api.github.com/repos/LevenLabs/saturn/tags","blobs_url":"https://api.github.com/repos/LevenLabs/saturn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LevenLabs/saturn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LevenLabs/saturn/git/refs{/sha}","trees_url":"https://api.github.com/repos/LevenLabs/saturn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LevenLabs/saturn/statuses/{sha}","languages_url":"https://api.github.com/repos/LevenLabs/saturn/languages","stargazers_url":"https://api.github.com/repos/LevenLabs/saturn/stargazers","contributors_url":"https://api.github.com/repos/LevenLabs/saturn/contributors","subscribers_url":"https://api.github.com/repos/LevenLabs/saturn/subscribers","subscription_url":"https://api.github.com/repos/LevenLabs/saturn/subscription","commits_url":"https://api.github.com/repos/LevenLabs/saturn/commits{/sha}","git_commits_url":"https://api.github.com/repos/LevenLabs/saturn/git/commits{/sha}","comments_url":"https://api.github.com/repos/LevenLabs/saturn/comments{/number}","issue_comment_url":"https://api.github.com/repos/LevenLabs/saturn/issues/comments{/number}","contents_url":"https://api.github.com/repos/LevenLabs/saturn/contents/{+path}","compare_url":"https://api.github.com/repos/LevenLabs/saturn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LevenLabs/saturn/merges","archive_url":"https://api.github.com/repos/LevenLabs/saturn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LevenLabs/saturn/downloads","issues_url":"https://api.github.com/repos/LevenLabs/saturn/issues{/number}","pulls_url":"https://api.github.com/repos/LevenLabs/saturn/pulls{/number}","milestones_url":"https://api.github.com/repos/LevenLabs/saturn/milestones{/number}","notifications_url":"https://api.github.com/repos/LevenLabs/saturn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LevenLabs/saturn/labels{/name}","releases_url":"https://api.github.com/repos/LevenLabs/saturn/releases{/id}","created_at":"2015-09-05T04:33:59Z","updated_at":"2015-09-05T04:37:36Z","pushed_at":"2015-09-21T03:10:52Z","git_url":"git://github.com/LevenLabs/saturn.git","ssh_url":"git@github.com:LevenLabs/saturn.git","clone_url":"https://github.com/LevenLabs/saturn.git","svn_url":"https://github.com/LevenLabs/saturn","homepage":null,"size":2120,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"LevenLabs:master","ref":"master","sha":"6fe89583c200864ee47af918942a70abc3a49377","user":{"login":"LevenLabs","id":13338552,"avatar_url":"https://avatars.githubusercontent.com/u/13338552?v=3","gravatar_id":"","url":"https://api.github.com/users/LevenLabs","html_url":"https://github.com/LevenLabs","followers_url":"https://api.github.com/users/LevenLabs/followers","following_url":"https://api.github.com/users/LevenLabs/following{/other_user}","gists_url":"https://api.github.com/users/LevenLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/LevenLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LevenLabs/subscriptions","organizations_url":"https://api.github.com/users/LevenLabs/orgs","repos_url":"https://api.github.com/users/LevenLabs/repos","events_url":"https://api.github.com/users/LevenLabs/events{/privacy}","received_events_url":"https://api.github.com/users/LevenLabs/received_events","type":"Organization","site_admin":false},"repo":{"id":41949072,"name":"saturn","full_name":"LevenLabs/saturn","owner":{"login":"LevenLabs","id":13338552,"avatar_url":"https://avatars.githubusercontent.com/u/13338552?v=3","gravatar_id":"","url":"https://api.github.com/users/LevenLabs","html_url":"https://github.com/LevenLabs","followers_url":"https://api.github.com/users/LevenLabs/followers","following_url":"https://api.github.com/users/LevenLabs/following{/other_user}","gists_url":"https://api.github.com/users/LevenLabs/gists{/gist_id}","starred_url":"https://api.github.com/users/LevenLabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LevenLabs/subscriptions","organizations_url":"https://api.github.com/users/LevenLabs/orgs","repos_url":"https://api.github.com/users/LevenLabs/repos","events_url":"https://api.github.com/users/LevenLabs/events{/privacy}","received_events_url":"https://api.github.com/users/LevenLabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/LevenLabs/saturn","description":"Simple time checker across a set of servers","fork":false,"url":"https://api.github.com/repos/LevenLabs/saturn","forks_url":"https://api.github.com/repos/LevenLabs/saturn/forks","keys_url":"https://api.github.com/repos/LevenLabs/saturn/keys{/key_id}","collaborators_url":"https://api.github.com/repos/LevenLabs/saturn/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/LevenLabs/saturn/teams","hooks_url":"https://api.github.com/repos/LevenLabs/saturn/hooks","issue_events_url":"https://api.github.com/repos/LevenLabs/saturn/issues/events{/number}","events_url":"https://api.github.com/repos/LevenLabs/saturn/events","assignees_url":"https://api.github.com/repos/LevenLabs/saturn/assignees{/user}","branches_url":"https://api.github.com/repos/LevenLabs/saturn/branches{/branch}","tags_url":"https://api.github.com/repos/LevenLabs/saturn/tags","blobs_url":"https://api.github.com/repos/LevenLabs/saturn/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/LevenLabs/saturn/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/LevenLabs/saturn/git/refs{/sha}","trees_url":"https://api.github.com/repos/LevenLabs/saturn/git/trees{/sha}","statuses_url":"https://api.github.com/repos/LevenLabs/saturn/statuses/{sha}","languages_url":"https://api.github.com/repos/LevenLabs/saturn/languages","stargazers_url":"https://api.github.com/repos/LevenLabs/saturn/stargazers","contributors_url":"https://api.github.com/repos/LevenLabs/saturn/contributors","subscribers_url":"https://api.github.com/repos/LevenLabs/saturn/subscribers","subscription_url":"https://api.github.com/repos/LevenLabs/saturn/subscription","commits_url":"https://api.github.com/repos/LevenLabs/saturn/commits{/sha}","git_commits_url":"https://api.github.com/repos/LevenLabs/saturn/git/commits{/sha}","comments_url":"https://api.github.com/repos/LevenLabs/saturn/comments{/number}","issue_comment_url":"https://api.github.com/repos/LevenLabs/saturn/issues/comments{/number}","contents_url":"https://api.github.com/repos/LevenLabs/saturn/contents/{+path}","compare_url":"https://api.github.com/repos/LevenLabs/saturn/compare/{base}...{head}","merges_url":"https://api.github.com/repos/LevenLabs/saturn/merges","archive_url":"https://api.github.com/repos/LevenLabs/saturn/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/LevenLabs/saturn/downloads","issues_url":"https://api.github.com/repos/LevenLabs/saturn/issues{/number}","pulls_url":"https://api.github.com/repos/LevenLabs/saturn/pulls{/number}","milestones_url":"https://api.github.com/repos/LevenLabs/saturn/milestones{/number}","notifications_url":"https://api.github.com/repos/LevenLabs/saturn/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/LevenLabs/saturn/labels{/name}","releases_url":"https://api.github.com/repos/LevenLabs/saturn/releases{/id}","created_at":"2015-09-05T04:33:59Z","updated_at":"2015-09-05T04:37:36Z","pushed_at":"2015-09-21T03:10:52Z","git_url":"git://github.com/LevenLabs/saturn.git","ssh_url":"git@github.com:LevenLabs/saturn.git","clone_url":"https://github.com/LevenLabs/saturn.git","svn_url":"https://github.com/LevenLabs/saturn","homepage":null,"size":2120,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/LevenLabs/saturn/pulls/3"},"html":{"href":"https://github.com/LevenLabs/saturn/pull/3"},"issue":{"href":"https://api.github.com/repos/LevenLabs/saturn/issues/3"},"comments":{"href":"https://api.github.com/repos/LevenLabs/saturn/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/LevenLabs/saturn/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/LevenLabs/saturn/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/LevenLabs/saturn/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/LevenLabs/saturn/statuses/f042c9572c7cfdb72665de7d096329df4c6f3dbb"}}}}