{"action":"created","comment":{"url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/comments/37203471","id":37203471,"diff_hunk":"@@ -663,6 +663,82 @@ func (self *ChainManager) InsertChain(chain types.Blocks) (int, error) {\n \treturn 0, nil\n }\n \n+// reorgs takes two blocks, an old chain and a new chain and will reconstruct the blocks and inserts them\n+// to be part of the new canonical chain and accumulates potential missing transactions and post an\n+// event about them\n+func (self *ChainManager) reorg(oldBlock, newBlock *types.Block) error {\n+\tself.mu.Lock()\n+\tdefer self.mu.Unlock()\n+\n+\tvar (\n+\t\tnewChain    types.Blocks\n+\t\tcommonBlock *types.Block\n+\t\toldStart    = oldBlock\n+\t\tnewStart    = newBlock\n+\t\tdeletedTxs  types.Transactions\n+\t\taddedTxs    types.Transactions\n+\t)\n+\n+\t// first reduce whoever is higher bound\n+\tif oldBlock.NumberU64() > newBlock.NumberU64() {\n+\t\t// reduce old chain\n+\t\tfor oldBlock = oldBlock; oldBlock != nil && oldBlock.NumberU64() != newBlock.NumberU64(); oldBlock = self.GetBlock(oldBlock.ParentHash()) {\n+\t\t\tdeletedTxs = append(deletedTxs, oldBlock.Transactions()...)\n+\t\t}\n+\t} else {\n+\t\t// reduce new chain and append new chain blocks for inserting later on\n+\t\tfor newBlock = newBlock; newBlock != nil && newBlock.NumberU64() != oldBlock.NumberU64(); newBlock = self.GetBlock(newBlock.ParentHash()) {\n+\t\t\tnewChain = append(newChain, newBlock)\n+\t\t}\n+\t}\n+\tif oldBlock == nil {\n+\t\treturn fmt.Errorf(\"Invalid old chain\")\n+\t}\n+\tif newBlock == nil {\n+\t\treturn fmt.Errorf(\"Invalid new chain\")\n+\t}\n+\n+\tnumSplit := newBlock.Number()\n+\tfor {\n+\t\tif oldBlock.Hash() == newBlock.Hash() {\n+\t\t\tcommonBlock = oldBlock\n+\t\t\tbreak\n+\t\t}\n+\t\tnewChain = append(newChain, newBlock)\n+\n+\t\toldBlock, newBlock = self.GetBlock(oldBlock.ParentHash()), self.GetBlock(newBlock.ParentHash())","path":"core/chain_manager.go","position":47,"original_position":47,"commit_id":"da5c0ede0fa907a1c468d3540069241ef1f9e737","original_commit_id":"da5c0ede0fa907a1c468d3540069241ef1f9e737","user":{"login":"Gustav-Simonsson","id":293096,"avatar_url":"https://avatars.githubusercontent.com/u/293096?v=3","gravatar_id":"","url":"https://api.github.com/users/Gustav-Simonsson","html_url":"https://github.com/Gustav-Simonsson","followers_url":"https://api.github.com/users/Gustav-Simonsson/followers","following_url":"https://api.github.com/users/Gustav-Simonsson/following{/other_user}","gists_url":"https://api.github.com/users/Gustav-Simonsson/gists{/gist_id}","starred_url":"https://api.github.com/users/Gustav-Simonsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Gustav-Simonsson/subscriptions","organizations_url":"https://api.github.com/users/Gustav-Simonsson/orgs","repos_url":"https://api.github.com/users/Gustav-Simonsson/repos","events_url":"https://api.github.com/users/Gustav-Simonsson/events{/privacy}","received_events_url":"https://api.github.com/users/Gustav-Simonsson/received_events","type":"User","site_admin":false},"body":"If old chain was reduced above, it'll set oldBlock to it's parent in the for loop post statement. Then here it's set to it's grandparent. Looks like it'll skip adding the parent's txs to deletedTxs in this case.","created_at":"2015-08-17T16:00:37Z","updated_at":"2015-08-17T16:00:37Z","html_url":"https://github.com/ethereum/go-ethereum/pull/1669#discussion_r37203471","pull_request_url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669","_links":{"self":{"href":"https://api.github.com/repos/ethereum/go-ethereum/pulls/comments/37203471"},"html":{"href":"https://github.com/ethereum/go-ethereum/pull/1669#discussion_r37203471"},"pull_request":{"href":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669"}}},"pull_request":{"url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669","id":42536377,"html_url":"https://github.com/ethereum/go-ethereum/pull/1669","diff_url":"https://github.com/ethereum/go-ethereum/pull/1669.diff","patch_url":"https://github.com/ethereum/go-ethereum/pull/1669.patch","issue_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1669","number":1669,"state":"open","locked":false,"title":"core, xeth: implemented auto resend strategy for owned transactions","user":{"login":"obscuren","id":6264126,"avatar_url":"https://avatars.githubusercontent.com/u/6264126?v=3","gravatar_id":"","url":"https://api.github.com/users/obscuren","html_url":"https://github.com/obscuren","followers_url":"https://api.github.com/users/obscuren/followers","following_url":"https://api.github.com/users/obscuren/following{/other_user}","gists_url":"https://api.github.com/users/obscuren/gists{/gist_id}","starred_url":"https://api.github.com/users/obscuren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obscuren/subscriptions","organizations_url":"https://api.github.com/users/obscuren/orgs","repos_url":"https://api.github.com/users/obscuren/repos","events_url":"https://api.github.com/users/obscuren/events{/privacy}","received_events_url":"https://api.github.com/users/obscuren/received_events","type":"User","site_admin":false},"body":"Added an new transaction type used by the transaction pool `poolTx`.\r\nThis struct hold information about the transaction state:\r\n\r\n* amount of post tries\r\n* added timestamp\r\n* last post timestamp\r\n\r\nWhenever a transaction is being submitted by the user the transaction is\r\nflagged as owned. When an owned transaction sits in the pool for too\r\nlong (39 seconds) it will be posted again.\r\n\r\nA future PR could check the amount of post tries and will post back a\r\nfailure event. An failure event could potentially be posted back to a\r\nfrontend connected to the `geth` instance and deletes from the pool. A\r\nfrontend could ask the user for a higher gas price or some other action.\r\n\r\n***\r\n\r\nThis PR also adds back any potential missing transactions during chain reorganisations and adds functionality to `types.Transactions` to split of `Difference`s between two slices of `Transaction`s. \r\n\r\nCloses #1668","created_at":"2015-08-16T13:22:09Z","updated_at":"2015-08-17T16:00:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e83506193a04334d871d0147c95c31c37287e444","assignee":null,"milestone":{"url":"https://api.github.com/repos/ethereum/go-ethereum/milestones/16","html_url":"https://github.com/ethereum/go-ethereum/milestones/1.0.3","labels_url":"https://api.github.com/repos/ethereum/go-ethereum/milestones/16/labels","id":1256572,"number":16,"title":"1.0.3","description":"","creator":{"login":"obscuren","id":6264126,"avatar_url":"https://avatars.githubusercontent.com/u/6264126?v=3","gravatar_id":"","url":"https://api.github.com/users/obscuren","html_url":"https://github.com/obscuren","followers_url":"https://api.github.com/users/obscuren/followers","following_url":"https://api.github.com/users/obscuren/following{/other_user}","gists_url":"https://api.github.com/users/obscuren/gists{/gist_id}","starred_url":"https://api.github.com/users/obscuren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obscuren/subscriptions","organizations_url":"https://api.github.com/users/obscuren/orgs","repos_url":"https://api.github.com/users/obscuren/repos","events_url":"https://api.github.com/users/obscuren/events{/privacy}","received_events_url":"https://api.github.com/users/obscuren/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":0,"state":"open","created_at":"2015-08-15T21:52:41Z","updated_at":"2015-08-17T09:25:16Z","due_on":"2015-09-13T22:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669/commits","review_comments_url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669/comments","review_comment_url":"https://api.github.com/repos/ethereum/go-ethereum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/1669/comments","statuses_url":"https://api.github.com/repos/ethereum/go-ethereum/statuses/da5c0ede0fa907a1c468d3540069241ef1f9e737","head":{"label":"obscuren:tx-pool-auto-resend","ref":"tx-pool-auto-resend","sha":"da5c0ede0fa907a1c468d3540069241ef1f9e737","user":{"login":"obscuren","id":6264126,"avatar_url":"https://avatars.githubusercontent.com/u/6264126?v=3","gravatar_id":"","url":"https://api.github.com/users/obscuren","html_url":"https://github.com/obscuren","followers_url":"https://api.github.com/users/obscuren/followers","following_url":"https://api.github.com/users/obscuren/following{/other_user}","gists_url":"https://api.github.com/users/obscuren/gists{/gist_id}","starred_url":"https://api.github.com/users/obscuren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obscuren/subscriptions","organizations_url":"https://api.github.com/users/obscuren/orgs","repos_url":"https://api.github.com/users/obscuren/repos","events_url":"https://api.github.com/users/obscuren/events{/privacy}","received_events_url":"https://api.github.com/users/obscuren/received_events","type":"User","site_admin":false},"repo":{"id":34282926,"name":"go-ethereum","full_name":"obscuren/go-ethereum","owner":{"login":"obscuren","id":6264126,"avatar_url":"https://avatars.githubusercontent.com/u/6264126?v=3","gravatar_id":"","url":"https://api.github.com/users/obscuren","html_url":"https://github.com/obscuren","followers_url":"https://api.github.com/users/obscuren/followers","following_url":"https://api.github.com/users/obscuren/following{/other_user}","gists_url":"https://api.github.com/users/obscuren/gists{/gist_id}","starred_url":"https://api.github.com/users/obscuren/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/obscuren/subscriptions","organizations_url":"https://api.github.com/users/obscuren/orgs","repos_url":"https://api.github.com/users/obscuren/repos","events_url":"https://api.github.com/users/obscuren/events{/privacy}","received_events_url":"https://api.github.com/users/obscuren/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/obscuren/go-ethereum","description":"Jeffrey Wilcke's Go implementation of the Ethereum y/w paper","fork":true,"url":"https://api.github.com/repos/obscuren/go-ethereum","forks_url":"https://api.github.com/repos/obscuren/go-ethereum/forks","keys_url":"https://api.github.com/repos/obscuren/go-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/obscuren/go-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/obscuren/go-ethereum/teams","hooks_url":"https://api.github.com/repos/obscuren/go-ethereum/hooks","issue_events_url":"https://api.github.com/repos/obscuren/go-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/obscuren/go-ethereum/events","assignees_url":"https://api.github.com/repos/obscuren/go-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/obscuren/go-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/obscuren/go-ethereum/tags","blobs_url":"https://api.github.com/repos/obscuren/go-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/obscuren/go-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/obscuren/go-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/obscuren/go-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/obscuren/go-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/obscuren/go-ethereum/languages","stargazers_url":"https://api.github.com/repos/obscuren/go-ethereum/stargazers","contributors_url":"https://api.github.com/repos/obscuren/go-ethereum/contributors","subscribers_url":"https://api.github.com/repos/obscuren/go-ethereum/subscribers","subscription_url":"https://api.github.com/repos/obscuren/go-ethereum/subscription","commits_url":"https://api.github.com/repos/obscuren/go-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/obscuren/go-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/obscuren/go-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/obscuren/go-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/obscuren/go-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/obscuren/go-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/obscuren/go-ethereum/merges","archive_url":"https://api.github.com/repos/obscuren/go-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/obscuren/go-ethereum/downloads","issues_url":"https://api.github.com/repos/obscuren/go-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/obscuren/go-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/obscuren/go-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/obscuren/go-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/obscuren/go-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/obscuren/go-ethereum/releases{/id}","created_at":"2015-04-20T19:55:44Z","updated_at":"2015-05-19T15:03:00Z","pushed_at":"2015-08-17T13:09:39Z","git_url":"git://github.com/obscuren/go-ethereum.git","ssh_url":"git@github.com:obscuren/go-ethereum.git","clone_url":"https://github.com/obscuren/go-ethereum.git","svn_url":"https://github.com/obscuren/go-ethereum","homepage":"","size":48813,"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":"develop"}},"base":{"label":"ethereum:develop","ref":"develop","sha":"59b28cfa311f7852ef9bd93ec64961b6c3a8d760","user":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"repo":{"id":15452919,"name":"go-ethereum","full_name":"ethereum/go-ethereum","owner":{"login":"ethereum","id":6250754,"avatar_url":"https://avatars.githubusercontent.com/u/6250754?v=3","gravatar_id":"","url":"https://api.github.com/users/ethereum","html_url":"https://github.com/ethereum","followers_url":"https://api.github.com/users/ethereum/followers","following_url":"https://api.github.com/users/ethereum/following{/other_user}","gists_url":"https://api.github.com/users/ethereum/gists{/gist_id}","starred_url":"https://api.github.com/users/ethereum/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethereum/subscriptions","organizations_url":"https://api.github.com/users/ethereum/orgs","repos_url":"https://api.github.com/users/ethereum/repos","events_url":"https://api.github.com/users/ethereum/events{/privacy}","received_events_url":"https://api.github.com/users/ethereum/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ethereum/go-ethereum","description":"Jeffrey Wilcke's Go implementation of the Ethereum y/w paper","fork":false,"url":"https://api.github.com/repos/ethereum/go-ethereum","forks_url":"https://api.github.com/repos/ethereum/go-ethereum/forks","keys_url":"https://api.github.com/repos/ethereum/go-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethereum/go-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethereum/go-ethereum/teams","hooks_url":"https://api.github.com/repos/ethereum/go-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethereum/go-ethereum/events","assignees_url":"https://api.github.com/repos/ethereum/go-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethereum/go-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethereum/go-ethereum/tags","blobs_url":"https://api.github.com/repos/ethereum/go-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethereum/go-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethereum/go-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethereum/go-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethereum/go-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethereum/go-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethereum/go-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethereum/go-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethereum/go-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethereum/go-ethereum/subscription","commits_url":"https://api.github.com/repos/ethereum/go-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethereum/go-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethereum/go-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethereum/go-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethereum/go-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethereum/go-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethereum/go-ethereum/merges","archive_url":"https://api.github.com/repos/ethereum/go-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethereum/go-ethereum/downloads","issues_url":"https://api.github.com/repos/ethereum/go-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethereum/go-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethereum/go-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethereum/go-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethereum/go-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethereum/go-ethereum/releases{/id}","created_at":"2013-12-26T13:05:46Z","updated_at":"2015-08-16T11:49:15Z","pushed_at":"2015-08-17T13:37:58Z","git_url":"git://github.com/ethereum/go-ethereum.git","ssh_url":"git@github.com:ethereum/go-ethereum.git","clone_url":"https://github.com/ethereum/go-ethereum.git","svn_url":"https://github.com/ethereum/go-ethereum","homepage":"","size":75621,"stargazers_count":589,"watchers_count":589,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":189,"mirror_url":null,"open_issues_count":157,"forks":189,"open_issues":157,"watchers":589,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669"},"html":{"href":"https://github.com/ethereum/go-ethereum/pull/1669"},"issue":{"href":"https://api.github.com/repos/ethereum/go-ethereum/issues/1669"},"comments":{"href":"https://api.github.com/repos/ethereum/go-ethereum/issues/1669/comments"},"review_comments":{"href":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669/comments"},"review_comment":{"href":"https://api.github.com/repos/ethereum/go-ethereum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethereum/go-ethereum/pulls/1669/commits"},"statuses":{"href":"https://api.github.com/repos/ethereum/go-ethereum/statuses/da5c0ede0fa907a1c468d3540069241ef1f9e737"}}}}