This commit is contained in:
2026-06-05 14:53:16 +02:00
parent 27e25d5bf4
commit f81e0f3bea
66 changed files with 7655 additions and 214 deletions

View File

@@ -1153,6 +1153,22 @@ pub(crate) struct DemoPipeline2BackfillSignatureRequest {
pub http_role: std::option::Option<std::string::String>,
}
/// Request payload for batch signature backfill.
#[derive(Clone, Debug, serde::Deserialize, TS)]
#[ts(
export,
export_to = "../frontend/ts/bindings/DemoPipeline2BackfillSignaturesBatchRequest.ts"
)]
#[serde(rename_all = "camelCase")]
pub(crate) struct DemoPipeline2BackfillSignaturesBatchRequest {
/// Transaction signatures to resolve and replay.
pub signatures: std::vec::Vec<std::string::String>,
/// Optional HTTP role.
pub http_role: std::option::Option<std::string::String>,
/// Whether the batch should continue after a hard per-signature error.
pub continue_on_error: bool,
}
/// Shared backfill response payload.
#[derive(Clone, Debug, serde::Serialize, TS)]
#[ts(export, export_to = "../frontend/ts/bindings/DemoPipeline2BackfillPayload.ts")]
@@ -1604,6 +1620,63 @@ pub(crate) async fn demo_pipeline2_backfill_signature(
})
}
/// Runs a targeted batch signature backfill then returns the refreshed catalog.
#[tauri::command]
pub(crate) async fn demo_pipeline2_backfill_signatures_batch(
state: tauri::State<'_, crate::AppState>,
request: DemoPipeline2BackfillSignaturesBatchRequest,
) -> Result<DemoPipeline2BackfillPayload, std::string::String> {
let mut signatures = std::vec::Vec::<std::string::String>::new();
for signature in request.signatures {
let trimmed_signature = signature.trim().to_string();
if trimmed_signature.is_empty() {
continue;
}
signatures.push(trimmed_signature);
}
if signatures.is_empty() {
return Err("signature batch must contain at least one signature".to_string());
}
let http_role = demo_pipeline2_normalize_http_role(request.http_role);
let database = state.database.clone();
let http_pool = std::sync::Arc::new(state.http_pool.clone());
let service = kb_lib::TokenBackfillService::new(http_pool, database.clone(), http_role.clone());
let result = service
.backfill_signatures(signatures.as_slice(), request.continue_on_error)
.await;
let backfill = match result {
Ok(backfill) => backfill,
Err(error) => {
return Err(format!(
"cannot backfill signature batch with role '{}': {}",
http_role, error
));
},
};
let summary_json_result = serde_json::to_string_pretty(&backfill);
let summary_json = match summary_json_result {
Ok(summary_json) => summary_json,
Err(error) => {
return Err(format!(
"cannot serialize signature batch backfill result: {}",
error
));
},
};
let catalog_result = demo_pipeline2_build_catalog(database).await;
let catalog = match catalog_result {
Ok(catalog) => catalog,
Err(error) => return Err(error),
};
Ok(DemoPipeline2BackfillPayload {
object_key: format!("{} signatures", backfill.unique_signature_count),
mode: "signatureBatch".to_string(),
http_role,
summary_json,
catalog,
})
}
/// Loads candles for one pair and one timeframe.
#[tauri::command]
pub(crate) async fn demo_pipeline2_get_pair_candles(
@@ -1783,6 +1856,7 @@ pub(crate) async fn demo_pipeline2_replay_local_pipeline(
token_metadata_limit: std::option::Option<i64>,
skip_certified_dex_decode: bool,
force_decode_replay: bool,
defer_instruction_observation_index_refresh: bool,
) -> Result<kb_lib::LocalPipelineReplayResult, std::string::String> {
let config = kb_lib::LocalPipelineReplayConfig {
limit,
@@ -1791,6 +1865,7 @@ pub(crate) async fn demo_pipeline2_replay_local_pipeline(
reset_market_materialization_before_replay: true,
skip_certified_dex_decode,
force_decode_replay,
defer_instruction_observation_index_refresh,
};
let database = state.database.clone();
let service = if refresh_missing_token_metadata {

View File

@@ -158,6 +158,7 @@ pub async fn run() -> Result<(), kb_lib::Error> {
crate::demo_pipeline2::demo_pipeline2_backfill_token_mint,
crate::demo_pipeline2::demo_pipeline2_backfill_pool_address,
crate::demo_pipeline2::demo_pipeline2_backfill_signature,
crate::demo_pipeline2::demo_pipeline2_backfill_signatures_batch,
crate::demo_pipeline2::demo_pipeline2_get_pair_candles,
crate::demo_pipeline2::demo_pipeline2_replay_local_pipeline,
crate::demo_pipeline2::demo_pipeline2_diagnose_local_pipeline,