Skip to content

Commit

Permalink
Merge branch 'master' of github.com:ordinals/ord into add-opus
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Jan 24, 2025
2 parents 8f7822e + 2dae21f commit 4f93be4
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 20 deletions.
18 changes: 11 additions & 7 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,13 +1789,17 @@ impl Index {
.with_context(|| format!("current {current} height is greater than sat height {height}"))?;

Ok(Blocktime::Expected(
Utc::now()
.round_subsecs(0)
.checked_add_signed(
chrono::Duration::try_seconds(10 * 60 * i64::from(expected_blocks))
.context("timestamp out of range")?,
)
.context("timestamp out of range")?,
if self.settings.chain() == Chain::Regtest {
DateTime::default()
} else {
Utc::now()
}
.round_subsecs(0)
.checked_add_signed(
chrono::Duration::try_seconds(10 * 60 * i64::from(expected_blocks))
.context("timestamp out of range")?,
)
.context("timestamp out of range")?,
))
}

Expand Down
1 change: 1 addition & 0 deletions src/inscriptions/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ impl Media {
("application/pdf", GENERIC, Pdf, &["pdf"]),
("application/pgp-signature", TEXT, Text, &["asc"]),
("application/protobuf", GENERIC, Unknown, &["binpb"]),
("application/x-bittorrent", GENERIC, Unknown, &["torrent"]),
("application/x-javascript", TEXT, Code(JavaScript), &[]),
("application/yaml", TEXT, Code(Yaml), &["yaml", "yml"]),
("audio/flac", GENERIC, Audio, &["flac"]),
Expand Down
19 changes: 12 additions & 7 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,13 +849,15 @@ impl Server {
return Ok(if accept_json {
StatusCode::NOT_FOUND.into_response()
} else {
let unlock = if let Some(height) = rune.unlock_height(server_config.chain.network()) {
Some((height, index.block_time(height)?.timestamp()))
} else {
None
};

(
StatusCode::NOT_FOUND,
RuneNotFoundHtml {
rune,
unlock_height: rune.unlock_height(server_config.chain.network()),
}
.page(server_config),
RuneNotFoundHtml { rune, unlock }.page(server_config),
)
.into_response()
});
Expand Down Expand Up @@ -3295,7 +3297,10 @@ mod tests {
StatusCode::NOT_FOUND,
RuneNotFoundHtml {
rune: Rune(0),
unlock_height: Some(Height(209999)),
unlock: Some((
Height(209999),
DateTime::from_timestamp(125998800, 0).unwrap(),
)),
},
);
}
Expand All @@ -3314,7 +3319,7 @@ mod tests {
StatusCode::NOT_FOUND,
RuneNotFoundHtml {
rune: Rune(Rune::RESERVED),
unlock_height: None,
unlock: None,
},
);
}
Expand Down
10 changes: 6 additions & 4 deletions src/templates/rune_not_found.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::*;
#[derive(Boilerplate, Debug, PartialEq, Serialize)]
pub struct RuneNotFoundHtml {
pub rune: Rune,
pub unlock_height: Option<Height>,
pub unlock: Option<(Height, DateTime<Utc>)>,
}

impl PageContent for RuneNotFoundHtml {
Expand All @@ -21,12 +21,14 @@ mod tests {
assert_regex_match!(
RuneNotFoundHtml {
rune: Rune(u128::MAX),
unlock_height: Some(Height(111)),
unlock: Some((Height(111), DateTime::default())),
},
"<h1>BCGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
r"<h1>BCGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
<dl>
<dt>unlock height</dt>
<dd>111</dd>
<dt>unlock time</dt>
<dd><time>1970-01-01 00:00:00 UTC</time> \(expected\)</dd>
<dt>reserved</dt>
<dd>false</dd>
</dl>
Expand All @@ -39,7 +41,7 @@ mod tests {
assert_regex_match!(
RuneNotFoundHtml {
rune: Rune(Rune::RESERVED),
unlock_height: None,
unlock: None,
},
"<h1>AAAAAAAAAAAAAAAAAAAAAAAAAAA</h1>
<dl>
Expand Down
6 changes: 4 additions & 2 deletions templates/rune-not-found.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<h1>{{ self.rune }}</h1>
<dl>
%% if let Some(unlock_height) = self.unlock_height {
%% if let Some((height, time)) = self.unlock {
<dt>unlock height</dt>
<dd>{{ unlock_height }}</dd>
<dd>{{ height }}</dd>
<dt>unlock time</dt>
<dd><time>{{ time }}</time> (expected)</dd>
<dt>reserved</dt>
<dd>false</dd>
%% } else {
Expand Down

0 comments on commit 4f93be4

Please sign in to comment.