Skip to content

Commit

Permalink
Remove inscription content type counts from /status page (ordinals#3922)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Aug 29, 2024
1 parent 3b081ee commit 3a50f67
Show file tree
Hide file tree
Showing 8 changed files with 1 addition and 53 deletions.
13 changes: 0 additions & 13 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ define_multimap_table! { SATPOINT_TO_SEQUENCE_NUMBER, &SatPointValue, u32 }
define_multimap_table! { SAT_TO_SEQUENCE_NUMBER, u64, u32 }
define_multimap_table! { SEQUENCE_NUMBER_TO_CHILDREN, u32, u32 }
define_multimap_table! { SCRIPT_PUBKEY_TO_OUTPOINT, &[u8], OutPointValue }
define_table! { CONTENT_TYPE_TO_COUNT, Option<&[u8]>, u64 }
define_table! { HEIGHT_TO_BLOCK_HEADER, u32, &HeaderValue }
define_table! { HEIGHT_TO_LAST_SEQUENCE_NUMBER, u32, u32 }
define_table! { HOME_INSCRIPTIONS, u32, InscriptionIdValue }
Expand Down Expand Up @@ -302,7 +301,6 @@ impl Index {
tx.open_multimap_table(SAT_TO_SEQUENCE_NUMBER)?;
tx.open_multimap_table(SCRIPT_PUBKEY_TO_OUTPOINT)?;
tx.open_multimap_table(SEQUENCE_NUMBER_TO_CHILDREN)?;
tx.open_table(CONTENT_TYPE_TO_COUNT)?;
tx.open_table(HEIGHT_TO_BLOCK_HEADER)?;
tx.open_table(HEIGHT_TO_LAST_SEQUENCE_NUMBER)?;
tx.open_table(HOME_INSCRIPTIONS)?;
Expand Down Expand Up @@ -515,21 +513,10 @@ impl Index {
let cursed_inscriptions = statistic(Statistic::CursedInscriptions)?;
let initial_sync_time = statistic(Statistic::InitialSyncTime)?;

let mut content_type_counts = rtx
.open_table(CONTENT_TYPE_TO_COUNT)?
.iter()?
.map(|result| {
result.map(|(key, value)| (key.value().map(|slice| slice.into()), value.value()))
})
.collect::<Result<Vec<(Option<Vec<u8>>, u64)>, StorageError>>()?;

content_type_counts.sort_by_key(|(_content_type, count)| Reverse(*count));

Ok(StatusHtml {
address_index: self.has_address_index(),
blessed_inscriptions,
chain: self.settings.chain(),
content_type_counts,
cursed_inscriptions,
height,
initial_sync_time: Duration::from_micros(initial_sync_time),
Expand Down
2 changes: 0 additions & 2 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,6 @@ impl<'index> Updater<'index> {
}
};

let mut content_type_to_count = wtx.open_table(CONTENT_TYPE_TO_COUNT)?;
let mut height_to_block_header = wtx.open_table(HEIGHT_TO_BLOCK_HEADER)?;
let mut height_to_last_sequence_number = wtx.open_table(HEIGHT_TO_LAST_SEQUENCE_NUMBER)?;
let mut home_inscriptions = wtx.open_table(HOME_INSCRIPTIONS)?;
Expand Down Expand Up @@ -465,7 +464,6 @@ impl<'index> Updater<'index> {
let mut inscription_updater = InscriptionUpdater {
blessed_inscription_count,
chain: self.index.settings.chain(),
content_type_to_count: &mut content_type_to_count,
cursed_inscription_count,
event_sender: self.index.event_sender.as_ref(),
flotsam: Vec::new(),
Expand Down
13 changes: 0 additions & 13 deletions src/index/updater/inscription_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ enum Origin {
pub(super) struct InscriptionUpdater<'a, 'tx> {
pub(super) blessed_inscription_count: u64,
pub(super) chain: Chain,
pub(super) content_type_to_count: &'a mut Table<'tx, Option<&'static [u8]>, u64>,
pub(super) cursed_inscription_count: u64,
pub(super) event_sender: Option<&'a mpsc::Sender<Event>>,
pub(super) flotsam: Vec<Flotsam>,
Expand Down Expand Up @@ -194,18 +193,6 @@ impl<'a, 'tx> InscriptionUpdater<'a, 'tx> {
.filter(|&pointer| pointer < total_output_value)
.unwrap_or(offset);

let content_type = inscription.payload.content_type.as_deref();

let content_type_count = self
.content_type_to_count
.get(content_type)?
.map(|entry| entry.value())
.unwrap_or_default();

self
.content_type_to_count
.insert(content_type, content_type_count + 1)?;

floating_inscriptions.push(Flotsam {
inscription_id,
offset,
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use {
snafu::{Backtrace, ErrorCompat, Snafu},
std::{
backtrace::BacktraceStatus,
cmp::{self, Reverse},
cmp,
collections::{BTreeMap, BTreeSet, HashMap, HashSet, VecDeque},
env,
ffi::OsString,
Expand Down
9 changes: 0 additions & 9 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3564,15 +3564,6 @@ mod tests {
[[:xdigit:]]{40}
</a>
</dd>
<dt>inscription content types</dt>
<dd>
<dl>
<dt>text/plain;charset=utf-8</dt>
<dd>2</dt>
<dt><em>none</em></dt>
<dd>1</dt>
</dl>
</dd>
</dl>
.*",
);
Expand Down
1 change: 0 additions & 1 deletion src/templates/status.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pub struct StatusHtml {
pub address_index: bool,
pub blessed_inscriptions: u64,
pub chain: Chain,
pub content_type_counts: Vec<(Option<Vec<u8>>, u64)>,
pub cursed_inscriptions: u64,
pub height: Option<u32>,
pub initial_sync_time: Duration,
Expand Down
13 changes: 0 additions & 13 deletions templates/status.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,4 @@ <h1>Status</h1>
</a>
</dd>
%% }
<dt>inscription content types</dt>
<dd>
<dl>
%% for (content_type, count) in &self.content_type_counts {
%% if let Some(content_type) = content_type {
<dt>{{String::from_utf8_lossy(&content_type)}}</dt>
%% } else {
<dt><em>none</em></dt>
%% }
<dd>{{count}}</dt>
%% }
</dl>
</dd>
</dl>
1 change: 0 additions & 1 deletion tests/json_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ fn get_status() {
address_index: false,
blessed_inscriptions: 1,
chain: Chain::Regtest,
content_type_counts: vec![(Some("text/plain;charset=utf-8".into()), 1)],
cursed_inscriptions: 0,
height: Some(3),
initial_sync_time: dummy_duration,
Expand Down

0 comments on commit 3a50f67

Please sign in to comment.