{"action":"created","comment":{"url":"https://api.github.com/repos/solana-labs/solana/pulls/comments/220736929","pull_request_review_id":159215486,"id":220736929,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyMDczNjkyOQ==","diff_hunk":"@@ -0,0 +1,104 @@\n+//! The `poh_service` module provides an object for generating a Proof of History.\n+//! It records Hashes items on behalf of its users. It continuously generates\n+//! new Hashes, only stopping to check if it has been sent a Hash to mix in\n+//! to the Poh.\n+//!\n+//! The returned Entry includes the mix-in request, the latest Poh Hash, and the\n+//! number of Hashes generated in the service since the last mix-in request.\n+//!\n+//! The resulting stream of Hashes represents ordered events in time.\n+//!\n+use bank::Bank;\n+use entry::Entry;\n+use hash::Hash;\n+use poh::Poh;\n+use result::Result;\n+use std::sync::mpsc::Sender;\n+use std::sync::{Arc, Mutex};\n+use transaction::Transaction;\n+\n+#[derive(Clone)]\n+pub struct PohRecorder {\n+    poh: Arc<Mutex<Poh>>,\n+    bank: Arc<Bank>,\n+    sender: Sender<Vec<Entry>>,\n+}\n+\n+impl PohRecorder {\n+    /// A recorder to synchronize PoH with the following data structures\n+    /// * bank - the LastId's queue is updated on `tick` and `record` events\n+    /// * sender - the Entry channel that outputs to the ledger\n+    pub fn new(bank: Arc<Bank>, sender: Sender<Vec<Entry>>) -> Self {\n+        let poh = Arc::new(Mutex::new(Poh::new(bank.last_id())));\n+        PohRecorder { poh, bank, sender }\n+    }\n+\n+    pub fn hash(&self) {\n+        // TODO: amortize the cost of this lock by doing the loop in here for\n+        // some min amount of hashes\n+        let mut poh = self.poh.lock().unwrap();\n+        poh.hash()\n+    }\n+\n+    pub fn tick(&self) -> Result<()> {\n+        // Register and send the entry out while holding the lock.\n+        // This guarantees PoH order and Entry production and banks LastId queue is the same\n+        let mut poh = self.poh.lock().unwrap();\n+        let tick = poh.tick();\n+        self.bank.register_entry_id(&tick.id);\n+        let entry = Entry {\n+            num_hashes: tick.num_hashes,\n+            id: tick.id,\n+            transactions: vec![],\n+        };\n+        self.sender.send(vec![entry])?;\n+        Ok(())\n+    }\n+\n+    pub fn record(&self, mixin: Hash, txs: Vec<Transaction>) -> Result<()> {\n+        // Register and send the entry out while holding the lock.\n+        // This guarantees PoH order and Entry production and banks LastId queue is the same.\n+        let mut poh = self.poh.lock().unwrap();","path":"src/poh_recorder.rs","position":61,"original_position":61,"commit_id":"fdb4fc3d7d34409f6032372b4847df17ce6c1822","original_commit_id":"1a7b1028730609882c897e15c40d18bc3fbece33","user":{"login":"rob-solana","id":40183961,"node_id":"MDQ6VXNlcjQwMTgzOTYx","avatar_url":"https://avatars0.githubusercontent.com/u/40183961?v=4","gravatar_id":"","url":"https://api.github.com/users/rob-solana","html_url":"https://github.com/rob-solana","followers_url":"https://api.github.com/users/rob-solana/followers","following_url":"https://api.github.com/users/rob-solana/following{/other_user}","gists_url":"https://api.github.com/users/rob-solana/gists{/gist_id}","starred_url":"https://api.github.com/users/rob-solana/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rob-solana/subscriptions","organizations_url":"https://api.github.com/users/rob-solana/orgs","repos_url":"https://api.github.com/users/rob-solana/repos","events_url":"https://api.github.com/users/rob-solana/events{/privacy}","received_events_url":"https://api.github.com/users/rob-solana/received_events","type":"User","site_admin":false},"body":"this lock guards sender.send()?","created_at":"2018-09-26T21:58:49Z","updated_at":"2018-09-26T21:58:49Z","html_url":"https://github.com/solana-labs/solana/pull/1357#discussion_r220736929","pull_request_url":"https://api.github.com/repos/solana-labs/solana/pulls/1357","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/solana-labs/solana/pulls/comments/220736929"},"html":{"href":"https://github.com/solana-labs/solana/pull/1357#discussion_r220736929"},"pull_request":{"href":"https://api.github.com/repos/solana-labs/solana/pulls/1357"}},"in_reply_to_id":220712310},"pull_request":{"url":"https://api.github.com/repos/solana-labs/solana/pulls/1357","id":218443893,"node_id":"MDExOlB1bGxSZXF1ZXN0MjE4NDQzODkz","html_url":"https://github.com/solana-labs/solana/pull/1357","diff_url":"https://github.com/solana-labs/solana/pull/1357.diff","patch_url":"https://github.com/solana-labs/solana/pull/1357.patch","issue_url":"https://api.github.com/repos/solana-labs/solana/issues/1357","number":1357,"state":"open","locked":false,"title":"PoH Recorder to synchronize PoH, bank's last_id queue, and ledger entries","user":{"login":"aeyakovenko","id":1029046,"node_id":"MDQ6VXNlcjEwMjkwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1029046?v=4","gravatar_id":"","url":"https://api.github.com/users/aeyakovenko","html_url":"https://github.com/aeyakovenko","followers_url":"https://api.github.com/users/aeyakovenko/followers","following_url":"https://api.github.com/users/aeyakovenko/following{/other_user}","gists_url":"https://api.github.com/users/aeyakovenko/gists{/gist_id}","starred_url":"https://api.github.com/users/aeyakovenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeyakovenko/subscriptions","organizations_url":"https://api.github.com/users/aeyakovenko/orgs","repos_url":"https://api.github.com/users/aeyakovenko/repos","events_url":"https://api.github.com/users/aeyakovenko/events{/privacy}","received_events_url":"https://api.github.com/users/aeyakovenko/received_events","type":"User","site_admin":false},"body":"PoH Recorder to synchronize PoH, bank's last_id queue, and ledger entries.  Fixes to banking stage benches","created_at":"2018-09-26T20:25:40Z","updated_at":"2018-09-26T21:58:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8371c6a4c460f89bfdfc1b2d8c6862b096aa1466","assignee":null,"assignees":[],"requested_reviewers":[{"login":"garious","id":55449,"node_id":"MDQ6VXNlcjU1NDQ5","avatar_url":"https://avatars1.githubusercontent.com/u/55449?v=4","gravatar_id":"","url":"https://api.github.com/users/garious","html_url":"https://github.com/garious","followers_url":"https://api.github.com/users/garious/followers","following_url":"https://api.github.com/users/garious/following{/other_user}","gists_url":"https://api.github.com/users/garious/gists{/gist_id}","starred_url":"https://api.github.com/users/garious/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/garious/subscriptions","organizations_url":"https://api.github.com/users/garious/orgs","repos_url":"https://api.github.com/users/garious/repos","events_url":"https://api.github.com/users/garious/events{/privacy}","received_events_url":"https://api.github.com/users/garious/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/solana-labs/solana/pulls/1357/commits","review_comments_url":"https://api.github.com/repos/solana-labs/solana/pulls/1357/comments","review_comment_url":"https://api.github.com/repos/solana-labs/solana/pulls/comments{/number}","comments_url":"https://api.github.com/repos/solana-labs/solana/issues/1357/comments","statuses_url":"https://api.github.com/repos/solana-labs/solana/statuses/fdb4fc3d7d34409f6032372b4847df17ce6c1822","head":{"label":"aeyakovenko:fix_poh","ref":"fix_poh","sha":"fdb4fc3d7d34409f6032372b4847df17ce6c1822","user":{"login":"aeyakovenko","id":1029046,"node_id":"MDQ6VXNlcjEwMjkwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1029046?v=4","gravatar_id":"","url":"https://api.github.com/users/aeyakovenko","html_url":"https://github.com/aeyakovenko","followers_url":"https://api.github.com/users/aeyakovenko/followers","following_url":"https://api.github.com/users/aeyakovenko/following{/other_user}","gists_url":"https://api.github.com/users/aeyakovenko/gists{/gist_id}","starred_url":"https://api.github.com/users/aeyakovenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeyakovenko/subscriptions","organizations_url":"https://api.github.com/users/aeyakovenko/orgs","repos_url":"https://api.github.com/users/aeyakovenko/repos","events_url":"https://api.github.com/users/aeyakovenko/events{/privacy}","received_events_url":"https://api.github.com/users/aeyakovenko/received_events","type":"User","site_admin":false},"repo":{"id":124140461,"node_id":"MDEwOlJlcG9zaXRvcnkxMjQxNDA0NjE=","name":"solana","full_name":"aeyakovenko/solana","private":false,"owner":{"login":"aeyakovenko","id":1029046,"node_id":"MDQ6VXNlcjEwMjkwNDY=","avatar_url":"https://avatars0.githubusercontent.com/u/1029046?v=4","gravatar_id":"","url":"https://api.github.com/users/aeyakovenko","html_url":"https://github.com/aeyakovenko","followers_url":"https://api.github.com/users/aeyakovenko/followers","following_url":"https://api.github.com/users/aeyakovenko/following{/other_user}","gists_url":"https://api.github.com/users/aeyakovenko/gists{/gist_id}","starred_url":"https://api.github.com/users/aeyakovenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aeyakovenko/subscriptions","organizations_url":"https://api.github.com/users/aeyakovenko/orgs","repos_url":"https://api.github.com/users/aeyakovenko/repos","events_url":"https://api.github.com/users/aeyakovenko/events{/privacy}","received_events_url":"https://api.github.com/users/aeyakovenko/received_events","type":"User","site_admin":false},"html_url":"https://github.com/aeyakovenko/solana","description":"a high performance blockchain","fork":true,"url":"https://api.github.com/repos/aeyakovenko/solana","forks_url":"https://api.github.com/repos/aeyakovenko/solana/forks","keys_url":"https://api.github.com/repos/aeyakovenko/solana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aeyakovenko/solana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aeyakovenko/solana/teams","hooks_url":"https://api.github.com/repos/aeyakovenko/solana/hooks","issue_events_url":"https://api.github.com/repos/aeyakovenko/solana/issues/events{/number}","events_url":"https://api.github.com/repos/aeyakovenko/solana/events","assignees_url":"https://api.github.com/repos/aeyakovenko/solana/assignees{/user}","branches_url":"https://api.github.com/repos/aeyakovenko/solana/branches{/branch}","tags_url":"https://api.github.com/repos/aeyakovenko/solana/tags","blobs_url":"https://api.github.com/repos/aeyakovenko/solana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aeyakovenko/solana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aeyakovenko/solana/git/refs{/sha}","trees_url":"https://api.github.com/repos/aeyakovenko/solana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aeyakovenko/solana/statuses/{sha}","languages_url":"https://api.github.com/repos/aeyakovenko/solana/languages","stargazers_url":"https://api.github.com/repos/aeyakovenko/solana/stargazers","contributors_url":"https://api.github.com/repos/aeyakovenko/solana/contributors","subscribers_url":"https://api.github.com/repos/aeyakovenko/solana/subscribers","subscription_url":"https://api.github.com/repos/aeyakovenko/solana/subscription","commits_url":"https://api.github.com/repos/aeyakovenko/solana/commits{/sha}","git_commits_url":"https://api.github.com/repos/aeyakovenko/solana/git/commits{/sha}","comments_url":"https://api.github.com/repos/aeyakovenko/solana/comments{/number}","issue_comment_url":"https://api.github.com/repos/aeyakovenko/solana/issues/comments{/number}","contents_url":"https://api.github.com/repos/aeyakovenko/solana/contents/{+path}","compare_url":"https://api.github.com/repos/aeyakovenko/solana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aeyakovenko/solana/merges","archive_url":"https://api.github.com/repos/aeyakovenko/solana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aeyakovenko/solana/downloads","issues_url":"https://api.github.com/repos/aeyakovenko/solana/issues{/number}","pulls_url":"https://api.github.com/repos/aeyakovenko/solana/pulls{/number}","milestones_url":"https://api.github.com/repos/aeyakovenko/solana/milestones{/number}","notifications_url":"https://api.github.com/repos/aeyakovenko/solana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aeyakovenko/solana/labels{/name}","releases_url":"https://api.github.com/repos/aeyakovenko/solana/releases{/id}","deployments_url":"https://api.github.com/repos/aeyakovenko/solana/deployments","created_at":"2018-03-06T21:24:10Z","updated_at":"2018-09-25T23:00:51Z","pushed_at":"2018-09-26T21:56:35Z","git_url":"git://github.com/aeyakovenko/solana.git","ssh_url":"git@github.com:aeyakovenko/solana.git","clone_url":"https://github.com/aeyakovenko/solana.git","svn_url":"https://github.com/aeyakovenko/solana","homepage":"https://solana.com","size":11861,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"solana-labs:master","ref":"master","sha":"ca962371b8d379dd12c602b2a99d779103859721","user":{"login":"solana-labs","id":35608259,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NjA4MjU5","avatar_url":"https://avatars3.githubusercontent.com/u/35608259?v=4","gravatar_id":"","url":"https://api.github.com/users/solana-labs","html_url":"https://github.com/solana-labs","followers_url":"https://api.github.com/users/solana-labs/followers","following_url":"https://api.github.com/users/solana-labs/following{/other_user}","gists_url":"https://api.github.com/users/solana-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/solana-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solana-labs/subscriptions","organizations_url":"https://api.github.com/users/solana-labs/orgs","repos_url":"https://api.github.com/users/solana-labs/repos","events_url":"https://api.github.com/users/solana-labs/events{/privacy}","received_events_url":"https://api.github.com/users/solana-labs/received_events","type":"Organization","site_admin":false},"repo":{"id":121470383,"node_id":"MDEwOlJlcG9zaXRvcnkxMjE0NzAzODM=","name":"solana","full_name":"solana-labs/solana","private":false,"owner":{"login":"solana-labs","id":35608259,"node_id":"MDEyOk9yZ2FuaXphdGlvbjM1NjA4MjU5","avatar_url":"https://avatars3.githubusercontent.com/u/35608259?v=4","gravatar_id":"","url":"https://api.github.com/users/solana-labs","html_url":"https://github.com/solana-labs","followers_url":"https://api.github.com/users/solana-labs/followers","following_url":"https://api.github.com/users/solana-labs/following{/other_user}","gists_url":"https://api.github.com/users/solana-labs/gists{/gist_id}","starred_url":"https://api.github.com/users/solana-labs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/solana-labs/subscriptions","organizations_url":"https://api.github.com/users/solana-labs/orgs","repos_url":"https://api.github.com/users/solana-labs/repos","events_url":"https://api.github.com/users/solana-labs/events{/privacy}","received_events_url":"https://api.github.com/users/solana-labs/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/solana-labs/solana","description":"Blockchain, Rebuilt for Scale","fork":false,"url":"https://api.github.com/repos/solana-labs/solana","forks_url":"https://api.github.com/repos/solana-labs/solana/forks","keys_url":"https://api.github.com/repos/solana-labs/solana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/solana-labs/solana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/solana-labs/solana/teams","hooks_url":"https://api.github.com/repos/solana-labs/solana/hooks","issue_events_url":"https://api.github.com/repos/solana-labs/solana/issues/events{/number}","events_url":"https://api.github.com/repos/solana-labs/solana/events","assignees_url":"https://api.github.com/repos/solana-labs/solana/assignees{/user}","branches_url":"https://api.github.com/repos/solana-labs/solana/branches{/branch}","tags_url":"https://api.github.com/repos/solana-labs/solana/tags","blobs_url":"https://api.github.com/repos/solana-labs/solana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/solana-labs/solana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/solana-labs/solana/git/refs{/sha}","trees_url":"https://api.github.com/repos/solana-labs/solana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/solana-labs/solana/statuses/{sha}","languages_url":"https://api.github.com/repos/solana-labs/solana/languages","stargazers_url":"https://api.github.com/repos/solana-labs/solana/stargazers","contributors_url":"https://api.github.com/repos/solana-labs/solana/contributors","subscribers_url":"https://api.github.com/repos/solana-labs/solana/subscribers","subscription_url":"https://api.github.com/repos/solana-labs/solana/subscription","commits_url":"https://api.github.com/repos/solana-labs/solana/commits{/sha}","git_commits_url":"https://api.github.com/repos/solana-labs/solana/git/commits{/sha}","comments_url":"https://api.github.com/repos/solana-labs/solana/comments{/number}","issue_comment_url":"https://api.github.com/repos/solana-labs/solana/issues/comments{/number}","contents_url":"https://api.github.com/repos/solana-labs/solana/contents/{+path}","compare_url":"https://api.github.com/repos/solana-labs/solana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/solana-labs/solana/merges","archive_url":"https://api.github.com/repos/solana-labs/solana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/solana-labs/solana/downloads","issues_url":"https://api.github.com/repos/solana-labs/solana/issues{/number}","pulls_url":"https://api.github.com/repos/solana-labs/solana/pulls{/number}","milestones_url":"https://api.github.com/repos/solana-labs/solana/milestones{/number}","notifications_url":"https://api.github.com/repos/solana-labs/solana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/solana-labs/solana/labels{/name}","releases_url":"https://api.github.com/repos/solana-labs/solana/releases{/id}","deployments_url":"https://api.github.com/repos/solana-labs/solana/deployments","created_at":"2018-02-14T04:26:27Z","updated_at":"2018-09-26T20:41:17Z","pushed_at":"2018-09-26T21:56:37Z","git_url":"git://github.com/solana-labs/solana.git","ssh_url":"git@github.com:solana-labs/solana.git","clone_url":"https://github.com/solana-labs/solana.git","svn_url":"https://github.com/solana-labs/solana","homepage":"https://solana.com","size":11353,"stargazers_count":344,"watchers_count":344,"language":"Rust","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":54,"mirror_url":null,"archived":false,"open_issues_count":133,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":54,"open_issues":133,"watchers":344,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/solana-labs/solana/pulls/1357"},"html":{"href":"https://github.com/solana-labs/solana/pull/1357"},"issue":{"href":"https://api.github.com/repos/solana-labs/solana/issues/1357"},"comments":{"href":"https://api.github.com/repos/solana-labs/solana/issues/1357/comments"},"review_comments":{"href":"https://api.github.com/repos/solana-labs/solana/pulls/1357/comments"},"review_comment":{"href":"https://api.github.com/repos/solana-labs/solana/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/solana-labs/solana/pulls/1357/commits"},"statuses":{"href":"https://api.github.com/repos/solana-labs/solana/statuses/fdb4fc3d7d34409f6032372b4847df17ce6c1822"}},"author_association":"MEMBER"}}
{"actor":{"display_login":"rob-solana"}}