Skip to content

Commit

Permalink
note
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Nov 29, 2024
1 parent 186dbcf commit 813cbce
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions lib/ain-ocean/src/indexer/oracle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,16 +385,20 @@ fn index_set_oracle_data(
token.clone(),
currency.clone(),
);
let prev_price = price_repo
.by_id
.list(Some(id.clone()), SortOrder::Descending)?
.find(|item| match item {
Ok(((_, _, t, c), _)) => t == &token && c == &currency,
_ => true,
})
.transpose()?;
if let Some((k, _)) = prev_price {
price_repo.by_id.delete(&k)?
// NOTE(canonbrother): rocksdb sort by key by default
// temp solution: clean up extra data to allow limit by `token-currency` but sort by `count-height-token-currency`
{
let prev_price = price_repo
.by_id
.list(Some(id.clone()), SortOrder::Descending)?
.find(|item| match item {
Ok(((_, _, t, c), _)) => t == &token && c == &currency,
_ => true,
})
.transpose()?;
if let Some((k, _)) = prev_price {
price_repo.by_id.delete(&k)?
}
}
price_repo.by_id.put(
&id,
Expand Down

0 comments on commit 813cbce

Please sign in to comment.