pub trait CKBProtocolContext: Send {
Show 26 methods
// Required methods
fn set_notify<'life0, 'async_trait>(
&'life0 self,
interval: Duration,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn remove_notify<'life0, 'async_trait>(
&'life0 self,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_quick_send_message<'life0, 'async_trait>(
&'life0 self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_quick_send_message_to<'life0, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_quick_filter_broadcast<'life0, 'async_trait>(
&'life0 self,
target: TargetSession,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_future_task<'life0, 'async_trait>(
&'life0 self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_send_message<'life0, 'async_trait>(
&'life0 self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_send_message_to<'life0, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_filter_broadcast<'life0, 'async_trait>(
&'life0 self,
target: TargetSession,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn async_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
fn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>;
fn quick_send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>;
fn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes,
) -> Result<(), Error>;
fn future_task(
&self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool,
) -> Result<(), Error>;
fn send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>;
fn send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>;
fn filter_broadcast(
&self,
target: TargetSession,
data: Bytes,
) -> Result<(), Error>;
fn disconnect(
&self,
peer_index: PeerIndex,
message: &str,
) -> Result<(), Error>;
fn get_peer(&self, peer_index: PeerIndex) -> Option<Peer>;
fn with_peer_mut(
&self,
peer_index: PeerIndex,
f: Box<dyn FnOnce(&mut Peer)>,
);
fn connected_peers(&self) -> Vec<PeerIndex> ⓘ;
fn full_relay_connected_peers(&self) -> Vec<PeerIndex> ⓘ;
fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour);
fn ban_peer(
&self,
peer_index: PeerIndex,
duration: Duration,
reason: String,
);
fn protocol_id(&self) -> ProtocolId;
// Provided method
fn p2p_control(&self) -> Option<&ServiceControl> { ... }
}Expand description
Abstract protocol context
Required Methods§
Sourcefn set_notify<'life0, 'async_trait>(
&'life0 self,
interval: Duration,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn set_notify<'life0, 'async_trait>(
&'life0 self,
interval: Duration,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Set notify to tentacle
Sourcefn remove_notify<'life0, 'async_trait>(
&'life0 self,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn remove_notify<'life0, 'async_trait>(
&'life0 self,
token: u64,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Remove notify
Sourcefn async_quick_send_message<'life0, 'async_trait>(
&'life0 self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_quick_send_message<'life0, 'async_trait>(
&'life0 self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send message through quick queue
Sourcefn async_quick_send_message_to<'life0, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_quick_send_message_to<'life0, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send message through quick queue
Sourcefn async_quick_filter_broadcast<'life0, 'async_trait>(
&'life0 self,
target: TargetSession,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_quick_filter_broadcast<'life0, 'async_trait>(
&'life0 self,
target: TargetSession,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Filter broadcast message through quick queue
Sourcefn async_future_task<'life0, 'async_trait>(
&'life0 self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_future_task<'life0, 'async_trait>(
&'life0 self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
spawn a future task, if blocking is true we use tokio_threadpool::blocking to handle the task.
Sourcefn async_send_message<'life0, 'async_trait>(
&'life0 self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_send_message<'life0, 'async_trait>(
&'life0 self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send message
Sourcefn async_send_message_to<'life0, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_send_message_to<'life0, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Send message
Sourcefn async_filter_broadcast<'life0, 'async_trait>(
&'life0 self,
target: TargetSession,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn async_filter_broadcast<'life0, 'async_trait>(
&'life0 self,
target: TargetSession,
data: Bytes,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Filter broadcast message
Sourcefn async_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn async_disconnect<'life0, 'life1, 'async_trait>(
&'life0 self,
peer_index: PeerIndex,
message: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Disconnect session
Sourcefn quick_send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>
fn quick_send_message( &self, proto_id: ProtocolId, peer_index: PeerIndex, data: Bytes, ) -> Result<(), Error>
Send message through quick queue
Sourcefn quick_send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>
fn quick_send_message_to( &self, peer_index: PeerIndex, data: Bytes, ) -> Result<(), Error>
Send message through quick queue
Sourcefn quick_filter_broadcast(
&self,
target: TargetSession,
data: Bytes,
) -> Result<(), Error>
fn quick_filter_broadcast( &self, target: TargetSession, data: Bytes, ) -> Result<(), Error>
Filter broadcast message through quick queue
Sourcefn future_task(
&self,
task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>,
blocking: bool,
) -> Result<(), Error>
fn future_task( &self, task: Pin<Box<dyn Future<Output = ()> + Send + 'static>>, blocking: bool, ) -> Result<(), Error>
spawn a future task, if blocking is true we use tokio_threadpool::blocking to handle the task.
Sourcefn send_message(
&self,
proto_id: ProtocolId,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>
fn send_message( &self, proto_id: ProtocolId, peer_index: PeerIndex, data: Bytes, ) -> Result<(), Error>
Send message
Sourcefn send_message_to(
&self,
peer_index: PeerIndex,
data: Bytes,
) -> Result<(), Error>
fn send_message_to( &self, peer_index: PeerIndex, data: Bytes, ) -> Result<(), Error>
Send message
Sourcefn filter_broadcast(
&self,
target: TargetSession,
data: Bytes,
) -> Result<(), Error>
fn filter_broadcast( &self, target: TargetSession, data: Bytes, ) -> Result<(), Error>
Filter broadcast message
Sourcefn disconnect(&self, peer_index: PeerIndex, message: &str) -> Result<(), Error>
fn disconnect(&self, peer_index: PeerIndex, message: &str) -> Result<(), Error>
Disconnect session
Sourcefn connected_peers(&self) -> Vec<PeerIndex> ⓘ
fn connected_peers(&self) -> Vec<PeerIndex> ⓘ
Get all session id
Sourcefn full_relay_connected_peers(&self) -> Vec<PeerIndex> ⓘ
fn full_relay_connected_peers(&self) -> Vec<PeerIndex> ⓘ
Get all full_relay (exclude block-relay-only) id
Sourcefn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)
fn report_peer(&self, peer_index: PeerIndex, behaviour: Behaviour)
Report peer behavior
Sourcefn protocol_id(&self) -> ProtocolId
fn protocol_id(&self) -> ProtocolId
current protocol id
Provided Methods§
Sourcefn p2p_control(&self) -> Option<&ServiceControl>
fn p2p_control(&self) -> Option<&ServiceControl>
Raw tentacle controller