MCPcopy Create free account
hub / github.com/ElementsProject/lightning / poll_next

Method poll_next

cln-grpc/src/server.rs:47–79  ·  view source on GitHub ↗
(mut self: Pin<&mut Self>, cx: &mut Context<'_>)

Source from the content-addressed store, hash-verified

45 type Item = Result<T, tonic::Status>;
46
47 fn poll_next(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
48 while let Poll::Ready(result) = self.inner.as_mut().poll_next(cx) {
49 // None is used here to signal that we have reached the end of stream
50 // If inner ends the stream by returning None we do the same
51 if result.is_none() {
52 return Poll::Ready(None)
53 }
54 let result: Result<cln_rpc::Notification, BroadcastStreamRecvError> = result.unwrap();
55
56 match result {
57 Err(BroadcastStreamRecvError::Lagged(lag)) => {
58 // In this error case we've missed some notifications
59 // We log the error to core lightning and forward
60 // this information to the client
61 log::warn!("Due to lag the grpc-server skipped {} notifications", lag);
62 return Poll::Ready(Some(Err(
63 Status::data_loss(
64 format!("Skipped up to {} notifications", lag)))))
65 }
66 Ok(notification) => {
67 let filtered = (self.fn_filter_map)(notification);
68 match filtered {
69 Some(n) => return Poll::Ready(Some(Ok(n))),
70 None => {
71 // We ignore the message if it isn't a match.
72 // e.g: A `ChannelOpenedStream` will ignore `CustomMsgNotifications`
73 }
74 }
75 }
76 }
77 }
78 Poll::Pending
79 }
80}
81
82#[tonic::async_trait]

Callers

nothing calls this directly

Calls 1

unwrapMethod · 0.45

Tested by

no test coverage detected