{"action":"created","issue":{"url":"https://api.github.com/repos/NebulousLabs/Sia/issues/550","labels_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/550/labels{/name}","comments_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/550/comments","events_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/550/events","html_url":"https://github.com/NebulousLabs/Sia/pull/550","id":84808162,"number":550,"title":"DB handling","user":{"login":"lukechampine","id":3344749,"avatar_url":"https://avatars.githubusercontent.com/u/3344749?v=3","gravatar_id":"","url":"https://api.github.com/users/lukechampine","html_url":"https://github.com/lukechampine","followers_url":"https://api.github.com/users/lukechampine/followers","following_url":"https://api.github.com/users/lukechampine/following{/other_user}","gists_url":"https://api.github.com/users/lukechampine/gists{/gist_id}","starred_url":"https://api.github.com/users/lukechampine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lukechampine/subscriptions","organizations_url":"https://api.github.com/users/lukechampine/orgs","repos_url":"https://api.github.com/users/lukechampine/repos","events_url":"https://api.github.com/users/lukechampine/events{/privacy}","received_events_url":"https://api.github.com/users/lukechampine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-03T23:00:50Z","updated_at":"2015-06-04T02:06:06Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/NebulousLabs/Sia/pulls/550","html_url":"https://github.com/NebulousLabs/Sia/pull/550","diff_url":"https://github.com/NebulousLabs/Sia/pull/550.diff","patch_url":"https://github.com/NebulousLabs/Sia/pull/550.patch"},"body":"Using recursion to solve this problem is a little unconventional, I know, but the alternatives were either \"copy and paste code\" or \"use a GOTO\", so..."},"comment":{"url":"https://api.github.com/repos/NebulousLabs/Sia/issues/comments/108681233","html_url":"https://github.com/NebulousLabs/Sia/pull/550#issuecomment-108681233","issue_url":"https://api.github.com/repos/NebulousLabs/Sia/issues/550","id":108681233,"user":{"login":"DavidVorick","id":2316841,"avatar_url":"https://avatars.githubusercontent.com/u/2316841?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidVorick","html_url":"https://github.com/DavidVorick","followers_url":"https://api.github.com/users/DavidVorick/followers","following_url":"https://api.github.com/users/DavidVorick/following{/other_user}","gists_url":"https://api.github.com/users/DavidVorick/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidVorick/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidVorick/subscriptions","organizations_url":"https://api.github.com/users/DavidVorick/orgs","repos_url":"https://api.github.com/users/DavidVorick/repos","events_url":"https://api.github.com/users/DavidVorick/events{/privacy}","received_events_url":"https://api.github.com/users/DavidVorick/received_events","type":"User","site_admin":false},"created_at":"2015-06-04T02:06:06Z","updated_at":"2015-06-04T02:06:06Z","body":"That runs the risk of an infinite loop, I think it's a lot safer to just copy code, or make the first bit a separate function. You don't have to copy much:\r\n\r\n```\r\n        db, err := persist.OpenDB(filepath.Join(saveDir, \"chain.db\"))\r\n \tif err != nil {\r\n \t\treturn err\r\n \t}\r\n \theight, err := db.Height()\r\n \tif err != nil {\r\n \t\treturn err\r\n \t}\r\n\t// add genesis block\r\n\tcs.db = db\r\n\treturn db.AddBlock(cs.blockRoot.block)\r\n}\r\n```"}}