Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash on inscription not found #25

Merged
merged 1 commit into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 27 additions & 21 deletions src/index/updater/inscription_updater/stream.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::inscription::TransactionInscription;
use crate::subcommand::traits::Output;
use base64::{engine::general_purpose, Engine as _};
use log::{error, warn};

use super::*;
use rdkafka::{
Expand Down Expand Up @@ -260,29 +261,34 @@ impl StreamEvent {

pub(crate) fn with_transfer(&mut self, old_satpoint: SatPoint, index: &Index) -> &mut Self {
self.old_location = Some(old_satpoint);
if let Some(inscription) = index
self.old_owner = index
.get_transaction(old_satpoint.outpoint.txid)
.unwrap_or(None)
.and_then(|tx| {
tx.output
.get(old_satpoint.outpoint.vout as usize)
.and_then(|txout| {
Address::from_script(&txout.script_pubkey, StreamEvent::get_network())
.map_err(|e| {
error!(
"StreamEvent::with_transfer could not parse old_owner address: {}",
e
);
})
.ok()
})
});
match index
.get_inscription_by_id_unsafe(self.inscription_id)
.unwrap_or_else(|_| panic!("Inscription should exist: {}", self.inscription_id))
.unwrap_or(None)
{
self.enrich_content(inscription);
self.old_owner = index
.get_transaction(old_satpoint.outpoint.txid)
.unwrap_or(None)
.and_then(|tx| {
tx.output
.get(old_satpoint.outpoint.vout as usize)
.and_then(|txout| {
Address::from_script(&txout.script_pubkey, StreamEvent::get_network())
.map_err(|e| {
log::error!(
"StreamEvent::with_transfer could not parse old_owner address: {}",
e
);
})
.ok()
})
});
};
Some(inscription) => {
self.enrich_content(inscription);
}
None => {
warn!("could not find inscription for id {}", self.inscription_id);
}
}
self
}

Expand Down