//! `Foo` and `Bar` messages, and further composing it with a handler for `Baz` messages.
//!
//!```
+//! # fn main() {} // Avoid #[macro_export] generating an in-function warning
//! # extern crate bitcoin;
//! extern crate lightning;
//! #[macro_use]
//!
//! # use bitcoin::secp256k1::PublicKey;
//! # use lightning::io;
-//! # use lightning::ln::msgs::{DecodeError, LightningError};
+//! # use lightning::ln::msgs::{DecodeError, Init, LightningError};
//! # use lightning::ln::features::{InitFeatures, NodeFeatures};
//! use lightning::ln::peer_handler::CustomMessageHandler;
//! use lightning::ln::wire::{CustomMessageReader, self};
//! # fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> {
//! # unimplemented!()
//! # }
+//! # fn peer_disconnected(&self, _their_node_id: &PublicKey) {
+//! # unimplemented!()
+//! # }
+//! # fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
+//! # unimplemented!()
+//! # }
//! # fn provided_node_features(&self) -> NodeFeatures {
//! # unimplemented!()
//! # }
//! # fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> {
//! # unimplemented!()
//! # }
+//! # fn peer_disconnected(&self, _their_node_id: &PublicKey) {
+//! # unimplemented!()
+//! # }
+//! # fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
+//! # unimplemented!()
+//! # }
//! # fn provided_node_features(&self) -> NodeFeatures {
//! # unimplemented!()
//! # }
//! # fn get_and_clear_pending_msg(&self) -> Vec<(PublicKey, Self::CustomMessage)> {
//! # unimplemented!()
//! # }
+//! # fn peer_disconnected(&self, _their_node_id: &PublicKey) {
+//! # unimplemented!()
+//! # }
+//! # fn peer_connected(&self, _their_node_id: &PublicKey, _msg: &Init, _inbound: bool) -> Result<(), ()> {
+//! # unimplemented!()
+//! # }
//! # fn provided_node_features(&self) -> NodeFeatures {
//! # unimplemented!()
//! # }
//! # }
//! }
//!
-//! # fn main() {
//! // The first crate may define a handler composing `FooHandler` and `BarHandler` and export the
//! // corresponding message type ids as a macro to use in further composition.
//!
//! macro_rules! foo_bar_baz_type_ids {
//! () => { foo_bar_type_ids!() | baz_type_id!() }
//! }
-//! # }
//!```
//!
//! [BOLT 1]: https://github.com/lightning/bolts/blob/master/01-messaging.md
.collect()
}
+ fn peer_disconnected(&self, their_node_id: &$crate::bitcoin::secp256k1::PublicKey) {
+ $(
+ self.$field.peer_disconnected(their_node_id);
+ )*
+ }
+
+ fn peer_connected(&self, their_node_id: &$crate::bitcoin::secp256k1::PublicKey, msg: &$crate::lightning::ln::msgs::Init, inbound: bool) -> Result<(), ()> {
+ let mut result = Ok(());
+ $(
+ if let Err(e) = self.$field.peer_connected(their_node_id, msg, inbound) {
+ result = Err(e);
+ }
+ )*
+ result
+ }
+
fn provided_node_features(&self) -> $crate::lightning::ln::features::NodeFeatures {
$crate::lightning::ln::features::NodeFeatures::empty()
$(