Beispiel #1
0
        private Task ProcessSendProvenHeadersPayload(SendProvenHeadersPayload sendProvenHeadersPayload)
        {
            this.PreferHeaders = true;

            var provenHeadersActivationHeight = (this.network.Consensus.Options as PosConsensusOptions).ProvenHeadersActivationHeight;

            // Ensures we don't announce ProvenHeaders before ProvenHeadersActivationHeight.
            this.AnnounceProvenHeadersFromHeight = Math.Max(provenHeadersActivationHeight, sendProvenHeadersPayload.RequireFromHeight);

            return(Task.CompletedTask);
        }
        /// <inheritdoc />
        protected override async Task OnHandshakedAsync(INetworkPeer peer)
        {
            // Require from height is the highest between activation height and last checkpoint height.
            int lastCheckpointHeight = this.checkpoints.GetLastCheckpointHeight();
            int activationHeight     = (this.network.Consensus.Options as PosConsensusOptions).ProvenHeadersActivationHeight;

            int requireFromHeight = Math.Max(lastCheckpointHeight, activationHeight);

            this.logger.LogDebug("Proven headers are requested from height {0}.", requireFromHeight);

            var sendProvenHeadersPayload = new SendProvenHeadersPayload(requireFromHeight);

            await peer.SendMessageAsync(sendProvenHeadersPayload).ConfigureAwait(false);
        }