Skip to content

Commit ca5ecb6

Browse files
committed
backend: Extra debug
Signed-off-by: Alexandru Vasile <[email protected]>
1 parent 786ed39 commit ca5ecb6

File tree

1 file changed

+17
-1
lines changed
  • subxt/src/backend/unstable

1 file changed

+17
-1
lines changed

subxt/src/backend/unstable/mod.rs

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,12 +477,18 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
477477
let mut iter_num = 0;
478478
let now = std::time::Instant::now();
479479

480+
let mut tx_logs = Vec::with_capacity(32);
481+
let mut chainhead_logs = Vec::with_capacity(32);
482+
480483
// Now we can attempt to associate tx events with pinned blocks.
481484
let tx_stream = futures::stream::poll_fn(move |cx| {
482485
loop {
483486
iter_num += 1;
484487
if now.elapsed().as_secs() > 120 {
485-
panic!("iter={:#?}", iter_num);
488+
panic!(
489+
"iter_num: {}, tx_logs: {:#?}, chainhead_logs: {:#?}",
490+
iter_num, tx_logs, chainhead_logs
491+
);
486492
}
487493

488494
// Bail early if no more tx events; we don't want to keep polling for pinned blocks.
@@ -494,6 +500,8 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
494500
if let Poll::Ready(Some(seen_block)) = seen_blocks_sub.poll_next_unpin(cx) {
495501
match seen_block {
496502
SeenBlock::New(block_ref) => {
503+
chainhead_logs.push((now.elapsed().as_secs(), "new", block_ref.hash()));
504+
497505
// Optimization: once we have a `finalized_hash`, we only care about finalized
498506
// block refs now and can avoid bothering to save new blocks.
499507
if finalized_hash.is_none() {
@@ -503,6 +511,12 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
503511
}
504512
SeenBlock::Finalized(block_refs) => {
505513
for block_ref in block_refs {
514+
chainhead_logs.push((
515+
now.elapsed().as_secs(),
516+
"finalized",
517+
block_ref.hash(),
518+
));
519+
506520
seen_blocks.insert(
507521
block_ref.hash(),
508522
(SeenBlockMarker::Finalized, block_ref),
@@ -543,6 +557,8 @@ impl<T: Config + Send + Sync + 'static> Backend<T> for UnstableBackend<T> {
543557
Poll::Ready(Some(Ok(ev))) => ev,
544558
};
545559

560+
tx_logs.push((now.elapsed().as_secs(), ev.clone()));
561+
546562
// When we get one, map it to the correct format (or for finalized ev, wait for the pinned block):
547563
let ev = match ev {
548564
rpc_methods::TransactionStatus::Finalized { block } => {

0 commit comments

Comments
 (0)