|
15 | 15 | use std::collections::HashMap;
|
16 | 16 | use std::fmt::Debug;
|
17 | 17 | use std::sync::mpsc::Sender;
|
| 18 | +use std::time::{Duration, Instant}; |
18 | 19 |
|
19 | 20 | use blockstack_lib::chainstate::nakamoto::{NakamotoBlock, NakamotoBlockHeader};
|
20 | 21 | use blockstack_lib::net::api::postblock_proposal::{
|
@@ -185,27 +186,25 @@ impl SignerTrait<SignerMessage> for Signer {
|
185 | 186 | );
|
186 | 187 | }
|
187 | 188 | SignerMessage::BlockPushed(b) => {
|
188 |
| - let block_push_result = stacks_client.post_block(b); |
189 |
| - if let Err(ref e) = &block_push_result { |
190 |
| - warn!( |
191 |
| - "{self}: Failed to post block {} (id {}): {e:?}", |
192 |
| - &b.header.signer_signature_hash(), |
193 |
| - &b.block_id() |
194 |
| - ); |
195 |
| - }; |
196 | 189 | // This will infinitely loop until the block is acknowledged by the node
|
197 | 190 | info!(
|
198 | 191 | "{self}: Got block pushed message";
|
199 | 192 | "block_id" => %b.block_id(),
|
200 | 193 | "signer_sighash" => %b.header.signer_signature_hash(),
|
201 | 194 | );
|
| 195 | + let start_time = Instant::now(); |
202 | 196 | loop {
|
203 | 197 | match stacks_client.post_block(b) {
|
204 | 198 | Ok(block_push_result) => {
|
205 | 199 | debug!("{self}: Block pushed to stacks node: {block_push_result:?}");
|
206 | 200 | break;
|
207 | 201 | }
|
208 | 202 | Err(e) => {
|
| 203 | + if cfg!(test) |
| 204 | + && start_time.elapsed() > Duration::from_secs(30) |
| 205 | + { |
| 206 | + panic!("{self}: Timed out in test while pushing block to stacks node: {e}"); |
| 207 | + } |
209 | 208 | warn!("{self}: Failed to push block to stacks node: {e}. Retrying...");
|
210 | 209 | }
|
211 | 210 | };
|
|
0 commit comments