Skip to content

Commit

Permalink
fix: retrieve inscriptions from cache
Browse files Browse the repository at this point in the history
  • Loading branch information
hertarr committed Sep 24, 2023
1 parent 7f25841 commit 1d21e62
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 7 deletions.
28 changes: 28 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Build

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
lint:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- name: Install Rust Toolchain Components
uses: actions-rs/toolchain@v1
with:
components: rustfmt
override: true
toolchain: stable

- uses: Swatinem/rust-cache@v2

- name: Format
run: cargo fmt --all -- --check
17 changes: 11 additions & 6 deletions src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,12 +221,17 @@ impl<'block> InscriptionUpdater<'block> {
}

let previous_output = format!("{}:{}", tx_in.outpoint.txid, tx_in.outpoint.index);
let inscriptions_str_at_output = self
.output_inscription
.get(previous_output.as_bytes())
.unwrap_or_default();

let inscriptions_str = String::from_utf8(inscriptions_str_at_output)?;
let inscriptions_str = self
.output_inscription_cache
.entry(previous_output.clone())
.or_insert_with(|| {
String::from_utf8(
self.output_inscription
.get(previous_output.as_bytes())
.unwrap_or_default(),
)
.unwrap()
});
if inscriptions_str != "" {
for (inscription_id, inscription_offset) in
inscriptions_str
Expand Down
4 changes: 3 additions & 1 deletion src/inscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ impl Inscription {
continue;
}

let Ok(inscriptions) = InscriptionParser::parse(&tx_in.witness.clone().unwrap()) else { continue };
let Ok(inscriptions) = InscriptionParser::parse(&tx_in.witness.clone().unwrap()) else {
continue
};

result.extend(
inscriptions
Expand Down

0 comments on commit 1d21e62

Please sign in to comment.