backend: Memory log after 120s timeout

Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
Alexandru Vasile
2023-12-12 16:36:33 +02:00
parent 99bbe8db03
commit 02bd1a2b17
+10
View File
@@ -474,9 +474,17 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
// with chainHead_follow. // with chainHead_follow.
let mut finalized_hash: Option<T::Hash> = None; let mut finalized_hash: Option<T::Hash> = None;
let now = std::time::Instant::now();
let mut mem_log = vec![];
// Now we can attempt to associate tx events with pinned blocks. // Now we can attempt to associate tx events with pinned blocks.
let tx_stream = futures::stream::poll_fn(move |cx| { let tx_stream = futures::stream::poll_fn(move |cx| {
loop { loop {
if now.elapsed().as_secs() > 120 {
println!("Log stream: {:?}", mem_log);
panic!("{:?}", mem_log);
}
// Bail early if no more tx events; we don't want to keep polling for pinned blocks. // Bail early if no more tx events; we don't want to keep polling for pinned blocks.
if done { if done {
return Poll::Ready(None); return Poll::Ready(None);
@@ -535,6 +543,8 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
Poll::Ready(Some(Ok(ev))) => ev, Poll::Ready(Some(Ok(ev))) => ev,
}; };
mem_log.push((now.elapsed(), ev.clone()));
// When we get one, map it to the correct format (or for finalized ev, wait for the pinned block): // When we get one, map it to the correct format (or for finalized ev, wait for the pinned block):
let ev = match ev { let ev = match ev {
rpc_methods::TransactionStatus::Finalized { block } => { rpc_methods::TransactionStatus::Finalized { block } => {