{"action":"created","comment":{"url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments/202503658","pull_request_review_id":137226320,"id":202503658,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwMjUwMzY1OA==","diff_hunk":"@@ -36,99 +32,85 @@ type BitcoindClient struct {\n \tstarted int32 // To be used atomically.\n \tstopped int32 // To be used atomically.\n \n-\tclient      *rpcclient.Client\n-\tconnConfig  *rpcclient.ConnConfig // Work around unexported field\n+\t// birthday is the earliest time for which we should begin scanning the\n+\t// chain.\n+\tbirthday time.Time\n+\n+\t// chainParams are the parameters of the current chain this client is\n+\t// active under.\n \tchainParams *chaincfg.Params\n \n-\tzmqConnect      string\n-\tzmqPollInterval time.Duration\n+\t// clientID is the unique ID of this client assigned by the backing\n+\t// bitcoind connection.\n+\tclientID uint64\n \n-\tnotificationQueue *ConcurrentQueue\n+\t// chainConn is the backing client to our rescan client that contains\n+\t// the RPC and ZMQ connections to a bitcoind node.\n+\tchainConn *BitcoindConn\n \n+\t// bestBlock keeps track of the tip of the current best chain.\n \tbestBlockMtx sync.RWMutex\n \tbestBlock    waddrmgr.BlockStamp\n \n-\tclientMtx      sync.RWMutex\n-\trescanUpdate   chan interface{}\n-\tstartTime      time.Time\n+\t// notifyBlocks signals whether the client is sending block\n+\t// notifications to the caller.\n+\tnotifyBlocks uint32","path":"chain/bitcoind_client.go","position":null,"original_position":61,"commit_id":"56d594410e8d3184f60b088b2caff3a7c5a4d312","original_commit_id":"3f2472e40de6f63edd6aef8901675b0c0698f2bb","user":{"login":"wpaulino","id":9447167,"node_id":"MDQ6VXNlcjk0NDcxNjc=","avatar_url":"https://avatars0.githubusercontent.com/u/9447167?v=4","gravatar_id":"","url":"https://api.github.com/users/wpaulino","html_url":"https://github.com/wpaulino","followers_url":"https://api.github.com/users/wpaulino/followers","following_url":"https://api.github.com/users/wpaulino/following{/other_user}","gists_url":"https://api.github.com/users/wpaulino/gists{/gist_id}","starred_url":"https://api.github.com/users/wpaulino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpaulino/subscriptions","organizations_url":"https://api.github.com/users/wpaulino/orgs","repos_url":"https://api.github.com/users/wpaulino/repos","events_url":"https://api.github.com/users/wpaulino/events{/privacy}","received_events_url":"https://api.github.com/users/wpaulino/received_events","type":"User","site_admin":false},"body":"It needs to be atomic.","created_at":"2018-07-14T02:40:08Z","updated_at":"2018-07-14T02:40:08Z","html_url":"https://github.com/btcsuite/btcwallet/pull/511#discussion_r202503658","pull_request_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments/202503658"},"html":{"href":"https://github.com/btcsuite/btcwallet/pull/511#discussion_r202503658"},"pull_request":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511"}},"in_reply_to_id":202218479},"pull_request":{"url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511","id":196614758,"node_id":"MDExOlB1bGxSZXF1ZXN0MTk2NjE0NzU4","html_url":"https://github.com/btcsuite/btcwallet/pull/511","diff_url":"https://github.com/btcsuite/btcwallet/pull/511.diff","patch_url":"https://github.com/btcsuite/btcwallet/pull/511.patch","issue_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/511","number":511,"state":"open","locked":false,"title":"chain: share the same bitcoind connection between multiple rescan clients","user":{"login":"wpaulino","id":9447167,"node_id":"MDQ6VXNlcjk0NDcxNjc=","avatar_url":"https://avatars0.githubusercontent.com/u/9447167?v=4","gravatar_id":"","url":"https://api.github.com/users/wpaulino","html_url":"https://github.com/wpaulino","followers_url":"https://api.github.com/users/wpaulino/followers","following_url":"https://api.github.com/users/wpaulino/following{/other_user}","gists_url":"https://api.github.com/users/wpaulino/gists{/gist_id}","starred_url":"https://api.github.com/users/wpaulino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpaulino/subscriptions","organizations_url":"https://api.github.com/users/wpaulino/orgs","repos_url":"https://api.github.com/users/wpaulino/repos","events_url":"https://api.github.com/users/wpaulino/events{/privacy}","received_events_url":"https://api.github.com/users/wpaulino/received_events","type":"User","site_admin":false},"body":"In this PR, we introduce a nice optimization to `btcwallet`'s interaction with a `bitcoind` node. This was mostly inspired by https://github.com/lightningnetwork/lnd/issues/1174. Within `lnd`, we currently have three different subsystems responsible for watching the chain: `chainntnfs`, `lnwallet`,  and `routing/chainview`. Each of these subsystems has an active RPC and ZMQ connection to the underlying `bitcoind` node. This would incur a toll on the underlying `bitcoind` node and would cause us to miss ZMQ events, which are crucial to `lnd`. This PR attempts to remedy this by reworking how each BitcoindClient retrieves these events.\r\n\r\nWe introduce a `BitcoindConn` struct which is responsible for maintaining the RPC and ZMQ connection to a `bitcoind` node. This struct will be shared among all of the `BitcoindClients` created, and it will send each event to the currently active clients. This allows us to reduce the toll on the underlying `bitcoind` node and increases the reliability of the delivery of ZMQ events.\r\n\r\nSome other notable changes:\r\n* Used a concurrent unbounded queue for notification handling and delivery.\r\n* Improved overall documentation of methods and structs.","created_at":"2018-06-22T01:11:28Z","updated_at":"2018-07-14T02:40:08Z","closed_at":null,"merged_at":null,"merge_commit_sha":"3b4dfe8e80597c7f10d51e6a5ee09d9203faa0c6","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511/commits","review_comments_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511/comments","review_comment_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/511/comments","statuses_url":"https://api.github.com/repos/btcsuite/btcwallet/statuses/56d594410e8d3184f60b088b2caff3a7c5a4d312","head":{"label":"wpaulino:bitcoind-rescan-client","ref":"bitcoind-rescan-client","sha":"56d594410e8d3184f60b088b2caff3a7c5a4d312","user":{"login":"wpaulino","id":9447167,"node_id":"MDQ6VXNlcjk0NDcxNjc=","avatar_url":"https://avatars0.githubusercontent.com/u/9447167?v=4","gravatar_id":"","url":"https://api.github.com/users/wpaulino","html_url":"https://github.com/wpaulino","followers_url":"https://api.github.com/users/wpaulino/followers","following_url":"https://api.github.com/users/wpaulino/following{/other_user}","gists_url":"https://api.github.com/users/wpaulino/gists{/gist_id}","starred_url":"https://api.github.com/users/wpaulino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpaulino/subscriptions","organizations_url":"https://api.github.com/users/wpaulino/orgs","repos_url":"https://api.github.com/users/wpaulino/repos","events_url":"https://api.github.com/users/wpaulino/events{/privacy}","received_events_url":"https://api.github.com/users/wpaulino/received_events","type":"User","site_admin":false},"repo":{"id":136249614,"node_id":"MDEwOlJlcG9zaXRvcnkxMzYyNDk2MTQ=","name":"btcwallet","full_name":"wpaulino/btcwallet","owner":{"login":"wpaulino","id":9447167,"node_id":"MDQ6VXNlcjk0NDcxNjc=","avatar_url":"https://avatars0.githubusercontent.com/u/9447167?v=4","gravatar_id":"","url":"https://api.github.com/users/wpaulino","html_url":"https://github.com/wpaulino","followers_url":"https://api.github.com/users/wpaulino/followers","following_url":"https://api.github.com/users/wpaulino/following{/other_user}","gists_url":"https://api.github.com/users/wpaulino/gists{/gist_id}","starred_url":"https://api.github.com/users/wpaulino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wpaulino/subscriptions","organizations_url":"https://api.github.com/users/wpaulino/orgs","repos_url":"https://api.github.com/users/wpaulino/repos","events_url":"https://api.github.com/users/wpaulino/events{/privacy}","received_events_url":"https://api.github.com/users/wpaulino/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wpaulino/btcwallet","description":"A secure bitcoin wallet daemon written in Go (golang)","fork":true,"url":"https://api.github.com/repos/wpaulino/btcwallet","forks_url":"https://api.github.com/repos/wpaulino/btcwallet/forks","keys_url":"https://api.github.com/repos/wpaulino/btcwallet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wpaulino/btcwallet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wpaulino/btcwallet/teams","hooks_url":"https://api.github.com/repos/wpaulino/btcwallet/hooks","issue_events_url":"https://api.github.com/repos/wpaulino/btcwallet/issues/events{/number}","events_url":"https://api.github.com/repos/wpaulino/btcwallet/events","assignees_url":"https://api.github.com/repos/wpaulino/btcwallet/assignees{/user}","branches_url":"https://api.github.com/repos/wpaulino/btcwallet/branches{/branch}","tags_url":"https://api.github.com/repos/wpaulino/btcwallet/tags","blobs_url":"https://api.github.com/repos/wpaulino/btcwallet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wpaulino/btcwallet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wpaulino/btcwallet/git/refs{/sha}","trees_url":"https://api.github.com/repos/wpaulino/btcwallet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wpaulino/btcwallet/statuses/{sha}","languages_url":"https://api.github.com/repos/wpaulino/btcwallet/languages","stargazers_url":"https://api.github.com/repos/wpaulino/btcwallet/stargazers","contributors_url":"https://api.github.com/repos/wpaulino/btcwallet/contributors","subscribers_url":"https://api.github.com/repos/wpaulino/btcwallet/subscribers","subscription_url":"https://api.github.com/repos/wpaulino/btcwallet/subscription","commits_url":"https://api.github.com/repos/wpaulino/btcwallet/commits{/sha}","git_commits_url":"https://api.github.com/repos/wpaulino/btcwallet/git/commits{/sha}","comments_url":"https://api.github.com/repos/wpaulino/btcwallet/comments{/number}","issue_comment_url":"https://api.github.com/repos/wpaulino/btcwallet/issues/comments{/number}","contents_url":"https://api.github.com/repos/wpaulino/btcwallet/contents/{+path}","compare_url":"https://api.github.com/repos/wpaulino/btcwallet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wpaulino/btcwallet/merges","archive_url":"https://api.github.com/repos/wpaulino/btcwallet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wpaulino/btcwallet/downloads","issues_url":"https://api.github.com/repos/wpaulino/btcwallet/issues{/number}","pulls_url":"https://api.github.com/repos/wpaulino/btcwallet/pulls{/number}","milestones_url":"https://api.github.com/repos/wpaulino/btcwallet/milestones{/number}","notifications_url":"https://api.github.com/repos/wpaulino/btcwallet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wpaulino/btcwallet/labels{/name}","releases_url":"https://api.github.com/repos/wpaulino/btcwallet/releases{/id}","deployments_url":"https://api.github.com/repos/wpaulino/btcwallet/deployments","created_at":"2018-06-06T00:24:05Z","updated_at":"2018-06-20T00:56:21Z","pushed_at":"2018-07-14T02:39:18Z","git_url":"git://github.com/wpaulino/btcwallet.git","ssh_url":"git@github.com:wpaulino/btcwallet.git","clone_url":"https://github.com/wpaulino/btcwallet.git","svn_url":"https://github.com/wpaulino/btcwallet","homepage":"","size":7609,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc","node_id":"MDc6TGljZW5zZTEw"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"btcsuite:master","ref":"master","sha":"64b5b448f5e6853a2d870f388504a7807bc951f1","user":{"login":"btcsuite","id":10235229,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMjM1MjI5","avatar_url":"https://avatars0.githubusercontent.com/u/10235229?v=4","gravatar_id":"","url":"https://api.github.com/users/btcsuite","html_url":"https://github.com/btcsuite","followers_url":"https://api.github.com/users/btcsuite/followers","following_url":"https://api.github.com/users/btcsuite/following{/other_user}","gists_url":"https://api.github.com/users/btcsuite/gists{/gist_id}","starred_url":"https://api.github.com/users/btcsuite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btcsuite/subscriptions","organizations_url":"https://api.github.com/users/btcsuite/orgs","repos_url":"https://api.github.com/users/btcsuite/repos","events_url":"https://api.github.com/users/btcsuite/events{/privacy}","received_events_url":"https://api.github.com/users/btcsuite/received_events","type":"Organization","site_admin":false},"repo":{"id":12136863,"node_id":"MDEwOlJlcG9zaXRvcnkxMjEzNjg2Mw==","name":"btcwallet","full_name":"btcsuite/btcwallet","owner":{"login":"btcsuite","id":10235229,"node_id":"MDEyOk9yZ2FuaXphdGlvbjEwMjM1MjI5","avatar_url":"https://avatars0.githubusercontent.com/u/10235229?v=4","gravatar_id":"","url":"https://api.github.com/users/btcsuite","html_url":"https://github.com/btcsuite","followers_url":"https://api.github.com/users/btcsuite/followers","following_url":"https://api.github.com/users/btcsuite/following{/other_user}","gists_url":"https://api.github.com/users/btcsuite/gists{/gist_id}","starred_url":"https://api.github.com/users/btcsuite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/btcsuite/subscriptions","organizations_url":"https://api.github.com/users/btcsuite/orgs","repos_url":"https://api.github.com/users/btcsuite/repos","events_url":"https://api.github.com/users/btcsuite/events{/privacy}","received_events_url":"https://api.github.com/users/btcsuite/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/btcsuite/btcwallet","description":"A secure bitcoin wallet daemon written in Go (golang)","fork":false,"url":"https://api.github.com/repos/btcsuite/btcwallet","forks_url":"https://api.github.com/repos/btcsuite/btcwallet/forks","keys_url":"https://api.github.com/repos/btcsuite/btcwallet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/btcsuite/btcwallet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/btcsuite/btcwallet/teams","hooks_url":"https://api.github.com/repos/btcsuite/btcwallet/hooks","issue_events_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/events{/number}","events_url":"https://api.github.com/repos/btcsuite/btcwallet/events","assignees_url":"https://api.github.com/repos/btcsuite/btcwallet/assignees{/user}","branches_url":"https://api.github.com/repos/btcsuite/btcwallet/branches{/branch}","tags_url":"https://api.github.com/repos/btcsuite/btcwallet/tags","blobs_url":"https://api.github.com/repos/btcsuite/btcwallet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/btcsuite/btcwallet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/btcsuite/btcwallet/git/refs{/sha}","trees_url":"https://api.github.com/repos/btcsuite/btcwallet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/btcsuite/btcwallet/statuses/{sha}","languages_url":"https://api.github.com/repos/btcsuite/btcwallet/languages","stargazers_url":"https://api.github.com/repos/btcsuite/btcwallet/stargazers","contributors_url":"https://api.github.com/repos/btcsuite/btcwallet/contributors","subscribers_url":"https://api.github.com/repos/btcsuite/btcwallet/subscribers","subscription_url":"https://api.github.com/repos/btcsuite/btcwallet/subscription","commits_url":"https://api.github.com/repos/btcsuite/btcwallet/commits{/sha}","git_commits_url":"https://api.github.com/repos/btcsuite/btcwallet/git/commits{/sha}","comments_url":"https://api.github.com/repos/btcsuite/btcwallet/comments{/number}","issue_comment_url":"https://api.github.com/repos/btcsuite/btcwallet/issues/comments{/number}","contents_url":"https://api.github.com/repos/btcsuite/btcwallet/contents/{+path}","compare_url":"https://api.github.com/repos/btcsuite/btcwallet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/btcsuite/btcwallet/merges","archive_url":"https://api.github.com/repos/btcsuite/btcwallet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/btcsuite/btcwallet/downloads","issues_url":"https://api.github.com/repos/btcsuite/btcwallet/issues{/number}","pulls_url":"https://api.github.com/repos/btcsuite/btcwallet/pulls{/number}","milestones_url":"https://api.github.com/repos/btcsuite/btcwallet/milestones{/number}","notifications_url":"https://api.github.com/repos/btcsuite/btcwallet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/btcsuite/btcwallet/labels{/name}","releases_url":"https://api.github.com/repos/btcsuite/btcwallet/releases{/id}","deployments_url":"https://api.github.com/repos/btcsuite/btcwallet/deployments","created_at":"2013-08-15T14:53:57Z","updated_at":"2018-07-13T23:53:24Z","pushed_at":"2018-07-14T02:39:19Z","git_url":"git://github.com/btcsuite/btcwallet.git","ssh_url":"git@github.com:btcsuite/btcwallet.git","clone_url":"https://github.com/btcsuite/btcwallet.git","svn_url":"https://github.com/btcsuite/btcwallet","homepage":"","size":7557,"stargazers_count":410,"watchers_count":410,"language":"Go","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":281,"mirror_url":null,"archived":false,"open_issues_count":65,"license":{"key":"isc","name":"ISC License","spdx_id":"ISC","url":"https://api.github.com/licenses/isc","node_id":"MDc6TGljZW5zZTEw"},"forks":281,"open_issues":65,"watchers":410,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511"},"html":{"href":"https://github.com/btcsuite/btcwallet/pull/511"},"issue":{"href":"https://api.github.com/repos/btcsuite/btcwallet/issues/511"},"comments":{"href":"https://api.github.com/repos/btcsuite/btcwallet/issues/511/comments"},"review_comments":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511/comments"},"review_comment":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/btcsuite/btcwallet/pulls/511/commits"},"statuses":{"href":"https://api.github.com/repos/btcsuite/btcwallet/statuses/56d594410e8d3184f60b088b2caff3a7c5a4d312"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"wpaulino"}}