{"action":"created","comment":{"url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments/224011523","pull_request_review_id":163273825,"id":224011523,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNDAxMTUyMw==","diff_hunk":"@@ -0,0 +1,105 @@\n+﻿using System;\n+using System.Collections.Generic;\n+using System.Linq;\n+using System.Threading;\n+using System.Threading.Tasks;\n+using Microsoft.Extensions.Logging;\n+using NBitcoin;\n+using Stratis.Bitcoin.Connection;\n+using Stratis.Bitcoin.Interfaces;\n+using Stratis.Bitcoin.P2P.Peer;\n+using Stratis.Bitcoin.P2P.Protocol;\n+using Stratis.Bitcoin.P2P.Protocol.Payloads;\n+using Stratis.Bitcoin.Utilities;\n+\n+namespace Stratis.Bitcoin.Consensus\n+{\n+    /// <summary>Behavior that takes care of proven headers protocol. It also keeps the notion of peer's consensus tip.</summary>\n+    public class ProvenHeadersConsensusManagerBehavior : ConsensusManagerBehavior\n+    {\n+        private readonly ConcurrentChain chain;\n+        private readonly IInitialBlockDownloadState initialBlockDownloadState;\n+        private readonly IConsensusManager consensusManager;\n+        private readonly IPeerBanning peerBanning;\n+        private readonly ILoggerFactory loggerFactory;\n+        private readonly PosConsensusFactory consensusFactory;\n+\n+        /// <summary>Instance logger.</summary>\n+        private readonly ILogger logger;\n+\n+        public ProvenHeadersConsensusManagerBehavior(ConcurrentChain chain, IInitialBlockDownloadState initialBlockDownloadState, IConsensusManager consensusManager, IPeerBanning peerBanning, ILoggerFactory loggerFactory) : base(chain, initialBlockDownloadState, consensusManager, peerBanning, loggerFactory)\n+        {\n+            this.chain = chain;\n+            this.initialBlockDownloadState = initialBlockDownloadState;\n+            this.consensusManager = consensusManager;\n+            this.peerBanning = peerBanning;\n+            this.loggerFactory = loggerFactory;\n+            this.consensusFactory = new PosConsensusFactory();\n+            this.logger = loggerFactory.CreateLogger(this.GetType().FullName, $\"[{this.GetHashCode():x}] \");\n+        }\n+\n+        /// <inheritdoc />\n+        /// <summary>\n+        /// Processes and incoming message from the peer.\n+        /// </summary>\n+        /// <param name=\"peer\">Peer from which the message was received.</param>\n+        /// <param name=\"message\">Received message to process.</param>\n+        protected override async Task OnMessageReceivedAsync(INetworkPeer peer, IncomingMessage message)\n+        {\n+            await base.OnMessageReceivedAsync(peer, message);\n+            switch (message.Message.Payload)\n+            {\n+                case ProvenHeadersPayload provenHeaders:\n+                    await this.ProcessHeadersAsync(peer, provenHeaders.Headers.Cast<BlockHeader>().ToList()).ConfigureAwait(false);\n+                    break;\n+\n+                case GetProvenHeadersPayload getHeaders:\n+                    await this.ProcessGetHeadersAsync(peer, getHeaders).ConfigureAwait(false);\n+                    break;\n+            }\n+        }\n+\n+        /// <summary>Constructs the proven headers payload from locator to consensus tip.</summary>\n+        /// <param name=\"locator\">Block locator.</param>\n+        /// <param name=\"hashStop\">Hash of the block after which constructing headers payload should stop.</param>\n+        /// <param name=\"lastHeader\"><see cref=\"ProvenBlockHeader\"/> of the last header that was added to the <see cref=\"ProvenHeadersPayload\"/>.</param>\n+        /// <returns><see cref=\"ProvenHeadersPayload\"/> with headers from locator towards consensus tip or <c>null</c> in case locator was invalid.</returns>\n+        private ProvenHeadersPayload ConstructProvenHeadersPayload(BlockLocator locator, uint256 hashStop, out ChainedHeader lastHeader)","path":"src/Stratis.Bitcoin/Consensus/ProvenHeadersConsensusManagerBehavior.cs","position":67,"original_position":67,"commit_id":"71099ec35c2274b4fd2457864215bbf1cbee9ec5","original_commit_id":"71099ec35c2274b4fd2457864215bbf1cbee9ec5","user":{"login":"noescape00","id":10259355,"node_id":"MDQ6VXNlcjEwMjU5MzU1","avatar_url":"https://avatars0.githubusercontent.com/u/10259355?v=4","gravatar_id":"","url":"https://api.github.com/users/noescape00","html_url":"https://github.com/noescape00","followers_url":"https://api.github.com/users/noescape00/followers","following_url":"https://api.github.com/users/noescape00/following{/other_user}","gists_url":"https://api.github.com/users/noescape00/gists{/gist_id}","starred_url":"https://api.github.com/users/noescape00/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/noescape00/subscriptions","organizations_url":"https://api.github.com/users/noescape00/orgs","repos_url":"https://api.github.com/users/noescape00/repos","events_url":"https://api.github.com/users/noescape00/events{/privacy}","received_events_url":"https://api.github.com/users/noescape00/received_events","type":"User","site_admin":false},"body":"method is not used","created_at":"2018-10-10T09:55:04Z","updated_at":"2018-10-10T09:55:43Z","html_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/2400#discussion_r224011523","pull_request_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments/224011523"},"html":{"href":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/2400#discussion_r224011523"},"pull_request":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400"}}},"pull_request":{"url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400","id":220830039,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwODMwMDM5","html_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/2400","diff_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/2400.diff","patch_url":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/2400.patch","issue_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/2400","number":2400,"state":"open","locked":false,"title":"[PH] Extending ConsensusManagerBehaviour #2145","user":{"login":"kogot","id":5482607,"node_id":"MDQ6VXNlcjU0ODI2MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/5482607?v=4","gravatar_id":"","url":"https://api.github.com/users/kogot","html_url":"https://github.com/kogot","followers_url":"https://api.github.com/users/kogot/followers","following_url":"https://api.github.com/users/kogot/following{/other_user}","gists_url":"https://api.github.com/users/kogot/gists{/gist_id}","starred_url":"https://api.github.com/users/kogot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogot/subscriptions","organizations_url":"https://api.github.com/users/kogot/orgs","repos_url":"https://api.github.com/users/kogot/repos","events_url":"https://api.github.com/users/kogot/events{/privacy}","received_events_url":"https://api.github.com/users/kogot/received_events","type":"User","site_admin":false},"body":"this is for extend ConsensusManagerBehaviour to handle ProvenHeaders payload","created_at":"2018-10-05T21:33:32Z","updated_at":"2018-10-10T09:55:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f25f82a66cb433bd588b6b02501cf9906557cf3a","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400/commits","review_comments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400/comments","review_comment_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/2400/comments","statuses_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/statuses/71099ec35c2274b4fd2457864215bbf1cbee9ec5","head":{"label":"kogot:ph-consensusmanager","ref":"ph-consensusmanager","sha":"71099ec35c2274b4fd2457864215bbf1cbee9ec5","user":{"login":"kogot","id":5482607,"node_id":"MDQ6VXNlcjU0ODI2MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/5482607?v=4","gravatar_id":"","url":"https://api.github.com/users/kogot","html_url":"https://github.com/kogot","followers_url":"https://api.github.com/users/kogot/followers","following_url":"https://api.github.com/users/kogot/following{/other_user}","gists_url":"https://api.github.com/users/kogot/gists{/gist_id}","starred_url":"https://api.github.com/users/kogot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogot/subscriptions","organizations_url":"https://api.github.com/users/kogot/orgs","repos_url":"https://api.github.com/users/kogot/repos","events_url":"https://api.github.com/users/kogot/events{/privacy}","received_events_url":"https://api.github.com/users/kogot/received_events","type":"User","site_admin":false},"repo":{"id":119508425,"node_id":"MDEwOlJlcG9zaXRvcnkxMTk1MDg0MjU=","name":"StratisBitcoinFullNode","full_name":"kogot/StratisBitcoinFullNode","private":false,"owner":{"login":"kogot","id":5482607,"node_id":"MDQ6VXNlcjU0ODI2MDc=","avatar_url":"https://avatars0.githubusercontent.com/u/5482607?v=4","gravatar_id":"","url":"https://api.github.com/users/kogot","html_url":"https://github.com/kogot","followers_url":"https://api.github.com/users/kogot/followers","following_url":"https://api.github.com/users/kogot/following{/other_user}","gists_url":"https://api.github.com/users/kogot/gists{/gist_id}","starred_url":"https://api.github.com/users/kogot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kogot/subscriptions","organizations_url":"https://api.github.com/users/kogot/orgs","repos_url":"https://api.github.com/users/kogot/repos","events_url":"https://api.github.com/users/kogot/events{/privacy}","received_events_url":"https://api.github.com/users/kogot/received_events","type":"User","site_admin":false},"html_url":"https://github.com/kogot/StratisBitcoinFullNode","description":"Bitcoin full node in C#","fork":true,"url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode","forks_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/forks","keys_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/teams","hooks_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/hooks","issue_events_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/issues/events{/number}","events_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/events","assignees_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/assignees{/user}","branches_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/branches{/branch}","tags_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/tags","blobs_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/git/refs{/sha}","trees_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/statuses/{sha}","languages_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/languages","stargazers_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/stargazers","contributors_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/contributors","subscribers_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/subscribers","subscription_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/subscription","commits_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/commits{/sha}","git_commits_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/git/commits{/sha}","comments_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/comments{/number}","issue_comment_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/issues/comments{/number}","contents_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/contents/{+path}","compare_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/merges","archive_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/downloads","issues_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/issues{/number}","pulls_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/pulls{/number}","milestones_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/milestones{/number}","notifications_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/labels{/name}","releases_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/releases{/id}","deployments_url":"https://api.github.com/repos/kogot/StratisBitcoinFullNode/deployments","created_at":"2018-01-30T08:49:38Z","updated_at":"2018-08-10T10:04:50Z","pushed_at":"2018-10-09T14:05:44Z","git_url":"git://github.com/kogot/StratisBitcoinFullNode.git","ssh_url":"git@github.com:kogot/StratisBitcoinFullNode.git","clone_url":"https://github.com/kogot/StratisBitcoinFullNode.git","svn_url":"https://github.com/kogot/StratisBitcoinFullNode","homepage":"https://stratisplatform.com","size":37718,"stargazers_count":0,"watchers_count":0,"language":"C#","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":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"stratisproject:master","ref":"master","sha":"09c51923be3ea561e6456d3d319514e91dc221ca","user":{"login":"stratisproject","id":15229748,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MjI5NzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"repo":{"id":67271290,"node_id":"MDEwOlJlcG9zaXRvcnk2NzI3MTI5MA==","name":"StratisBitcoinFullNode","full_name":"stratisproject/StratisBitcoinFullNode","private":false,"owner":{"login":"stratisproject","id":15229748,"node_id":"MDEyOk9yZ2FuaXphdGlvbjE1MjI5NzQ4","avatar_url":"https://avatars0.githubusercontent.com/u/15229748?v=4","gravatar_id":"","url":"https://api.github.com/users/stratisproject","html_url":"https://github.com/stratisproject","followers_url":"https://api.github.com/users/stratisproject/followers","following_url":"https://api.github.com/users/stratisproject/following{/other_user}","gists_url":"https://api.github.com/users/stratisproject/gists{/gist_id}","starred_url":"https://api.github.com/users/stratisproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stratisproject/subscriptions","organizations_url":"https://api.github.com/users/stratisproject/orgs","repos_url":"https://api.github.com/users/stratisproject/repos","events_url":"https://api.github.com/users/stratisproject/events{/privacy}","received_events_url":"https://api.github.com/users/stratisproject/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stratisproject/StratisBitcoinFullNode","description":"Bitcoin full node in C#","fork":false,"url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode","forks_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/forks","keys_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/teams","hooks_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/hooks","issue_events_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/events{/number}","events_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/events","assignees_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/assignees{/user}","branches_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/branches{/branch}","tags_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/tags","blobs_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/refs{/sha}","trees_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/statuses/{sha}","languages_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/languages","stargazers_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/stargazers","contributors_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/contributors","subscribers_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/subscribers","subscription_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/subscription","commits_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/commits{/sha}","git_commits_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/git/commits{/sha}","comments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/comments{/number}","issue_comment_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/comments{/number}","contents_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/contents/{+path}","compare_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/merges","archive_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/downloads","issues_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues{/number}","pulls_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls{/number}","milestones_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/milestones{/number}","notifications_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/labels{/name}","releases_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/releases{/id}","deployments_url":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/deployments","created_at":"2016-09-03T04:32:51Z","updated_at":"2018-10-10T09:01:15Z","pushed_at":"2018-10-10T09:12:51Z","git_url":"git://github.com/stratisproject/StratisBitcoinFullNode.git","ssh_url":"git@github.com:stratisproject/StratisBitcoinFullNode.git","clone_url":"https://github.com/stratisproject/StratisBitcoinFullNode.git","svn_url":"https://github.com/stratisproject/StratisBitcoinFullNode","homepage":"https://stratisplatform.com","size":34335,"stargazers_count":583,"watchers_count":583,"language":"C#","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":255,"mirror_url":null,"archived":false,"open_issues_count":191,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":255,"open_issues":191,"watchers":583,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400"},"html":{"href":"https://github.com/stratisproject/StratisBitcoinFullNode/pull/2400"},"issue":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/2400"},"comments":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/issues/2400/comments"},"review_comments":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400/comments"},"review_comment":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/pulls/2400/commits"},"statuses":{"href":"https://api.github.com/repos/stratisproject/StratisBitcoinFullNode/statuses/71099ec35c2274b4fd2457864215bbf1cbee9ec5"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"noescape00"}}