Peer

pub struct Peer {
    pub info: PeerInfo,
    state: Arc<RwLock<State>>,
    // set of all hashes known to this peer (so no need to send)
    tracking_adapter: TrackingAdapter,
    connection: Option<conn::Tracker>,
}

TrackingAdapter

/// Adapter implementation that forwards everything to an underlying adapter
/// but keeps track of the block and transaction hashes that were received.
#[derive(Clone)]
struct TrackingAdapter {
    adapter: Arc<NetAdapter>,
    known: Arc<RwLock<Vec<Hash>>>,
}

主要工作由它封装的 NetAdapter 完成。

PeerInfo

/// General information about a connected peer that's useful to other modules.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct PeerInfo {
    pub capabilities: Capabilities,
    pub user_agent: String,
    pub version: u32,
    pub addr: SocketAddr,
    pub total_difficulty: Difficulty,
    pub height: u64,
    pub direction: Direction,
}

PeerData

/// Data stored for any given peer we've encountered.
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct PeerData {
    /// Network address of the peer.
    pub addr: SocketAddr,
    /// What capabilities the peer advertises. Unknown until a successful
    /// connection.
    pub capabilities: Capabilities,
    /// The peer user agent.
    pub user_agent: String,
    /// State the peer has been detected with.
    pub flags: State,
    /// The time the peer was last banned
    pub last_banned: i64,
    /// The reason for the ban
    pub ban_reason: ReasonForBan,
    /// Time when we last connected to this peer.
    pub last_connected: i64,
}

PeerStore

/// Storage facility for peer data.
pub struct PeerStore {
    db: grin_store::Store,
}

results matching ""

    No results matching ""