MCPcopy Create free account
hub / github.com/BitVM/BitVM / fund_input_with_retry

Method fund_input_with_retry

bridge/tests/bridge/faucet.rs:113–151  ·  view source on GitHub ↗
(&self, address: &Address, amount: Amount)

Source from the content-addressed store, hash-verified

111 }
112
113 async fn fund_input_with_retry(&self, address: &Address, amount: Amount) -> Txid {
114 let client_err_handler = |e: Error| {
115 panic!("Could not fund {} due to {:?}", address, e);
116 };
117 let mut resp = self
118 ._fund_input(address, amount)
119 .await
120 .unwrap_or_else(client_err_handler);
121
122 let mut retry = 0;
123 while resp.status().eq(&StatusCode::SERVICE_UNAVAILABLE) && retry <= ESPLORA_RETRIES {
124 retry += 1;
125 eprintln!("Retrying({}/{}) {:?}...", retry, ESPLORA_RETRIES, address);
126 sleep(Duration::from_millis(Self::get_random_millis(
127 ESPLORA_RETRY_WAIT_TIME * 1000,
128 ESPLORA_RETRY_WAIT_TIME * 10000,
129 )))
130 .await;
131 // sleep(Duration::from_secs(ESPLORA_RETRY_WAIT_TIME)).await;
132 resp = self
133 ._fund_input(address, amount)
134 .await
135 .unwrap_or_else(client_err_handler);
136 }
137
138 if resp.status().is_client_error() || resp.status().is_server_error() {
139 panic!(
140 "Could not fund {} with respond code {:?}, response: {:?}",
141 address,
142 resp.status(),
143 resp.text().await,
144 );
145 }
146
147 let result = resp.json::<FundResult>().await.unwrap();
148 println!("Funded at: {}", result.txid);
149
150 result.txid
151 }
152
153 async fn _fund_input(&self, address: &Address, amount: Amount) -> Result<Response, Error> {
154 let payload = format!(

Callers 2

fund_inputMethod · 0.80
fund_inputsMethod · 0.80

Calls 2

_fund_inputMethod · 0.80
statusMethod · 0.80

Tested by

no test coverage detected