{"action":"created","comment":{"url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/comments/221955674","pull_request_review_id":160726749,"id":221955674,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMTk1NTY3NA==","diff_hunk":"@@ -184,3 +184,40 @@ func (ls *LocalStore) Iterator(from uint64, to uint64, po uint8, f func(Address,\n func (ls *LocalStore) Close() {\n \tls.DbStore.Close()\n }\n+\n+func (ls *LocalStore) Migrate() error {\n+\tschema, err := ls.DbStore.GetSchema()\n+\tif err != nil {\n+\t\tlog.Error(err.Error())\n+\t\treturn err\n+\t}\n+\n+\tlog.Debug(\"found schema\", \"schema\", schema, \"runtime-schema\", CurrentDbSchema)\n+\tif schema != CurrentDbSchema {\n+\t\t// run migrations\n+\n+\t\tif schema == \"\" {\n+\t\t\tlog.Debug(\"running migrations for\", \"schema\", schema, \"runtime-schema\", CurrentDbSchema)\n+\n+\t\t\tcleanupFunc := func(c *chunk) bool {\n+\t\t\t\tvalid := false\n+\t\t\t\tfor _, v := range ls.Validators {\n+\t\t\t\t\tif valid = v.Validate(c.Address(), c.Data()); valid {\n+\t\t\t\t\t\tbreak\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\treturn valid\n+\t\t\t}\n+\n+\t\t\tls.DbStore.Cleanup(cleanupFunc)\n+\n+\t\t\terr := ls.DbStore.PutSchema(DbSchemaPurity)\n+\t\t\tif err != nil {\n+\t\t\t\tlog.Error(err.Error())","path":"swarm/storage/localstore.go","position":33,"original_position":33,"commit_id":"bf193d8b617ad94f549c5e956d8b3ba2d2f32990","original_commit_id":"bf193d8b617ad94f549c5e956d8b3ba2d2f32990","user":{"login":"nonsense","id":50459,"node_id":"MDQ6VXNlcjUwNDU5","avatar_url":"https://avatars0.githubusercontent.com/u/50459?v=4","gravatar_id":"","url":"https://api.github.com/users/nonsense","html_url":"https://github.com/nonsense","followers_url":"https://api.github.com/users/nonsense/followers","following_url":"https://api.github.com/users/nonsense/following{/other_user}","gists_url":"https://api.github.com/users/nonsense/gists{/gist_id}","starred_url":"https://api.github.com/users/nonsense/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nonsense/subscriptions","organizations_url":"https://api.github.com/users/nonsense/orgs","repos_url":"https://api.github.com/users/nonsense/repos","events_url":"https://api.github.com/users/nonsense/events{/privacy}","received_events_url":"https://api.github.com/users/nonsense/received_events","type":"User","site_admin":false},"body":"not sure it will be - better log twice than not even once.","created_at":"2018-10-02T13:44:21Z","updated_at":"2018-10-02T13:44:21Z","html_url":"https://github.com/ethersphere/go-ethereum/pull/933#discussion_r221955674","pull_request_url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/comments/221955674"},"html":{"href":"https://github.com/ethersphere/go-ethereum/pull/933#discussion_r221955674"},"pull_request":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933"}},"in_reply_to_id":221943736},"pull_request":{"url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933","id":215945403,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE1OTQ1NDAz","html_url":"https://github.com/ethersphere/go-ethereum/pull/933","diff_url":"https://github.com/ethersphere/go-ethereum/pull/933.diff","patch_url":"https://github.com/ethersphere/go-ethereum/pull/933.patch","issue_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues/933","number":933,"state":"open","locked":false,"title":"swarm: schemas and migrations","user":{"login":"nonsense","id":50459,"node_id":"MDQ6VXNlcjUwNDU5","avatar_url":"https://avatars0.githubusercontent.com/u/50459?v=4","gravatar_id":"","url":"https://api.github.com/users/nonsense","html_url":"https://github.com/nonsense","followers_url":"https://api.github.com/users/nonsense/followers","following_url":"https://api.github.com/users/nonsense/following{/other_user}","gists_url":"https://api.github.com/users/nonsense/gists{/gist_id}","starred_url":"https://api.github.com/users/nonsense/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nonsense/subscriptions","organizations_url":"https://api.github.com/users/nonsense/orgs","repos_url":"https://api.github.com/users/nonsense/repos","events_url":"https://api.github.com/users/nonsense/events{/privacy}","received_events_url":"https://api.github.com/users/nonsense/received_events","type":"User","site_admin":false},"body":"The idea of this PR is to add `schema` identifier to every LevelDB instance, so that we can migrate or cleanup in case Swarm binary runs on a LevelDB instance that it doesn't detect.\r\n\r\nSchemas have names, and not versions, so that we think carefully what needs to happen once we have 2-3 different schema in production.\r\n\r\nThe idea for this first formal schema is to run the `ldbstore.Cleanup()` task on start-up. We should review it carefully and make sure all `invalid` chunks are removed (MRU and other).\r\n\r\nAddresses https://github.com/ethersphere/go-ethereum/issues/909","created_at":"2018-09-17T11:10:20Z","updated_at":"2018-10-02T13:44:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"845ea305881b112c19ca7bd53674cdb9f883b52b","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":718019424,"node_id":"MDU6TGFiZWw3MTgwMTk0MjQ=","url":"https://api.github.com/repos/ethersphere/go-ethereum/labels/ready%20for%20review","name":"ready for review","color":"44aa25","default":false},{"id":782009315,"node_id":"MDU6TGFiZWw3ODIwMDkzMTU=","url":"https://api.github.com/repos/ethersphere/go-ethereum/labels/submitted%20to%20ethereum/go-ethereum","name":"submitted to ethereum/go-ethereum","color":"67e5bb","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933/commits","review_comments_url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933/comments","review_comment_url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues/933/comments","statuses_url":"https://api.github.com/repos/ethersphere/go-ethereum/statuses/bf193d8b617ad94f549c5e956d8b3ba2d2f32990","head":{"label":"ethersphere:migrations","ref":"migrations","sha":"bf193d8b617ad94f549c5e956d8b3ba2d2f32990","user":{"login":"ethersphere","id":6946989,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NDY5ODk=","avatar_url":"https://avatars2.githubusercontent.com/u/6946989?v=4","gravatar_id":"","url":"https://api.github.com/users/ethersphere","html_url":"https://github.com/ethersphere","followers_url":"https://api.github.com/users/ethersphere/followers","following_url":"https://api.github.com/users/ethersphere/following{/other_user}","gists_url":"https://api.github.com/users/ethersphere/gists{/gist_id}","starred_url":"https://api.github.com/users/ethersphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethersphere/subscriptions","organizations_url":"https://api.github.com/users/ethersphere/orgs","repos_url":"https://api.github.com/users/ethersphere/repos","events_url":"https://api.github.com/users/ethersphere/events{/privacy}","received_events_url":"https://api.github.com/users/ethersphere/received_events","type":"Organization","site_admin":false},"repo":{"id":17790136,"node_id":"MDEwOlJlcG9zaXRvcnkxNzc5MDEzNg==","name":"go-ethereum","full_name":"ethersphere/go-ethereum","private":false,"owner":{"login":"ethersphere","id":6946989,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NDY5ODk=","avatar_url":"https://avatars2.githubusercontent.com/u/6946989?v=4","gravatar_id":"","url":"https://api.github.com/users/ethersphere","html_url":"https://github.com/ethersphere","followers_url":"https://api.github.com/users/ethersphere/followers","following_url":"https://api.github.com/users/ethersphere/following{/other_user}","gists_url":"https://api.github.com/users/ethersphere/gists{/gist_id}","starred_url":"https://api.github.com/users/ethersphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethersphere/subscriptions","organizations_url":"https://api.github.com/users/ethersphere/orgs","repos_url":"https://api.github.com/users/ethersphere/repos","events_url":"https://api.github.com/users/ethersphere/events{/privacy}","received_events_url":"https://api.github.com/users/ethersphere/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ethersphere/go-ethereum","description":"Ethereum Go","fork":true,"url":"https://api.github.com/repos/ethersphere/go-ethereum","forks_url":"https://api.github.com/repos/ethersphere/go-ethereum/forks","keys_url":"https://api.github.com/repos/ethersphere/go-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethersphere/go-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethersphere/go-ethereum/teams","hooks_url":"https://api.github.com/repos/ethersphere/go-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethersphere/go-ethereum/events","assignees_url":"https://api.github.com/repos/ethersphere/go-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethersphere/go-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethersphere/go-ethereum/tags","blobs_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethersphere/go-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethersphere/go-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethersphere/go-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethersphere/go-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethersphere/go-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethersphere/go-ethereum/subscription","commits_url":"https://api.github.com/repos/ethersphere/go-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethersphere/go-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethersphere/go-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethersphere/go-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethersphere/go-ethereum/merges","archive_url":"https://api.github.com/repos/ethersphere/go-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethersphere/go-ethereum/downloads","issues_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethersphere/go-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethersphere/go-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethersphere/go-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethersphere/go-ethereum/releases{/id}","deployments_url":"https://api.github.com/repos/ethersphere/go-ethereum/deployments","created_at":"2014-03-16T02:06:34Z","updated_at":"2018-10-02T09:32:58Z","pushed_at":"2018-10-02T13:00:05Z","git_url":"git://github.com/ethersphere/go-ethereum.git","ssh_url":"git@github.com:ethersphere/go-ethereum.git","clone_url":"https://github.com/ethersphere/go-ethereum.git","svn_url":"https://github.com/ethersphere/go-ethereum","homepage":"","size":108708,"stargazers_count":116,"watchers_count":116,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"archived":false,"open_issues_count":199,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":35,"open_issues":199,"watchers":116,"default_branch":"master"}},"base":{"label":"ethersphere:master","ref":"master","sha":"cc21928e1246f860ede5160986ec3a95956fc8d4","user":{"login":"ethersphere","id":6946989,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NDY5ODk=","avatar_url":"https://avatars2.githubusercontent.com/u/6946989?v=4","gravatar_id":"","url":"https://api.github.com/users/ethersphere","html_url":"https://github.com/ethersphere","followers_url":"https://api.github.com/users/ethersphere/followers","following_url":"https://api.github.com/users/ethersphere/following{/other_user}","gists_url":"https://api.github.com/users/ethersphere/gists{/gist_id}","starred_url":"https://api.github.com/users/ethersphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethersphere/subscriptions","organizations_url":"https://api.github.com/users/ethersphere/orgs","repos_url":"https://api.github.com/users/ethersphere/repos","events_url":"https://api.github.com/users/ethersphere/events{/privacy}","received_events_url":"https://api.github.com/users/ethersphere/received_events","type":"Organization","site_admin":false},"repo":{"id":17790136,"node_id":"MDEwOlJlcG9zaXRvcnkxNzc5MDEzNg==","name":"go-ethereum","full_name":"ethersphere/go-ethereum","private":false,"owner":{"login":"ethersphere","id":6946989,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY5NDY5ODk=","avatar_url":"https://avatars2.githubusercontent.com/u/6946989?v=4","gravatar_id":"","url":"https://api.github.com/users/ethersphere","html_url":"https://github.com/ethersphere","followers_url":"https://api.github.com/users/ethersphere/followers","following_url":"https://api.github.com/users/ethersphere/following{/other_user}","gists_url":"https://api.github.com/users/ethersphere/gists{/gist_id}","starred_url":"https://api.github.com/users/ethersphere/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ethersphere/subscriptions","organizations_url":"https://api.github.com/users/ethersphere/orgs","repos_url":"https://api.github.com/users/ethersphere/repos","events_url":"https://api.github.com/users/ethersphere/events{/privacy}","received_events_url":"https://api.github.com/users/ethersphere/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/ethersphere/go-ethereum","description":"Ethereum Go","fork":true,"url":"https://api.github.com/repos/ethersphere/go-ethereum","forks_url":"https://api.github.com/repos/ethersphere/go-ethereum/forks","keys_url":"https://api.github.com/repos/ethersphere/go-ethereum/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ethersphere/go-ethereum/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ethersphere/go-ethereum/teams","hooks_url":"https://api.github.com/repos/ethersphere/go-ethereum/hooks","issue_events_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues/events{/number}","events_url":"https://api.github.com/repos/ethersphere/go-ethereum/events","assignees_url":"https://api.github.com/repos/ethersphere/go-ethereum/assignees{/user}","branches_url":"https://api.github.com/repos/ethersphere/go-ethereum/branches{/branch}","tags_url":"https://api.github.com/repos/ethersphere/go-ethereum/tags","blobs_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/refs{/sha}","trees_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ethersphere/go-ethereum/statuses/{sha}","languages_url":"https://api.github.com/repos/ethersphere/go-ethereum/languages","stargazers_url":"https://api.github.com/repos/ethersphere/go-ethereum/stargazers","contributors_url":"https://api.github.com/repos/ethersphere/go-ethereum/contributors","subscribers_url":"https://api.github.com/repos/ethersphere/go-ethereum/subscribers","subscription_url":"https://api.github.com/repos/ethersphere/go-ethereum/subscription","commits_url":"https://api.github.com/repos/ethersphere/go-ethereum/commits{/sha}","git_commits_url":"https://api.github.com/repos/ethersphere/go-ethereum/git/commits{/sha}","comments_url":"https://api.github.com/repos/ethersphere/go-ethereum/comments{/number}","issue_comment_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues/comments{/number}","contents_url":"https://api.github.com/repos/ethersphere/go-ethereum/contents/{+path}","compare_url":"https://api.github.com/repos/ethersphere/go-ethereum/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ethersphere/go-ethereum/merges","archive_url":"https://api.github.com/repos/ethersphere/go-ethereum/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ethersphere/go-ethereum/downloads","issues_url":"https://api.github.com/repos/ethersphere/go-ethereum/issues{/number}","pulls_url":"https://api.github.com/repos/ethersphere/go-ethereum/pulls{/number}","milestones_url":"https://api.github.com/repos/ethersphere/go-ethereum/milestones{/number}","notifications_url":"https://api.github.com/repos/ethersphere/go-ethereum/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ethersphere/go-ethereum/labels{/name}","releases_url":"https://api.github.com/repos/ethersphere/go-ethereum/releases{/id}","deployments_url":"https://api.github.com/repos/ethersphere/go-ethereum/deployments","created_at":"2014-03-16T02:06:34Z","updated_at":"2018-10-02T09:32:58Z","pushed_at":"2018-10-02T13:00:05Z","git_url":"git://github.com/ethersphere/go-ethereum.git","ssh_url":"git@github.com:ethersphere/go-ethereum.git","clone_url":"https://github.com/ethersphere/go-ethereum.git","svn_url":"https://github.com/ethersphere/go-ethereum","homepage":"","size":108708,"stargazers_count":116,"watchers_count":116,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":35,"mirror_url":null,"archived":false,"open_issues_count":199,"license":{"key":"lgpl-3.0","name":"GNU Lesser General Public License v3.0","spdx_id":"LGPL-3.0","url":"https://api.github.com/licenses/lgpl-3.0","node_id":"MDc6TGljZW5zZTEy"},"forks":35,"open_issues":199,"watchers":116,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933"},"html":{"href":"https://github.com/ethersphere/go-ethereum/pull/933"},"issue":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/issues/933"},"comments":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/issues/933/comments"},"review_comments":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933/comments"},"review_comment":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/pulls/933/commits"},"statuses":{"href":"https://api.github.com/repos/ethersphere/go-ethereum/statuses/bf193d8b617ad94f549c5e956d8b3ba2d2f32990"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"nonsense"}}