Struct mutiny_core::scb::message_handler::SCBMessageHandler
source · pub struct SCBMessageHandler { /* private fields */ }Expand description
Custom message handler for Static Channel Backups.
This will send bogus channel reestablish messages to the peer, which will trigger the peer to close the channel on our behalf.
Implementations§
source§impl SCBMessageHandler
impl SCBMessageHandler
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new instance of a SCBMessageHandler
sourcepub fn request_channel_close(&self, node_id: PublicKey, channel_id: [u8; 32])
pub fn request_channel_close(&self, node_id: PublicKey, channel_id: [u8; 32])
Send a message to the peer with given node id. Note that the message is not
sent right away, but only when the LDK
lightning::ln::peer_handler::PeerManager::process_events is next called.
sourcepub fn has_pending_messages(&self) -> bool
pub fn has_pending_messages(&self) -> bool
Returns whether the message handler has any message to be sent.
Trait Implementations§
source§impl CustomMessageHandler for SCBMessageHandler
impl CustomMessageHandler for SCBMessageHandler
source§fn handle_custom_message(
&self,
_msg: ChannelReestablish,
_org: &PublicKey
) -> Result<(), LightningError>
fn handle_custom_message( &self, _msg: ChannelReestablish, _org: &PublicKey ) -> Result<(), LightningError>
Handles the given message sent from
sender_node_id, possibly producing messages for
CustomMessageHandler::get_and_clear_pending_msg to return and thus for PeerManager
to send.source§fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>
fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)>
Returns the list of pending messages that were generated by the handler, clearing the list
in the process. Each message is paired with the node id of the intended recipient. If no
connection to the node exists, then the message is simply not sent.
source§fn provided_node_features(&self) -> NodeFeatures
fn provided_node_features(&self) -> NodeFeatures
Gets the node feature flags which this handler itself supports. All available handlers are
queried similarly and their feature flags are OR’d together to form the
NodeFeatures
which are broadcasted in our NodeAnnouncement message.source§fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures
fn provided_init_features(&self, _their_node_id: &PublicKey) -> InitFeatures
Gets the init feature flags which should be sent to the given peer. All available handlers
are queried similarly and their feature flags are OR’d together to form the
InitFeatures
which are sent in our Init message.source§impl CustomMessageReader for SCBMessageHandler
impl CustomMessageReader for SCBMessageHandler
Dummy implementation of CustomMessageReader for SCBMessageHandler.
We are just sending ChannelReestablish messages, which are not
custom messages, but we need to implement this trait to be able to use
the CustomMessageHandler trait.
§type CustomMessage = ChannelReestablish
type CustomMessage = ChannelReestablish
The type of the message decoded by the implementation.
source§fn read<R: Read>(
&self,
_msg_type: u16,
_buffer: &mut R
) -> Result<Option<Self::CustomMessage>, DecodeError>
fn read<R: Read>( &self, _msg_type: u16, _buffer: &mut R ) -> Result<Option<Self::CustomMessage>, DecodeError>
Decodes a custom message to
CustomMessageType. If the given message type is known to the
implementation and the message could be decoded, must return Ok(Some(message)). If the
message type is unknown to the implementation, must return Ok(None). If a decoding error
occur, must return Err(DecodeError::X) where X details the encountered error.Auto Trait Implementations§
impl !RefUnwindSafe for SCBMessageHandler
impl Send for SCBMessageHandler
impl Sync for SCBMessageHandler
impl Unpin for SCBMessageHandler
impl UnwindSafe for SCBMessageHandler
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more