[][src]Trait ckb_network::CKBProtocolContext

pub trait CKBProtocolContext: Send {
    pub fn set_notify(
        &self,
        interval: Duration,
        token: u64
    ) -> Result<(), Error>;
pub fn remove_notify(&self, token: u64) -> Result<(), Error>;
pub fn quick_send_message(
        &self,
        proto_id: ProtocolId,
        peer_index: PeerIndex,
        data: Bytes
    ) -> Result<(), Error>;
pub fn quick_send_message_to(
        &self,
        peer_index: PeerIndex,
        data: Bytes
    ) -> Result<(), Error>;
pub fn quick_filter_broadcast(
        &self,
        target: TargetSession,
        data: Bytes
    ) -> Result<(), Error>;
pub fn future_task(
        &self,
        task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
        blocking: bool
    ) -> Result<(), Error>;
pub fn send_message(
        &self,
        proto_id: ProtocolId,
        peer_index: PeerIndex,
        data: Bytes
    ) -> Result<(), Error>;
pub fn send_message_to(
        &self,
        peer_index: PeerIndex,
        data: Bytes
    ) -> Result<(), Error>;
pub fn filter_broadcast(
        &self,
        target: TargetSession,
        data: Bytes
    ) -> Result<(), Error>;
pub fn disconnect(
        &self,
        peer_index: PeerIndex,
        message: &str
    ) -> Result<(), Error>;
pub fn get_peer(&self, peer_index: PeerIndex) -> Option<Peer>;
pub fn with_peer_mut(
        &self,
        peer_index: PeerIndex,
        f: Box<dyn FnOnce(&mut Peer)>
    );
pub fn connected_peers(&self) -> Vec<PeerIndex>;
pub fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour);
pub fn ban_peer(
        &self,
        peer_index: PeerIndex,
        duration: Duration,
        reason: String
    );
pub fn send_paused(&self) -> bool;
pub fn protocol_id(&self) -> ProtocolId; pub fn p2p_control(&self) -> Option<&ServiceControl> { ... } }

Abstract protocol context

Required methods

pub fn set_notify(&self, interval: Duration, token: u64) -> Result<(), Error>[src]

Set notify to tentacle

pub fn remove_notify(&self, token: u64) -> Result<(), Error>[src]

Remove notify

pub fn quick_send_message(
    &self,
    proto_id: ProtocolId,
    peer_index: PeerIndex,
    data: Bytes
) -> Result<(), Error>
[src]

Send message through quick queue

pub fn quick_send_message_to(
    &self,
    peer_index: PeerIndex,
    data: Bytes
) -> Result<(), Error>
[src]

Send message through quick queue

pub fn quick_filter_broadcast(
    &self,
    target: TargetSession,
    data: Bytes
) -> Result<(), Error>
[src]

Filter broadcast message through quick queue

pub fn future_task(
    &self,
    task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
    blocking: bool
) -> Result<(), Error>
[src]

spawn a future task, if blocking is true we use tokio_threadpool::blocking to handle the task.

pub fn send_message(
    &self,
    proto_id: ProtocolId,
    peer_index: PeerIndex,
    data: Bytes
) -> Result<(), Error>
[src]

Send message

pub fn send_message_to(
    &self,
    peer_index: PeerIndex,
    data: Bytes
) -> Result<(), Error>
[src]

Send message

pub fn filter_broadcast(
    &self,
    target: TargetSession,
    data: Bytes
) -> Result<(), Error>
[src]

Filter broadcast message

pub fn disconnect(
    &self,
    peer_index: PeerIndex,
    message: &str
) -> Result<(), Error>
[src]

Disconnect session

pub fn get_peer(&self, peer_index: PeerIndex) -> Option<Peer>[src]

Get peer info

pub fn with_peer_mut(
    &self,
    peer_index: PeerIndex,
    f: Box<dyn FnOnce(&mut Peer)>
)
[src]

Modify peer info

pub fn connected_peers(&self) -> Vec<PeerIndex>[src]

Get all session id

pub fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)[src]

Report peer behavior

pub fn ban_peer(
    &self,
    peer_index: PeerIndex,
    duration: Duration,
    reason: String
)
[src]

Ban peer

pub fn send_paused(&self) -> bool[src]

Can send message again?

pub fn protocol_id(&self) -> ProtocolId[src]

current protocol id

Loading content...

Provided methods

pub fn p2p_control(&self) -> Option<&ServiceControl>[src]

Raw tentacle controller

Loading content...

Implementors

Loading content...