@@ -129,8 +129,46 @@ where C::Target: chain::Access, L::Target: Logger {
129
129
/// Provides interface to help with initial routing sync by
130
130
/// serving historical announcements.
131
131
///
132
- /// An [`EventHandler`] decorator for applying updates from [`Event::PaymentFailed`] to the
133
- /// [`NetworkGraph`].
132
+ /// Serves as an [`EventHandler`] decorator for applying updates from [`Event::PaymentFailed`] to
133
+ /// the [`NetworkGraph`].
134
+ ///
135
+ /// # Example
136
+ ///
137
+ /// ```
138
+ /// # extern crate bitcoin;
139
+ /// #
140
+ /// # use bitcoin::blockdata::constants::genesis_block;
141
+ /// # use bitcoin::blockdata::transaction::TxOut;
142
+ /// # use bitcoin::hash_types::BlockHash;
143
+ /// # use bitcoin::network::constants::Network;
144
+ /// # use lightning::chain;
145
+ /// # use lightning::routing::network_graph::{NetGraphMsgHandler, NetworkGraph};
146
+ /// # use lightning::util::events::Event;
147
+ /// # use lightning::util::logger::{Logger, Record};
148
+ /// #
149
+ /// # struct NullLogger;
150
+ /// # impl Logger for NullLogger {
151
+ /// # fn log(&self, _record: &Record) {}
152
+ /// # }
153
+ /// # struct ChainSource;
154
+ /// # impl chain::Access for ChainSource {
155
+ /// # fn get_utxo(&self, _: &BlockHash, _: u64) -> Result<TxOut, chain::AccessError> {
156
+ /// # unimplemented!()
157
+ /// # }
158
+ /// # }
159
+ /// let network_graph = NetworkGraph::new(genesis_block(Network::Testnet).header.block_hash());
160
+ /// let chain_source = ChainSource {};
161
+ /// let logger = NullLogger {};
162
+ /// let event_handler = |event: &Event| {
163
+ /// // Handle event
164
+ /// };
165
+ /// let event_handler = NetGraphMsgHandler::new(network_graph, Some(&chain_source), &logger, event_handler);
166
+ /// ```
167
+ ///
168
+ /// Once `event_handler` has been decorated, use it with any implementation of [`EventsProvider`] as
169
+ /// usual.
170
+ ///
171
+ /// [`EventsProvider`]: crate::util::events::EventsProvider
134
172
pub struct NetGraphMsgHandler < C : Deref , L : Deref , E : EventHandler >
135
173
where C :: Target : chain:: Access , L :: Target : Logger
136
174
{
0 commit comments