pub fn spv(spv_cmd: &Value, api_host: &str) -> ValueExamples found in repository?
examples/crosschain.rs (line 223)
219fn poll_for_spv_proof(spv_cmd: &serde_json::Value, api_host: &str, max_attempts: u32, interval_seconds: u64) -> serde_json::Value {
220 for attempt in 1..=max_attempts {
221 println!("SPV proof attempt {}/{}", attempt, max_attempts);
222
223 let spv_result = fetch::spv(spv_cmd, api_host);
224
225 // Log diagnostic hints when no proof
226 if !has_spv_proof(&spv_result) {
227 if let Some(err) = spv_result.get("error") {
228 println!("(diagnostic) SPV response error field: {}", err);
229 } else if spv_result.as_object().map(|o| o.is_empty()).unwrap_or(true) {
230 println!("(diagnostic) Empty SPV response – likely not yet indexed. Waiting...");
231 } else {
232 println!("(diagnostic) SPV response keys: {:?}", spv_result.as_object().map(|o| o.keys().collect::<Vec<_>>()));
233 }
234 }
235
236 // Check if we got a valid SPV proof
237 if has_spv_proof(&spv_result) {
238 println!("✓ SPV proof obtained!");
239 return spv_result;
240 }
241
242 if attempt < max_attempts {
243 println!("SPV proof not ready, waiting {} seconds...", interval_seconds);
244 thread::sleep(Duration::from_secs(interval_seconds));
245 }
246 }
247
248 println!("⚠️ SPV proof polling timeout after {} attempts", max_attempts);
249 json!({})
250}