{"action":"created","comment":{"url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments/80100074","id":80100074,"diff_hunk":"@@ -54,13 +62,27 @@ func (s *BlockService) AddBlock(b blocks.Block) (key.Key, error) {\n }\n \n func (s *BlockService) AddBlocks(bs []blocks.Block) ([]key.Key, error) {\n-\terr := s.Blockstore.PutMany(bs)\n+\tvar toput []blocks.Block\n+\tfor _, b := range bs {\n+\t\thas, err := s.Blockstore.Has(b.Key())\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\n+\t\tif has {\n+\t\t\tcontinue\n+\t\t}\n+\n+\t\ttoput = append(toput, b)\n+\t}\n+\n+\terr := s.Blockstore.PutMany(toput)\n \tif err != nil {\n \t\treturn nil, err\n \t}\n \n \tvar ks []key.Key\n-\tfor _, b := range bs {\n+\tfor _, b := range toput {\n \t\tif err := s.Exchange.HasBlock(b); err != nil {","path":"blockservice/blockservice.go","position":44,"original_position":44,"commit_id":"582e5dee3a97f994e7d204ed23960f5752f86553","original_commit_id":"582e5dee3a97f994e7d204ed23960f5752f86553","user":{"login":"kevina","id":1271492,"avatar_url":"https://avatars.githubusercontent.com/u/1271492?v=3","gravatar_id":"","url":"https://api.github.com/users/kevina","html_url":"https://github.com/kevina","followers_url":"https://api.github.com/users/kevina/followers","following_url":"https://api.github.com/users/kevina/following{/other_user}","gists_url":"https://api.github.com/users/kevina/gists{/gist_id}","starred_url":"https://api.github.com/users/kevina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kevina/subscriptions","organizations_url":"https://api.github.com/users/kevina/orgs","repos_url":"https://api.github.com/users/kevina/repos","events_url":"https://api.github.com/users/kevina/events{/privacy}","received_events_url":"https://api.github.com/users/kevina/received_events","type":"User","site_admin":false},"body":"@whyrusleeping, this change modifies the return value so that only the keys that don't already exist are returned.  Was this intentional?","created_at":"2016-09-22T18:00:34Z","updated_at":"2016-09-22T18:00:34Z","html_url":"https://github.com/ipfs/go-ipfs/pull/3105#discussion_r80100074","pull_request_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105","_links":{"self":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments/80100074"},"html":{"href":"https://github.com/ipfs/go-ipfs/pull/3105#discussion_r80100074"},"pull_request":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105"}}},"pull_request":{"url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105","id":82065063,"html_url":"https://github.com/ipfs/go-ipfs/pull/3105","diff_url":"https://github.com/ipfs/go-ipfs/pull/3105.diff","patch_url":"https://github.com/ipfs/go-ipfs/pull/3105.patch","issue_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3105","number":3105,"state":"closed","locked":false,"title":"bitswap: don't re-provide blocks we've provided very recently","user":{"login":"whyrusleeping","id":1243164,"avatar_url":"https://avatars.githubusercontent.com/u/1243164?v=3","gravatar_id":"","url":"https://api.github.com/users/whyrusleeping","html_url":"https://github.com/whyrusleeping","followers_url":"https://api.github.com/users/whyrusleeping/followers","following_url":"https://api.github.com/users/whyrusleeping/following{/other_user}","gists_url":"https://api.github.com/users/whyrusleeping/gists{/gist_id}","starred_url":"https://api.github.com/users/whyrusleeping/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whyrusleeping/subscriptions","organizations_url":"https://api.github.com/users/whyrusleeping/orgs","repos_url":"https://api.github.com/users/whyrusleeping/repos","events_url":"https://api.github.com/users/whyrusleeping/events{/privacy}","received_events_url":"https://api.github.com/users/whyrusleeping/received_events","type":"User","site_admin":false},"body":"Lots of operations will store the same block multiple times in rapid succession, we have optimizations to avoid putting those to disk multiple times, but nothing to avoid providing them multiple times.\r\n\r\nThis is *a* solution. The other option is to use the same logic as the blockstore (if we have the block already, noop) for providing. The issue with that is that you would no longer be able to re-add a file as a way to re-provide it.\r\n\r\ncc @jbenet @Kubuxu for feedback\r\n\r\nLicense: MIT\r\nSigned-off-by: Jeromy <why@ipfs.io>","created_at":"2016-08-20T01:36:10Z","updated_at":"2016-09-22T18:00:34Z","closed_at":"2016-08-25T19:31:02Z","merged_at":"2016-08-25T19:31:02Z","merge_commit_sha":"5a8b79b2245595ee1e73a3234f42d6f168de372a","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105/commits","review_comments_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105/comments","review_comment_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/3105/comments","statuses_url":"https://api.github.com/repos/ipfs/go-ipfs/statuses/582e5dee3a97f994e7d204ed23960f5752f86553","head":{"label":"ipfs:feat/bitswap/dup-prov-cache","ref":"feat/bitswap/dup-prov-cache","sha":"582e5dee3a97f994e7d204ed23960f5752f86553","user":{"login":"ipfs","id":10536621,"avatar_url":"https://avatars.githubusercontent.com/u/10536621?v=3","gravatar_id":"","url":"https://api.github.com/users/ipfs","html_url":"https://github.com/ipfs","followers_url":"https://api.github.com/users/ipfs/followers","following_url":"https://api.github.com/users/ipfs/following{/other_user}","gists_url":"https://api.github.com/users/ipfs/gists{/gist_id}","starred_url":"https://api.github.com/users/ipfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipfs/subscriptions","organizations_url":"https://api.github.com/users/ipfs/orgs","repos_url":"https://api.github.com/users/ipfs/repos","events_url":"https://api.github.com/users/ipfs/events{/privacy}","received_events_url":"https://api.github.com/users/ipfs/received_events","type":"Organization","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"ipfs/go-ipfs","owner":{"login":"ipfs","id":10536621,"avatar_url":"https://avatars.githubusercontent.com/u/10536621?v=3","gravatar_id":"","url":"https://api.github.com/users/ipfs","html_url":"https://github.com/ipfs","followers_url":"https://api.github.com/users/ipfs/followers","following_url":"https://api.github.com/users/ipfs/following{/other_user}","gists_url":"https://api.github.com/users/ipfs/gists{/gist_id}","starred_url":"https://api.github.com/users/ipfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipfs/subscriptions","organizations_url":"https://api.github.com/users/ipfs/orgs","repos_url":"https://api.github.com/users/ipfs/repos","events_url":"https://api.github.com/users/ipfs/events{/privacy}","received_events_url":"https://api.github.com/users/ipfs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipfs/go-ipfs","description":"IPFS implementation in go","fork":false,"url":"https://api.github.com/repos/ipfs/go-ipfs","forks_url":"https://api.github.com/repos/ipfs/go-ipfs/forks","keys_url":"https://api.github.com/repos/ipfs/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipfs/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipfs/go-ipfs/teams","hooks_url":"https://api.github.com/repos/ipfs/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/ipfs/go-ipfs/events","assignees_url":"https://api.github.com/repos/ipfs/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/ipfs/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/ipfs/go-ipfs/tags","blobs_url":"https://api.github.com/repos/ipfs/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipfs/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipfs/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipfs/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipfs/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/ipfs/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/ipfs/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/ipfs/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/ipfs/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/ipfs/go-ipfs/subscription","commits_url":"https://api.github.com/repos/ipfs/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipfs/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/ipfs/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/ipfs/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipfs/go-ipfs/merges","archive_url":"https://api.github.com/repos/ipfs/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipfs/go-ipfs/downloads","issues_url":"https://api.github.com/repos/ipfs/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/ipfs/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/ipfs/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipfs/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/ipfs/go-ipfs/releases{/id}","deployments_url":"https://api.github.com/repos/ipfs/go-ipfs/deployments","created_at":"2014-06-26T08:14:34Z","updated_at":"2016-09-22T14:16:08Z","pushed_at":"2016-09-21T06:48:58Z","git_url":"git://github.com/ipfs/go-ipfs.git","ssh_url":"git@github.com:ipfs/go-ipfs.git","clone_url":"https://github.com/ipfs/go-ipfs.git","svn_url":"https://github.com/ipfs/go-ipfs","homepage":"https://github.com/ipfs/ipfs","size":36391,"stargazers_count":2262,"watchers_count":2262,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":367,"mirror_url":null,"open_issues_count":490,"forks":367,"open_issues":490,"watchers":2262,"default_branch":"master"}},"base":{"label":"ipfs:master","ref":"master","sha":"a2bba212d0baf6d7e79f56e83f00923785f6f906","user":{"login":"ipfs","id":10536621,"avatar_url":"https://avatars.githubusercontent.com/u/10536621?v=3","gravatar_id":"","url":"https://api.github.com/users/ipfs","html_url":"https://github.com/ipfs","followers_url":"https://api.github.com/users/ipfs/followers","following_url":"https://api.github.com/users/ipfs/following{/other_user}","gists_url":"https://api.github.com/users/ipfs/gists{/gist_id}","starred_url":"https://api.github.com/users/ipfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipfs/subscriptions","organizations_url":"https://api.github.com/users/ipfs/orgs","repos_url":"https://api.github.com/users/ipfs/repos","events_url":"https://api.github.com/users/ipfs/events{/privacy}","received_events_url":"https://api.github.com/users/ipfs/received_events","type":"Organization","site_admin":false},"repo":{"id":21233191,"name":"go-ipfs","full_name":"ipfs/go-ipfs","owner":{"login":"ipfs","id":10536621,"avatar_url":"https://avatars.githubusercontent.com/u/10536621?v=3","gravatar_id":"","url":"https://api.github.com/users/ipfs","html_url":"https://github.com/ipfs","followers_url":"https://api.github.com/users/ipfs/followers","following_url":"https://api.github.com/users/ipfs/following{/other_user}","gists_url":"https://api.github.com/users/ipfs/gists{/gist_id}","starred_url":"https://api.github.com/users/ipfs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ipfs/subscriptions","organizations_url":"https://api.github.com/users/ipfs/orgs","repos_url":"https://api.github.com/users/ipfs/repos","events_url":"https://api.github.com/users/ipfs/events{/privacy}","received_events_url":"https://api.github.com/users/ipfs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ipfs/go-ipfs","description":"IPFS implementation in go","fork":false,"url":"https://api.github.com/repos/ipfs/go-ipfs","forks_url":"https://api.github.com/repos/ipfs/go-ipfs/forks","keys_url":"https://api.github.com/repos/ipfs/go-ipfs/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ipfs/go-ipfs/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ipfs/go-ipfs/teams","hooks_url":"https://api.github.com/repos/ipfs/go-ipfs/hooks","issue_events_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/events{/number}","events_url":"https://api.github.com/repos/ipfs/go-ipfs/events","assignees_url":"https://api.github.com/repos/ipfs/go-ipfs/assignees{/user}","branches_url":"https://api.github.com/repos/ipfs/go-ipfs/branches{/branch}","tags_url":"https://api.github.com/repos/ipfs/go-ipfs/tags","blobs_url":"https://api.github.com/repos/ipfs/go-ipfs/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ipfs/go-ipfs/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ipfs/go-ipfs/git/refs{/sha}","trees_url":"https://api.github.com/repos/ipfs/go-ipfs/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ipfs/go-ipfs/statuses/{sha}","languages_url":"https://api.github.com/repos/ipfs/go-ipfs/languages","stargazers_url":"https://api.github.com/repos/ipfs/go-ipfs/stargazers","contributors_url":"https://api.github.com/repos/ipfs/go-ipfs/contributors","subscribers_url":"https://api.github.com/repos/ipfs/go-ipfs/subscribers","subscription_url":"https://api.github.com/repos/ipfs/go-ipfs/subscription","commits_url":"https://api.github.com/repos/ipfs/go-ipfs/commits{/sha}","git_commits_url":"https://api.github.com/repos/ipfs/go-ipfs/git/commits{/sha}","comments_url":"https://api.github.com/repos/ipfs/go-ipfs/comments{/number}","issue_comment_url":"https://api.github.com/repos/ipfs/go-ipfs/issues/comments{/number}","contents_url":"https://api.github.com/repos/ipfs/go-ipfs/contents/{+path}","compare_url":"https://api.github.com/repos/ipfs/go-ipfs/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ipfs/go-ipfs/merges","archive_url":"https://api.github.com/repos/ipfs/go-ipfs/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ipfs/go-ipfs/downloads","issues_url":"https://api.github.com/repos/ipfs/go-ipfs/issues{/number}","pulls_url":"https://api.github.com/repos/ipfs/go-ipfs/pulls{/number}","milestones_url":"https://api.github.com/repos/ipfs/go-ipfs/milestones{/number}","notifications_url":"https://api.github.com/repos/ipfs/go-ipfs/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ipfs/go-ipfs/labels{/name}","releases_url":"https://api.github.com/repos/ipfs/go-ipfs/releases{/id}","deployments_url":"https://api.github.com/repos/ipfs/go-ipfs/deployments","created_at":"2014-06-26T08:14:34Z","updated_at":"2016-09-22T14:16:08Z","pushed_at":"2016-09-21T06:48:58Z","git_url":"git://github.com/ipfs/go-ipfs.git","ssh_url":"git@github.com:ipfs/go-ipfs.git","clone_url":"https://github.com/ipfs/go-ipfs.git","svn_url":"https://github.com/ipfs/go-ipfs","homepage":"https://github.com/ipfs/ipfs","size":36391,"stargazers_count":2262,"watchers_count":2262,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":367,"mirror_url":null,"open_issues_count":490,"forks":367,"open_issues":490,"watchers":2262,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105"},"html":{"href":"https://github.com/ipfs/go-ipfs/pull/3105"},"issue":{"href":"https://api.github.com/repos/ipfs/go-ipfs/issues/3105"},"comments":{"href":"https://api.github.com/repos/ipfs/go-ipfs/issues/3105/comments"},"review_comments":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105/comments"},"review_comment":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ipfs/go-ipfs/pulls/3105/commits"},"statuses":{"href":"https://api.github.com/repos/ipfs/go-ipfs/statuses/582e5dee3a97f994e7d204ed23960f5752f86553"}}}}
{"actor":{"display_login":"kevina"}}