{"action":"created","comment":{"url":"https://api.github.com/repos/tendermint/tendermint/pulls/comments/140627263","pull_request_review_id":64733224,"id":140627263,"diff_hunk":"@@ -127,12 +127,57 @@ func (s *State) Copy() *State {\n \t}\n }\n \n+var (\n+\terrNilGenesisDoc = errors.New(\"no genesisDoc was found\")\n+\n+\tgenesisDBKey = []byte(\"genesis-doc\")\n+)\n+\n+// GenesisDoc is the accessor to retrieve the genesisDoc associated\n+// with a state. If the state has no set GenesisDoc, it fetches from\n+// its database the JSON marshaled bytes keyed by \"genesis-doc\", and\n+// parses the GenesisDoc from that memoizing it for later use.\n+// If you'd like to change the value of the GenesisDoc, invoke SetGenesisDoc.\n+func (s *State) GenesisDoc() (*types.GenesisDoc, error) {\n+\ts.mtx.Lock()\n+\tdefer s.mtx.Unlock()\n+\n+\tif s.cachedGenesisDoc == nil {\n+\t\tretrGenesisDocBytes := s.db.Get(genesisDBKey)\n+\t\tif len(retrGenesisDocBytes) == 0 {\n+\t\t\treturn nil, errNilGenesisDoc\n+\t\t}\n+\t\tgenDoc, err := types.GenesisDocFromJSON(retrGenesisDocBytes)\n+\t\tif err != nil {\n+\t\t\treturn nil, err\n+\t\t}\n+\t\ts.cachedGenesisDoc = genDoc\n+\t}\n+\treturn s.cachedGenesisDoc, nil\n+}\n+\n+func (s *State) ChainID() (string, error) {\n+\tgenDoc, err := s.GenesisDoc()","path":"state/state.go","position":74,"original_position":74,"commit_id":"53f0fccdef16eb62f5c50c66d2db4be451f22251","original_commit_id":"53f0fccdef16eb62f5c50c66d2db4be451f22251","user":{"login":"odeke-em","id":4898263,"avatar_url":"https://avatars3.githubusercontent.com/u/4898263?v=4","gravatar_id":"","url":"https://api.github.com/users/odeke-em","html_url":"https://github.com/odeke-em","followers_url":"https://api.github.com/users/odeke-em/followers","following_url":"https://api.github.com/users/odeke-em/following{/other_user}","gists_url":"https://api.github.com/users/odeke-em/gists{/gist_id}","starred_url":"https://api.github.com/users/odeke-em/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeke-em/subscriptions","organizations_url":"https://api.github.com/users/odeke-em/orgs","repos_url":"https://api.github.com/users/odeke-em/repos","events_url":"https://api.github.com/users/odeke-em/events{/privacy}","received_events_url":"https://api.github.com/users/odeke-em/received_events","type":"User","site_admin":false},"body":"We need to load the genesisDoc from the DB if unset hence the need for it.","created_at":"2017-09-23T06:11:32Z","updated_at":"2017-09-23T06:11:32Z","html_url":"https://github.com/tendermint/tendermint/pull/676#discussion_r140627263","pull_request_url":"https://api.github.com/repos/tendermint/tendermint/pulls/676","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/tendermint/tendermint/pulls/comments/140627263"},"html":{"href":"https://github.com/tendermint/tendermint/pull/676#discussion_r140627263"},"pull_request":{"href":"https://api.github.com/repos/tendermint/tendermint/pulls/676"}},"in_reply_to_id":140625268},"pull_request":{"url":"https://api.github.com/repos/tendermint/tendermint/pulls/676","id":142692628,"html_url":"https://github.com/tendermint/tendermint/pull/676","diff_url":"https://github.com/tendermint/tendermint/pull/676.diff","patch_url":"https://github.com/tendermint/tendermint/pull/676.patch","issue_url":"https://api.github.com/repos/tendermint/tendermint/issues/676","number":676,"state":"open","locked":false,"title":"all, state: unexpose GenesisDoc, ChainID fields make them accessor methods","user":{"login":"odeke-em","id":4898263,"avatar_url":"https://avatars3.githubusercontent.com/u/4898263?v=4","gravatar_id":"","url":"https://api.github.com/users/odeke-em","html_url":"https://github.com/odeke-em","followers_url":"https://api.github.com/users/odeke-em/followers","following_url":"https://api.github.com/users/odeke-em/following{/other_user}","gists_url":"https://api.github.com/users/odeke-em/gists{/gist_id}","starred_url":"https://api.github.com/users/odeke-em/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeke-em/subscriptions","organizations_url":"https://api.github.com/users/odeke-em/orgs","repos_url":"https://api.github.com/users/odeke-em/repos","events_url":"https://api.github.com/users/odeke-em/events{/privacy}","received_events_url":"https://api.github.com/users/odeke-em/received_events","type":"User","site_admin":false},"body":"Fixes #671\r\n\r\nUnexpose GenesisDoc and ChainID fields to avoid them being\r\nserialized to the DB on every block write/state.Save()\r\n\r\nA GenesisDoc can now be alternatively written to the state's\r\ndatabase, by serializing its JSON as a value of key \"genesis-doc\".\r\n\r\nThere are now accessors and a setter for these attributes:\r\n- state.GenesisDoc() (*types.GenesisDoc, error)\r\n- state.ChainID() (string, error)\r\n- state.SetGenesisDoc(*types.GenesisDoc)\r\n\r\nThis is a breaking change since it changes how the state's\r\nserialization and requires that if loading the GenesisDoc entirely\r\nfrom the database, you'll need to set its value in the database\r\nas the GenesisDoc's JSON marshaled bytes.","created_at":"2017-09-23T00:40:06Z","updated_at":"2017-09-23T06:11:32Z","closed_at":null,"merged_at":null,"merge_commit_sha":"684b8af0ef2603089d7ad633e26800979c8ae819","assignee":null,"assignees":[],"requested_reviewers":[{"login":"adrianbrink","id":11320251,"avatar_url":"https://avatars0.githubusercontent.com/u/11320251?v=4","gravatar_id":"","url":"https://api.github.com/users/adrianbrink","html_url":"https://github.com/adrianbrink","followers_url":"https://api.github.com/users/adrianbrink/followers","following_url":"https://api.github.com/users/adrianbrink/following{/other_user}","gists_url":"https://api.github.com/users/adrianbrink/gists{/gist_id}","starred_url":"https://api.github.com/users/adrianbrink/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adrianbrink/subscriptions","organizations_url":"https://api.github.com/users/adrianbrink/orgs","repos_url":"https://api.github.com/users/adrianbrink/repos","events_url":"https://api.github.com/users/adrianbrink/events{/privacy}","received_events_url":"https://api.github.com/users/adrianbrink/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/tendermint/tendermint/pulls/676/commits","review_comments_url":"https://api.github.com/repos/tendermint/tendermint/pulls/676/comments","review_comment_url":"https://api.github.com/repos/tendermint/tendermint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/tendermint/tendermint/issues/676/comments","statuses_url":"https://api.github.com/repos/tendermint/tendermint/statuses/53f0fccdef16eb62f5c50c66d2db4be451f22251","head":{"label":"tendermint:state-unexpose-genesisDoc-chainID","ref":"state-unexpose-genesisDoc-chainID","sha":"53f0fccdef16eb62f5c50c66d2db4be451f22251","user":{"login":"tendermint","id":7572940,"avatar_url":"https://avatars1.githubusercontent.com/u/7572940?v=4","gravatar_id":"","url":"https://api.github.com/users/tendermint","html_url":"https://github.com/tendermint","followers_url":"https://api.github.com/users/tendermint/followers","following_url":"https://api.github.com/users/tendermint/following{/other_user}","gists_url":"https://api.github.com/users/tendermint/gists{/gist_id}","starred_url":"https://api.github.com/users/tendermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tendermint/subscriptions","organizations_url":"https://api.github.com/users/tendermint/orgs","repos_url":"https://api.github.com/users/tendermint/repos","events_url":"https://api.github.com/users/tendermint/events{/privacy}","received_events_url":"https://api.github.com/users/tendermint/received_events","type":"Organization","site_admin":false},"repo":{"id":19799491,"name":"tendermint","full_name":"tendermint/tendermint","owner":{"login":"tendermint","id":7572940,"avatar_url":"https://avatars1.githubusercontent.com/u/7572940?v=4","gravatar_id":"","url":"https://api.github.com/users/tendermint","html_url":"https://github.com/tendermint","followers_url":"https://api.github.com/users/tendermint/followers","following_url":"https://api.github.com/users/tendermint/following{/other_user}","gists_url":"https://api.github.com/users/tendermint/gists{/gist_id}","starred_url":"https://api.github.com/users/tendermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tendermint/subscriptions","organizations_url":"https://api.github.com/users/tendermint/orgs","repos_url":"https://api.github.com/users/tendermint/repos","events_url":"https://api.github.com/users/tendermint/events{/privacy}","received_events_url":"https://api.github.com/users/tendermint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tendermint/tendermint","description":"Tendermint Core (BFT Consensus) in Go","fork":false,"url":"https://api.github.com/repos/tendermint/tendermint","forks_url":"https://api.github.com/repos/tendermint/tendermint/forks","keys_url":"https://api.github.com/repos/tendermint/tendermint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tendermint/tendermint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tendermint/tendermint/teams","hooks_url":"https://api.github.com/repos/tendermint/tendermint/hooks","issue_events_url":"https://api.github.com/repos/tendermint/tendermint/issues/events{/number}","events_url":"https://api.github.com/repos/tendermint/tendermint/events","assignees_url":"https://api.github.com/repos/tendermint/tendermint/assignees{/user}","branches_url":"https://api.github.com/repos/tendermint/tendermint/branches{/branch}","tags_url":"https://api.github.com/repos/tendermint/tendermint/tags","blobs_url":"https://api.github.com/repos/tendermint/tendermint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tendermint/tendermint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tendermint/tendermint/git/refs{/sha}","trees_url":"https://api.github.com/repos/tendermint/tendermint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tendermint/tendermint/statuses/{sha}","languages_url":"https://api.github.com/repos/tendermint/tendermint/languages","stargazers_url":"https://api.github.com/repos/tendermint/tendermint/stargazers","contributors_url":"https://api.github.com/repos/tendermint/tendermint/contributors","subscribers_url":"https://api.github.com/repos/tendermint/tendermint/subscribers","subscription_url":"https://api.github.com/repos/tendermint/tendermint/subscription","commits_url":"https://api.github.com/repos/tendermint/tendermint/commits{/sha}","git_commits_url":"https://api.github.com/repos/tendermint/tendermint/git/commits{/sha}","comments_url":"https://api.github.com/repos/tendermint/tendermint/comments{/number}","issue_comment_url":"https://api.github.com/repos/tendermint/tendermint/issues/comments{/number}","contents_url":"https://api.github.com/repos/tendermint/tendermint/contents/{+path}","compare_url":"https://api.github.com/repos/tendermint/tendermint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tendermint/tendermint/merges","archive_url":"https://api.github.com/repos/tendermint/tendermint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tendermint/tendermint/downloads","issues_url":"https://api.github.com/repos/tendermint/tendermint/issues{/number}","pulls_url":"https://api.github.com/repos/tendermint/tendermint/pulls{/number}","milestones_url":"https://api.github.com/repos/tendermint/tendermint/milestones{/number}","notifications_url":"https://api.github.com/repos/tendermint/tendermint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tendermint/tendermint/labels{/name}","releases_url":"https://api.github.com/repos/tendermint/tendermint/releases{/id}","deployments_url":"https://api.github.com/repos/tendermint/tendermint/deployments","created_at":"2014-05-14T23:21:35Z","updated_at":"2017-09-22T19:44:59Z","pushed_at":"2017-09-23T03:09:51Z","git_url":"git://github.com/tendermint/tendermint.git","ssh_url":"git@github.com:tendermint/tendermint.git","clone_url":"https://github.com/tendermint/tendermint.git","svn_url":"https://github.com/tendermint/tendermint","homepage":"https://tendermint.com/","size":10043,"stargazers_count":739,"watchers_count":739,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":138,"mirror_url":null,"open_issues_count":91,"forks":138,"open_issues":91,"watchers":739,"default_branch":"master"}},"base":{"label":"tendermint:develop","ref":"develop","sha":"7682ad9a60162dd17fd6f61aeed7049a8635ac78","user":{"login":"tendermint","id":7572940,"avatar_url":"https://avatars1.githubusercontent.com/u/7572940?v=4","gravatar_id":"","url":"https://api.github.com/users/tendermint","html_url":"https://github.com/tendermint","followers_url":"https://api.github.com/users/tendermint/followers","following_url":"https://api.github.com/users/tendermint/following{/other_user}","gists_url":"https://api.github.com/users/tendermint/gists{/gist_id}","starred_url":"https://api.github.com/users/tendermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tendermint/subscriptions","organizations_url":"https://api.github.com/users/tendermint/orgs","repos_url":"https://api.github.com/users/tendermint/repos","events_url":"https://api.github.com/users/tendermint/events{/privacy}","received_events_url":"https://api.github.com/users/tendermint/received_events","type":"Organization","site_admin":false},"repo":{"id":19799491,"name":"tendermint","full_name":"tendermint/tendermint","owner":{"login":"tendermint","id":7572940,"avatar_url":"https://avatars1.githubusercontent.com/u/7572940?v=4","gravatar_id":"","url":"https://api.github.com/users/tendermint","html_url":"https://github.com/tendermint","followers_url":"https://api.github.com/users/tendermint/followers","following_url":"https://api.github.com/users/tendermint/following{/other_user}","gists_url":"https://api.github.com/users/tendermint/gists{/gist_id}","starred_url":"https://api.github.com/users/tendermint/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tendermint/subscriptions","organizations_url":"https://api.github.com/users/tendermint/orgs","repos_url":"https://api.github.com/users/tendermint/repos","events_url":"https://api.github.com/users/tendermint/events{/privacy}","received_events_url":"https://api.github.com/users/tendermint/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/tendermint/tendermint","description":"Tendermint Core (BFT Consensus) in Go","fork":false,"url":"https://api.github.com/repos/tendermint/tendermint","forks_url":"https://api.github.com/repos/tendermint/tendermint/forks","keys_url":"https://api.github.com/repos/tendermint/tendermint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tendermint/tendermint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tendermint/tendermint/teams","hooks_url":"https://api.github.com/repos/tendermint/tendermint/hooks","issue_events_url":"https://api.github.com/repos/tendermint/tendermint/issues/events{/number}","events_url":"https://api.github.com/repos/tendermint/tendermint/events","assignees_url":"https://api.github.com/repos/tendermint/tendermint/assignees{/user}","branches_url":"https://api.github.com/repos/tendermint/tendermint/branches{/branch}","tags_url":"https://api.github.com/repos/tendermint/tendermint/tags","blobs_url":"https://api.github.com/repos/tendermint/tendermint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tendermint/tendermint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tendermint/tendermint/git/refs{/sha}","trees_url":"https://api.github.com/repos/tendermint/tendermint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tendermint/tendermint/statuses/{sha}","languages_url":"https://api.github.com/repos/tendermint/tendermint/languages","stargazers_url":"https://api.github.com/repos/tendermint/tendermint/stargazers","contributors_url":"https://api.github.com/repos/tendermint/tendermint/contributors","subscribers_url":"https://api.github.com/repos/tendermint/tendermint/subscribers","subscription_url":"https://api.github.com/repos/tendermint/tendermint/subscription","commits_url":"https://api.github.com/repos/tendermint/tendermint/commits{/sha}","git_commits_url":"https://api.github.com/repos/tendermint/tendermint/git/commits{/sha}","comments_url":"https://api.github.com/repos/tendermint/tendermint/comments{/number}","issue_comment_url":"https://api.github.com/repos/tendermint/tendermint/issues/comments{/number}","contents_url":"https://api.github.com/repos/tendermint/tendermint/contents/{+path}","compare_url":"https://api.github.com/repos/tendermint/tendermint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tendermint/tendermint/merges","archive_url":"https://api.github.com/repos/tendermint/tendermint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tendermint/tendermint/downloads","issues_url":"https://api.github.com/repos/tendermint/tendermint/issues{/number}","pulls_url":"https://api.github.com/repos/tendermint/tendermint/pulls{/number}","milestones_url":"https://api.github.com/repos/tendermint/tendermint/milestones{/number}","notifications_url":"https://api.github.com/repos/tendermint/tendermint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tendermint/tendermint/labels{/name}","releases_url":"https://api.github.com/repos/tendermint/tendermint/releases{/id}","deployments_url":"https://api.github.com/repos/tendermint/tendermint/deployments","created_at":"2014-05-14T23:21:35Z","updated_at":"2017-09-22T19:44:59Z","pushed_at":"2017-09-23T03:09:51Z","git_url":"git://github.com/tendermint/tendermint.git","ssh_url":"git@github.com:tendermint/tendermint.git","clone_url":"https://github.com/tendermint/tendermint.git","svn_url":"https://github.com/tendermint/tendermint","homepage":"https://tendermint.com/","size":10043,"stargazers_count":739,"watchers_count":739,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":138,"mirror_url":null,"open_issues_count":91,"forks":138,"open_issues":91,"watchers":739,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/tendermint/tendermint/pulls/676"},"html":{"href":"https://github.com/tendermint/tendermint/pull/676"},"issue":{"href":"https://api.github.com/repos/tendermint/tendermint/issues/676"},"comments":{"href":"https://api.github.com/repos/tendermint/tendermint/issues/676/comments"},"review_comments":{"href":"https://api.github.com/repos/tendermint/tendermint/pulls/676/comments"},"review_comment":{"href":"https://api.github.com/repos/tendermint/tendermint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/tendermint/tendermint/pulls/676/commits"},"statuses":{"href":"https://api.github.com/repos/tendermint/tendermint/statuses/53f0fccdef16eb62f5c50c66d2db4be451f22251"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"odeke-em"}}