Skip to content

Commit

Permalink
view: don't record invalid and corrupted Metadata (#4453)
Browse files Browse the repository at this point in the history
  • Loading branch information
hdevalence authored May 24, 2024
1 parent 53f9474 commit 975ad7d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 25 deletions.
19 changes: 0 additions & 19 deletions crates/view/src/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,25 +1146,6 @@ impl Storage {
.await?
}

pub async fn record_unknown_asset(&self, id: asset::Id) -> anyhow::Result<()> {
let asset_id = id.to_bytes().to_vec();
let denom = "Unknown".to_string();

let pool = self.pool.clone();

spawn_blocking(move || {
pool.get()?
.execute(
"INSERT OR IGNORE INTO assets (asset_id, denom) VALUES (?1, ?2)",
(asset_id, denom),
)
.map_err(anyhow::Error::from)
})
.await??;

Ok(())
}

pub async fn record_position(&self, position: Position) -> anyhow::Result<()> {
let position_id = position.id().0.to_vec();

Expand Down
7 changes: 1 addition & 6 deletions crates/view/src/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,12 +399,7 @@ impl Worker {
.record_asset(denom_metadata.try_into()?)
.await?;
} else {
// Otherwise we are dealing with an unknown/novel asset ID, but we don't have the original raw denom field naming the asset.
// For now, we can just record the asset ID with the denom value as "Unknown".

self.storage
.record_unknown_asset(note_record.note.asset_id())
.await?;
tracing::warn!(asset_id = ?note_record.note.asset_id(), "received unknown asset ID with no available metadata");
}
}
}
Expand Down

0 comments on commit 975ad7d

Please sign in to comment.