Skip to content

Commit

Permalink
Fetch transactions below first inscription height (#1357)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 24, 2023
1 parent c08740c commit 28bc035
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 53 deletions.
52 changes: 0 additions & 52 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -911,58 +911,6 @@ mod tests {
}
}

#[test]
fn inscriptions_below_first_inscription_height_are_skipped() {
let inscription = inscription("text/plain", "hello");
let template = TransactionTemplate {
inputs: &[(1, 0, 0)],
witness: inscription.to_witness(),
..Default::default()
};

{
let context = Context::builder().build();
context.mine_blocks(1);
let txid = context.rpc_server.broadcast_tx(template.clone());
let inscription_id = InscriptionId::from(txid);
context.mine_blocks(1);

assert_eq!(
context.index.get_inscription_by_id(inscription_id).unwrap(),
Some(inscription)
);

assert_eq!(
context
.index
.get_inscription_satpoint_by_id(inscription_id)
.unwrap(),
Some(SatPoint {
outpoint: OutPoint { txid, vout: 0 },
offset: 0,
})
);
}

{
let context = Context::builder()
.arg("--first-inscription-height=3")
.build();
context.mine_blocks(1);
let txid = context.rpc_server.broadcast_tx(template);
let inscription_id = InscriptionId::from(txid);
context.mine_blocks(1);

assert_eq!(
context
.index
.get_inscription_satpoint_by_id(inscription_id)
.unwrap(),
None,
);
}
}

#[test]
fn list_first_coinbase_transaction() {
let context = Context::builder().arg("--index-sats").build();
Expand Down
3 changes: 2 additions & 1 deletion src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,8 @@ impl Updater {
let client =
Client::new(&index.rpc_url, index.auth.clone()).context("failed to connect to RPC URL")?;

let first_inscription_height = index.first_inscription_height;
// NB: We temporarily always fetch transactions, to avoid expensive cache misses.
let first_inscription_height = index.first_inscription_height.min(0);

thread::spawn(move || loop {
if let Some(height_limit) = height_limit {
Expand Down

0 comments on commit 28bc035

Please sign in to comment.