{"action":"created","comment":{"url":"https://api.github.com/repos/monetas/bmd/pulls/comments/32105964","id":32105964,"diff_hunk":"@@ -52,7 +52,11 @@ func TstSwapListen(f func(string, string) (net.Listener, error)) func(string, st\n \n // TstRetrieveObject exposes retrieveObject for testing purposes.\n func TstRetrieveObject(db database.Db, inv *wire.InvVect) wire.Message {\n-\treturn retrieveObject(db, inv)\n+\tobj := retrieveObject(db, inv)\n+\tif obj == nil {\n+\t\treturn nil\n+\t}\n+\treturn obj","path":"peer/internal_test.go","position":9,"original_position":9,"commit_id":"87624917fa386d69c973ea5d7a109d3eb7fa2075","original_commit_id":"fd811154f902d2bcc8e93a083534df1324d3d115","user":{"login":"ishbir","id":43928,"avatar_url":"https://avatars.githubusercontent.com/u/43928?v=3","gravatar_id":"","url":"https://api.github.com/users/ishbir","html_url":"https://github.com/ishbir","followers_url":"https://api.github.com/users/ishbir/followers","following_url":"https://api.github.com/users/ishbir/following{/other_user}","gists_url":"https://api.github.com/users/ishbir/gists{/gist_id}","starred_url":"https://api.github.com/users/ishbir/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ishbir/subscriptions","organizations_url":"https://api.github.com/users/ishbir/orgs","repos_url":"https://api.github.com/users/ishbir/repos","events_url":"https://api.github.com/users/ishbir/events{/privacy}","received_events_url":"https://api.github.com/users/ishbir/received_events","type":"User","site_admin":false},"body":"I was kinda confused initially and didn't bother to check. If we change the return type to *wire.MsgObject, it actually won't make any difference since we aren't storing nil in an interface but rather returning it straight-away. However, if it's kept as wire.Message, Go has to perform a cast from *wire.MsgObject to wire.Message interface. So the value of the interface might be nil, but it's type isn't.","created_at":"2015-06-10T10:48:52Z","updated_at":"2015-06-10T10:48:52Z","html_url":"https://github.com/monetas/bmd/pull/31#discussion_r32105964","pull_request_url":"https://api.github.com/repos/monetas/bmd/pulls/31","_links":{"self":{"href":"https://api.github.com/repos/monetas/bmd/pulls/comments/32105964"},"html":{"href":"https://github.com/monetas/bmd/pull/31#discussion_r32105964"},"pull_request":{"href":"https://api.github.com/repos/monetas/bmd/pulls/31"}}},"pull_request":{"url":"https://api.github.com/repos/monetas/bmd/pulls/31","id":37139909,"html_url":"https://github.com/monetas/bmd/pull/31","diff_url":"https://github.com/monetas/bmd/pull/31.diff","patch_url":"https://github.com/monetas/bmd/pull/31.patch","issue_url":"https://api.github.com/repos/monetas/bmd/issues/31","number":31,"state":"closed","locked":false,"title":"Bug fixes making initial download work. Object manager downloads from multiple peers simultaneously. Program is stable as far as I know. ","user":{"login":"DanielKrawisz","id":4990891,"avatar_url":"https://avatars.githubusercontent.com/u/4990891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKrawisz","html_url":"https://github.com/DanielKrawisz","followers_url":"https://api.github.com/users/DanielKrawisz/followers","following_url":"https://api.github.com/users/DanielKrawisz/following{/other_user}","gists_url":"https://api.github.com/users/DanielKrawisz/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKrawisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKrawisz/subscriptions","organizations_url":"https://api.github.com/users/DanielKrawisz/orgs","repos_url":"https://api.github.com/users/DanielKrawisz/repos","events_url":"https://api.github.com/users/DanielKrawisz/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKrawisz/received_events","type":"User","site_admin":false},"body":"The object manager now downloads large lists of invs from other peers more intelligently and there are a number of bug fixes. \r\n\r\n* When an inv is processed by the object manager, if it is too big to be processed by the peer that requested in all at once, the object manager goes through all the peers and apportions invs to them until they are all full or until there are no invs left.\r\n* Peers report to the object manager when they are ready to download more objects.\r\n* If a peer is disconnected, all invs assigned to it are reassigned to other peers. \r\n* When the peers are all done working, any remaining invs which no peer knows about are deleted from the set of unknown invs. \r\n* There was a very complicated bug that caused the object manager to lock up when its message channel filled up. This happened during the initial download when several object requests would expire at once. The object manager would then send a disconnect request to the peer for every single one, and for each one the peer would send a handledonepeer message back to the object manager! This is resolved by ensuring that the object manager only tells a peer to disconnect once and ensuring that the peer only calls DonePeer on the object manager once and ensuring that the object manager only tells the peer to disconnect once. This became especially convoluted when several peers are downloading at once because then the object manager could send a disconnect request to each peer. If more than one peer needs to be disconnected at once, a separate go routine is started that disconnects them one by one. I have also made the object manager more lenient about expired requests during the initial download. The original problem was caused by invalid timestamps that recorded when a peer last received an object. For some reason the times are recorded properly when I log them. I am still researching why this would happen, but I hypothesize that it has to do with the way go optimizes its processes. \r\n* Instead of relaying invs immediately, the object manager stores them and relays the whole list every 10 seconds. This works fine because the peers don't relay new invs immediately either but randomize the time. This also fixes a bug which caused the peers to relay new invs much too quickly because I confused a microsecond with a nanosecond. Now the new inv is relayed randomly every 20 to 60 seconds. \r\n* There is a new option for request timeout, ie the time at which an object request is considered to have expired. It is set by default at 3 minutes. \r\n* Finally, I fixed the issue with the pong timeout https://github.com/monetas/bmd/issues/28. I used a timer rather than a ticker because the ticker needs to be reset every time a message is sent. However, I forgot to make the ticker reset itself, which it does now. \r\n\r\nOriginally MaxPeerRequests was going to be a command-line option, but I don't think there is any reason a user would want to adjust it. It can cause problems if it is very low or very high, but any number in the middle ought to work fine. Right now it is a constant set at 120. ","created_at":"2015-06-08T10:29:24Z","updated_at":"2015-06-10T10:48:52Z","closed_at":"2015-06-09T12:49:19Z","merged_at":"2015-06-09T12:49:19Z","merge_commit_sha":"2215daf95c85b32c80fbe5fd31783000598cbd3f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/monetas/bmd/pulls/31/commits","review_comments_url":"https://api.github.com/repos/monetas/bmd/pulls/31/comments","review_comment_url":"https://api.github.com/repos/monetas/bmd/pulls/comments{/number}","comments_url":"https://api.github.com/repos/monetas/bmd/issues/31/comments","statuses_url":"https://api.github.com/repos/monetas/bmd/statuses/87624917fa386d69c973ea5d7a109d3eb7fa2075","head":{"label":"DanielKrawisz:more_bug_fixes","ref":"more_bug_fixes","sha":"87624917fa386d69c973ea5d7a109d3eb7fa2075","user":{"login":"DanielKrawisz","id":4990891,"avatar_url":"https://avatars.githubusercontent.com/u/4990891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKrawisz","html_url":"https://github.com/DanielKrawisz","followers_url":"https://api.github.com/users/DanielKrawisz/followers","following_url":"https://api.github.com/users/DanielKrawisz/following{/other_user}","gists_url":"https://api.github.com/users/DanielKrawisz/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKrawisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKrawisz/subscriptions","organizations_url":"https://api.github.com/users/DanielKrawisz/orgs","repos_url":"https://api.github.com/users/DanielKrawisz/repos","events_url":"https://api.github.com/users/DanielKrawisz/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKrawisz/received_events","type":"User","site_admin":false},"repo":{"id":34642817,"name":"bmd","full_name":"DanielKrawisz/bmd","owner":{"login":"DanielKrawisz","id":4990891,"avatar_url":"https://avatars.githubusercontent.com/u/4990891?v=3","gravatar_id":"","url":"https://api.github.com/users/DanielKrawisz","html_url":"https://github.com/DanielKrawisz","followers_url":"https://api.github.com/users/DanielKrawisz/followers","following_url":"https://api.github.com/users/DanielKrawisz/following{/other_user}","gists_url":"https://api.github.com/users/DanielKrawisz/gists{/gist_id}","starred_url":"https://api.github.com/users/DanielKrawisz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DanielKrawisz/subscriptions","organizations_url":"https://api.github.com/users/DanielKrawisz/orgs","repos_url":"https://api.github.com/users/DanielKrawisz/repos","events_url":"https://api.github.com/users/DanielKrawisz/events{/privacy}","received_events_url":"https://api.github.com/users/DanielKrawisz/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/DanielKrawisz/bmd","description":"","fork":true,"url":"https://api.github.com/repos/DanielKrawisz/bmd","forks_url":"https://api.github.com/repos/DanielKrawisz/bmd/forks","keys_url":"https://api.github.com/repos/DanielKrawisz/bmd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DanielKrawisz/bmd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DanielKrawisz/bmd/teams","hooks_url":"https://api.github.com/repos/DanielKrawisz/bmd/hooks","issue_events_url":"https://api.github.com/repos/DanielKrawisz/bmd/issues/events{/number}","events_url":"https://api.github.com/repos/DanielKrawisz/bmd/events","assignees_url":"https://api.github.com/repos/DanielKrawisz/bmd/assignees{/user}","branches_url":"https://api.github.com/repos/DanielKrawisz/bmd/branches{/branch}","tags_url":"https://api.github.com/repos/DanielKrawisz/bmd/tags","blobs_url":"https://api.github.com/repos/DanielKrawisz/bmd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DanielKrawisz/bmd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DanielKrawisz/bmd/git/refs{/sha}","trees_url":"https://api.github.com/repos/DanielKrawisz/bmd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DanielKrawisz/bmd/statuses/{sha}","languages_url":"https://api.github.com/repos/DanielKrawisz/bmd/languages","stargazers_url":"https://api.github.com/repos/DanielKrawisz/bmd/stargazers","contributors_url":"https://api.github.com/repos/DanielKrawisz/bmd/contributors","subscribers_url":"https://api.github.com/repos/DanielKrawisz/bmd/subscribers","subscription_url":"https://api.github.com/repos/DanielKrawisz/bmd/subscription","commits_url":"https://api.github.com/repos/DanielKrawisz/bmd/commits{/sha}","git_commits_url":"https://api.github.com/repos/DanielKrawisz/bmd/git/commits{/sha}","comments_url":"https://api.github.com/repos/DanielKrawisz/bmd/comments{/number}","issue_comment_url":"https://api.github.com/repos/DanielKrawisz/bmd/issues/comments{/number}","contents_url":"https://api.github.com/repos/DanielKrawisz/bmd/contents/{+path}","compare_url":"https://api.github.com/repos/DanielKrawisz/bmd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DanielKrawisz/bmd/merges","archive_url":"https://api.github.com/repos/DanielKrawisz/bmd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DanielKrawisz/bmd/downloads","issues_url":"https://api.github.com/repos/DanielKrawisz/bmd/issues{/number}","pulls_url":"https://api.github.com/repos/DanielKrawisz/bmd/pulls{/number}","milestones_url":"https://api.github.com/repos/DanielKrawisz/bmd/milestones{/number}","notifications_url":"https://api.github.com/repos/DanielKrawisz/bmd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DanielKrawisz/bmd/labels{/name}","releases_url":"https://api.github.com/repos/DanielKrawisz/bmd/releases{/id}","created_at":"2015-04-27T02:56:09Z","updated_at":"2015-06-07T05:18:54Z","pushed_at":"2015-06-09T12:46:11Z","git_url":"git://github.com/DanielKrawisz/bmd.git","ssh_url":"git@github.com:DanielKrawisz/bmd.git","clone_url":"https://github.com/DanielKrawisz/bmd.git","svn_url":"https://github.com/DanielKrawisz/bmd","homepage":null,"size":1822,"stargazers_count":1,"watchers_count":1,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"monetas:master","ref":"master","sha":"c4bafe2bb385f64beda7dc0563f60109505fd66f","user":{"login":"monetas","id":4219418,"avatar_url":"https://avatars.githubusercontent.com/u/4219418?v=3","gravatar_id":"","url":"https://api.github.com/users/monetas","html_url":"https://github.com/monetas","followers_url":"https://api.github.com/users/monetas/followers","following_url":"https://api.github.com/users/monetas/following{/other_user}","gists_url":"https://api.github.com/users/monetas/gists{/gist_id}","starred_url":"https://api.github.com/users/monetas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monetas/subscriptions","organizations_url":"https://api.github.com/users/monetas/orgs","repos_url":"https://api.github.com/users/monetas/repos","events_url":"https://api.github.com/users/monetas/events{/privacy}","received_events_url":"https://api.github.com/users/monetas/received_events","type":"Organization","site_admin":false},"repo":{"id":32594697,"name":"bmd","full_name":"monetas/bmd","owner":{"login":"monetas","id":4219418,"avatar_url":"https://avatars.githubusercontent.com/u/4219418?v=3","gravatar_id":"","url":"https://api.github.com/users/monetas","html_url":"https://github.com/monetas","followers_url":"https://api.github.com/users/monetas/followers","following_url":"https://api.github.com/users/monetas/following{/other_user}","gists_url":"https://api.github.com/users/monetas/gists{/gist_id}","starred_url":"https://api.github.com/users/monetas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/monetas/subscriptions","organizations_url":"https://api.github.com/users/monetas/orgs","repos_url":"https://api.github.com/users/monetas/repos","events_url":"https://api.github.com/users/monetas/events{/privacy}","received_events_url":"https://api.github.com/users/monetas/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/monetas/bmd","description":"Implementation of Bitmessage protocol in Go -- Alpha/Experimental Code","fork":false,"url":"https://api.github.com/repos/monetas/bmd","forks_url":"https://api.github.com/repos/monetas/bmd/forks","keys_url":"https://api.github.com/repos/monetas/bmd/keys{/key_id}","collaborators_url":"https://api.github.com/repos/monetas/bmd/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/monetas/bmd/teams","hooks_url":"https://api.github.com/repos/monetas/bmd/hooks","issue_events_url":"https://api.github.com/repos/monetas/bmd/issues/events{/number}","events_url":"https://api.github.com/repos/monetas/bmd/events","assignees_url":"https://api.github.com/repos/monetas/bmd/assignees{/user}","branches_url":"https://api.github.com/repos/monetas/bmd/branches{/branch}","tags_url":"https://api.github.com/repos/monetas/bmd/tags","blobs_url":"https://api.github.com/repos/monetas/bmd/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/monetas/bmd/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/monetas/bmd/git/refs{/sha}","trees_url":"https://api.github.com/repos/monetas/bmd/git/trees{/sha}","statuses_url":"https://api.github.com/repos/monetas/bmd/statuses/{sha}","languages_url":"https://api.github.com/repos/monetas/bmd/languages","stargazers_url":"https://api.github.com/repos/monetas/bmd/stargazers","contributors_url":"https://api.github.com/repos/monetas/bmd/contributors","subscribers_url":"https://api.github.com/repos/monetas/bmd/subscribers","subscription_url":"https://api.github.com/repos/monetas/bmd/subscription","commits_url":"https://api.github.com/repos/monetas/bmd/commits{/sha}","git_commits_url":"https://api.github.com/repos/monetas/bmd/git/commits{/sha}","comments_url":"https://api.github.com/repos/monetas/bmd/comments{/number}","issue_comment_url":"https://api.github.com/repos/monetas/bmd/issues/comments{/number}","contents_url":"https://api.github.com/repos/monetas/bmd/contents/{+path}","compare_url":"https://api.github.com/repos/monetas/bmd/compare/{base}...{head}","merges_url":"https://api.github.com/repos/monetas/bmd/merges","archive_url":"https://api.github.com/repos/monetas/bmd/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/monetas/bmd/downloads","issues_url":"https://api.github.com/repos/monetas/bmd/issues{/number}","pulls_url":"https://api.github.com/repos/monetas/bmd/pulls{/number}","milestones_url":"https://api.github.com/repos/monetas/bmd/milestones{/number}","notifications_url":"https://api.github.com/repos/monetas/bmd/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/monetas/bmd/labels{/name}","releases_url":"https://api.github.com/repos/monetas/bmd/releases{/id}","created_at":"2015-03-20T16:29:15Z","updated_at":"2015-06-10T05:50:49Z","pushed_at":"2015-06-09T13:17:14Z","git_url":"git://github.com/monetas/bmd.git","ssh_url":"git@github.com:monetas/bmd.git","clone_url":"https://github.com/monetas/bmd.git","svn_url":"https://github.com/monetas/bmd","homepage":"","size":2293,"stargazers_count":3,"watchers_count":3,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":0,"forks":4,"open_issues":0,"watchers":3,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/monetas/bmd/pulls/31"},"html":{"href":"https://github.com/monetas/bmd/pull/31"},"issue":{"href":"https://api.github.com/repos/monetas/bmd/issues/31"},"comments":{"href":"https://api.github.com/repos/monetas/bmd/issues/31/comments"},"review_comments":{"href":"https://api.github.com/repos/monetas/bmd/pulls/31/comments"},"review_comment":{"href":"https://api.github.com/repos/monetas/bmd/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/monetas/bmd/pulls/31/commits"},"statuses":{"href":"https://api.github.com/repos/monetas/bmd/statuses/87624917fa386d69c973ea5d7a109d3eb7fa2075"}}}}