fix: don't mark unfetched txns as processed

This commit is contained in:
dboures 2023-06-08 22:19:53 -05:00
parent 67b3583ba6
commit 4ba8fd5ec5
No known key found for this signature in database
GPG Key ID: AB3790129D478852
2 changed files with 9 additions and 6 deletions

View File

@ -15,10 +15,11 @@ const PROGRAM_DATA: &str = "Program data: ";
pub fn parse_trades_from_openbook_txns(
txns: &mut Vec<ClientResult<EncodedConfirmedTransactionWithStatusMeta>>,
sig_strings: &Vec<String>,
mut sig_strings: Vec<String>,
target_markets: &HashMap<Pubkey, String>,
) -> Vec<OpenBookFillEvent> {
) -> (Vec<OpenBookFillEvent>, Vec<String>) {
let mut fills_vector = Vec::<OpenBookFillEvent>::new();
let mut failed_sigs = vec![];
for (idx, txn) in txns.iter_mut().enumerate() {
match txn {
Ok(t) => {
@ -42,13 +43,15 @@ pub fn parse_trades_from_openbook_txns(
}
Err(e) => {
warn!("rpc error in get_transaction {}", e);
failed_sigs.push(sig_strings[idx].clone());
METRIC_RPC_ERRORS_TOTAL
.with_label_values(&["getTransaction"])
.inc();
}
}
}
fills_vector
sig_strings.retain(|s| !failed_sigs.contains(&s));
(fills_vector, sig_strings)
}
fn parse_openbook_fills_from_logs(

View File

@ -111,10 +111,10 @@ pub async fn scrape_fills(
let mut txns = join_all(txn_futs).await;
// TODO: reenable total fills metric
let fills = parse_trades_from_openbook_txns(&mut txns, &sig_strings, target_markets);
let (fills, completed_sigs) = parse_trades_from_openbook_txns(&mut txns, sig_strings, target_markets);
// Write any fills to the database, and update the transactions as processed
insert_fills_atomically(pool, worker_id, fills, sig_strings).await?;
// Write fills to the database, and update properly fetched transactions as processed
insert_fills_atomically(pool, worker_id, fills, completed_sigs).await?;
}
Ok(())