From 62a1a451359f1164c60f0ebffc7792f65ec370ca Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Mon, 25 Sep 2023 18:07:26 -0400 Subject: [PATCH] Move where we create the readers to prevent only creating readers for present-at-boot tributaries Also renames publish_transaction to publish_signed_transaction. --- coordinator/src/main.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/coordinator/src/main.rs b/coordinator/src/main.rs index ccc58c24..ec9651f4 100644 --- a/coordinator/src/main.rs +++ b/coordinator/src/main.rs @@ -300,12 +300,12 @@ pub async fn heartbeat_tributaries( let ten_blocks_of_time = Duration::from_secs((10 * Tributary::::block_time()).into()); - let mut readers = vec![]; - for tributary in tributaries.read().await.values() { - readers.push(tributary.tributary.read().await.reader()); - } - loop { + let mut readers = vec![]; + for tributary in tributaries.read().await.values() { + readers.push(tributary.tributary.read().await.reader()); + } + for tributary in &readers { let tip = tributary.tip(); let block_time = @@ -454,7 +454,7 @@ pub async fn handle_p2p( } } -pub async fn publish_transaction( +pub async fn publish_signed_transaction( tributary: &Tributary, tx: Transaction, ) { @@ -473,7 +473,7 @@ pub async fn publish_transaction( assert!(tributary.add_transaction(tx).await, "created an invalid transaction"); } } else { - panic!("non-signed transaction passed to publish_transaction"); + panic!("non-signed transaction passed to publish_signed_transaction"); } } @@ -781,7 +781,7 @@ pub async fn handle_processors( }; tx.sign(&mut OsRng, genesis, &key, nonce); - publish_transaction(&tributary, tx).await; + publish_signed_transaction(&tributary, tx).await; } } } @@ -867,7 +867,7 @@ pub async fn run( panic!("tributary we don't have came to consensus on an Batch"); }; let tributary = tributary.tributary.read().await; - publish_transaction(&tributary, tx).await; + publish_signed_transaction(&tributary, tx).await; } } };