mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
Split SyncContext from protocol Context (#2550)
This commit is contained in:
committed by
Gavin Wood
parent
20e809668b
commit
e5b0a98f1a
@@ -33,7 +33,7 @@
|
||||
use std::cmp::max;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use log::{debug, trace, warn, info};
|
||||
use crate::protocol::Context;
|
||||
use crate::protocol::PeerInfo as ProtocolPeerInfo;
|
||||
use network_libp2p::PeerId;
|
||||
use client::{BlockStatus, ClientInfo};
|
||||
use consensus::{BlockOrigin, import_queue::{IncomingBlock, SharedFinalityProofRequestBuilder}};
|
||||
@@ -63,6 +63,28 @@ const ANCESTRY_BLOCK_ERROR_REPUTATION_CHANGE: i32 = -(1 << 9);
|
||||
/// Reputation change when a peer sent us a status message with a different genesis than us.
|
||||
const GENESIS_MISMATCH_REPUTATION_CHANGE: i32 = i32::min_value() + 1;
|
||||
|
||||
/// Context for a network-specific handler.
|
||||
pub trait Context<B: BlockT> {
|
||||
/// Get a reference to the client.
|
||||
fn client(&self) -> &crate::chain::Client<B>;
|
||||
|
||||
/// Adjusts the reputation of the peer. Use this to point out that a peer has been malign or
|
||||
/// irresponsible or appeared lazy.
|
||||
fn report_peer(&mut self, who: PeerId, reputation: i32);
|
||||
|
||||
/// Force disconnecting from a peer. Use this when a peer misbehaved.
|
||||
fn disconnect_peer(&mut self, who: PeerId);
|
||||
|
||||
/// Get peer info.
|
||||
fn peer_info(&self, peer: &PeerId) -> Option<ProtocolPeerInfo<B>>;
|
||||
|
||||
/// Request a finality proof from a peer.
|
||||
fn send_finality_proof_request(&mut self, who: PeerId, request: message::FinalityProofRequest<B::Hash>);
|
||||
|
||||
/// Request a block from a peer.
|
||||
fn send_block_request(&mut self, who: PeerId, request: message::BlockRequest<B>);
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub(crate) struct PeerSync<B: BlockT> {
|
||||
pub common_number: NumberFor<B>,
|
||||
|
||||
Reference in New Issue
Block a user