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

Rebase on parent support #15

Closed
wants to merge 60 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
621a747
Make retrieving inscriptions in block fast (#2333)
veryordinally Aug 17, 2023
8f15f6b
Allow setting custom postage (#2331)
raphjaph Aug 17, 2023
462f38b
Use `--fee-rate` when sending an amount (#1922)
gmart7t2 Aug 17, 2023
f6a2bac
Release 0.8.2 (#2334)
raphjaph Aug 17, 2023
3a3e9f5
Homogenize design (#2346)
casey Aug 21, 2023
4b9a530
Reduce index durability when testing (#2347)
casey Aug 21, 2023
6b846dc
Add hint about maximum number of open files for testing (#2348)
casey Aug 21, 2023
8d146ca
Recognize media types without explicit charset (#2349)
casey Aug 21, 2023
fb0457c
Update explorer.md (#2215)
elocremarc Aug 22, 2023
47d2aff
Add tags and inscription id documentation (#2351)
raphjaph Aug 22, 2023
8a95a0f
Use correct height and depth in reorg log (#2352)
gmart7t2 Aug 22, 2023
68a41f7
Allow splitting merged inscriptions (#1927)
gmart7t2 Aug 22, 2023
5c09dd6
Return JSON from all commands (#2355)
casey Aug 23, 2023
c910079
Render GLB/GLTF models in preview (#2369)
raphjaph Aug 25, 2023
34bb1c6
Remove transaction ID to inscription ID conversion (#2370)
casey Aug 25, 2023
898c2cd
Add proper block inscriptions HTML (#2337)
veryordinally Aug 27, 2023
9eb09aa
Make homepage more interesting (#2374)
raphjaph Aug 27, 2023
c458791
Add testing guide for recursion (#2357)
elocremarc Aug 27, 2023
7a6d8b7
Fix slice error for inscriptions block view (#2378)
veryordinally Aug 27, 2023
cfb7492
Add some links to docs (#2364)
ordinaHO Aug 27, 2023
28b9d71
Tweaks to front-end (#2381)
raphjaph Aug 28, 2023
0749c5b
Release 0.8.3 (#2382)
raphjaph Aug 28, 2023
04701d2
Remove unused content_response match statement (#2384)
casey Aug 29, 2023
d41edf7
Inscriptions with unrecognized even fields are unbound and cursed (#2…
raphjaph Aug 29, 2023
36946f7
Vaccuum log with every new deploy (#2390)
raphjaph Aug 29, 2023
24231be
Add reindexing docs (#2393)
raphjaph Aug 29, 2023
7bb33ea
Add language picker for docs (#2403)
raphjaph Aug 30, 2023
329f31b
Add Chinese version of the handbook (#2406)
DrJingLee Aug 31, 2023
9b8a4bf
Deduplicate sat range summation logic (#2402)
casey Aug 31, 2023
ba40b36
Allocate blocks vector ahead of time (#2409)
casey Aug 31, 2023
676f48f
Use tapscript extraction from rust-bitcoin (#2404)
casey Aug 31, 2023
89fde16
Add `decode` command (#2401)
casey Aug 31, 2023
5c656b2
Install mdbook-i18n-helpers in Github Workflows (#2408)
raphjaph Aug 31, 2023
bc73eb9
Add application/protobuf media type (#2389)
casey Aug 31, 2023
c48e455
Update clap (#2415)
casey Aug 31, 2023
10ca91e
Update dependencies (#2414)
casey Aug 31, 2023
10c99e7
Remove unused itertools dependency (#2416)
casey Aug 31, 2023
3e75a78
Fix UTXO selection in mock Bitcoin Core instance(#2417)
raphjaph Aug 31, 2023
33a9e0e
Tweak translations intructions (#2413)
raphjaph Aug 31, 2023
c00652c
Make any zero-valued input inscription unbound (#2397)
raphjaph Aug 31, 2023
87a9ed7
Implement provenance in index (#2353)
casey Sep 4, 2023
e6ceb97
Add provenance spec (#2278)
casey Sep 4, 2023
393848f
Fix Chinese translation typos and format errors (#2419)
DrJingLee Sep 4, 2023
44f8b2a
Prevent search when query field is empty (#2425)
elocremarc Sep 6, 2023
04bc261
Inscribe with parent (#2388)
raphjaph Sep 6, 2023
4b1709d
Add provenance to docs summary (#2427)
casey Sep 6, 2023
ca30715
Add Japanese version of handbook (#2426)
DrJingLee Sep 9, 2023
1491e63
Provide more detailed translation instructions (#2443)
DrJingLee Sep 10, 2023
54c38d9
Fold BlockIndex into database (#2436)
raphjaph Sep 11, 2023
422bc01
Fix type (#2444)
DrJingLee Sep 11, 2023
833854d
Allow reinscribing with wallet (#2432)
raphjaph Sep 11, 2023
80ef6e7
Release 0.9.0 (#2445)
raphjaph Sep 11, 2023
547b7ab
Add kafka feature and stream
nothing0012 Feb 25, 2023
368a588
Add json-rpc server for getSatRanges
nothing0012 Jul 27, 2023
89700d1
add block based rarities (#12)
haozhiliu Aug 15, 2023
75defc2
Refactor stream event to its own mod
nothing0012 Aug 16, 2023
7512bd4
Fix cargo fmt
nothing0012 Aug 16, 2023
7137285
exclude sat range end from calculating block based rarities (#13)
haozhiliu Aug 23, 2023
e5c946b
refactor rpc response to put rare sats and sat ranges under utxo obje…
haozhiliu Sep 7, 2023
aed1f1e
Fix console log
nothing0012 Sep 11, 2023
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
Prev Previous commit
Next Next commit
Make homepage more interesting (ordinals#2374)
  • Loading branch information
raphjaph authored Aug 27, 2023
commit 9eb09aa5dfb6614e994980972894d319a484840c
14 changes: 0 additions & 14 deletions src/index.rs
Original file line number Diff line number Diff line change
@@ -876,20 +876,6 @@ impl Index {
Ok(result)
}

pub(crate) fn get_homepage_inscriptions(&self) -> Result<Vec<InscriptionId>> {
Ok(
self
.database
.begin_read()?
.open_table(INSCRIPTION_NUMBER_TO_INSCRIPTION_ID)?
.iter()?
.rev()
.take(8)
.flat_map(|result| result.map(|(_number, id)| Entry::load(*id.value())))
.collect(),
)
}

pub(crate) fn get_latest_inscriptions_with_prev_and_next(
&self,
n: usize,
25 changes: 25 additions & 0 deletions src/index/block_index.rs
Original file line number Diff line number Diff line change
@@ -203,4 +203,29 @@ impl BlockIndex {

Ok(inscriptions)
}

pub(crate) fn get_highest_paying_inscriptions_in_block(
&self,
index: &Index,
block_height: u64,
n: usize,
) -> Result<Vec<InscriptionId>> {
let inscription_ids = self.get_inscriptions_in_block(index, block_height)?;

let mut inscription_to_fee: Vec<(InscriptionId, u64)> = Vec::new();
for id in inscription_ids {
inscription_to_fee.push((id, index.get_inscription_entry(id)?.unwrap().fee));
}

inscription_to_fee.sort_by_key(|(_, fee)| *fee);

Ok(
inscription_to_fee
.iter()
.map(|(id, _)| *id)
.rev()
.take(n)
.collect(),
)
}
}
45 changes: 30 additions & 15 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
@@ -560,15 +560,24 @@ impl Server {
async fn home(
Extension(page_config): Extension<Arc<PageConfig>>,
Extension(index): Extension<Arc<Index>>,
Extension(block_index_state): Extension<Arc<BlockIndexState>>,
) -> ServerResult<PageHtml<HomeHtml>> {
Ok(
HomeHtml::new(index.blocks(100)?, index.get_homepage_inscriptions()?)
.page(page_config, index.has_sat_index()?),
)
let blocks = index.blocks(100)?;
let mut featured_blocks = BTreeMap::new();
for (height, hash) in blocks.iter().take(5) {
let inscriptions = block_index_state
.block_index
.read()
.unwrap()
.get_highest_paying_inscriptions_in_block(&index, *height, 8)?;
featured_blocks.insert(*hash, inscriptions);
}

Ok(HomeHtml::new(blocks, featured_blocks).page(page_config, index.has_sat_index()?))
}

async fn install_script() -> Redirect {
Redirect::to("https://raw.githubusercontent.com/casey/ord/master/install.sh")
Redirect::to("https://raw.githubusercontent.com/ordinals/ord/master/install.sh")
}

async fn block(
@@ -1545,7 +1554,7 @@ mod tests {
fn install_sh_redirects_to_github() {
TestServer::new().assert_redirect(
"/install.sh",
"https://raw.githubusercontent.com/casey/ord/master/install.sh",
"https://raw.githubusercontent.com/ordinals/ord/master/install.sh",
);
}

@@ -1960,15 +1969,21 @@ mod tests {
test_server.mine_blocks(1);

test_server.assert_response_regex(
"/",
StatusCode::OK,
".*<title>Ordinals</title>.*
<h2>Latest Blocks</h2>
<ol start=1 reversed class=blocks>
<li><a href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>
<li><a href=/block/000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f>000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f</a></li>
"/",
StatusCode::OK,
".*<title>Ordinals</title>.*
<div class=block>
<h2><a href=/block/1>Block 1</a></h2>
<div class=thumbnails>
</div>
</div>
<div class=block>
<h2><a href=/block/0>Block 0</a></h2>
<div class=thumbnails>
</div>
</div>
</ol>.*",
);
);
}

#[test]
@@ -1989,7 +2004,7 @@ mod tests {
test_server.assert_response_regex(
"/",
StatusCode::OK,
".*<ol start=101 reversed class=blocks>\n( <li><a href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>\n){100}</ol>.*"
".*<ol start=96 reversed class=block-list>\n( <li><a href=/block/[[:xdigit:]]{64}>[[:xdigit:]]{64}</a></li>\n){95}</ol>.*"
);
}

53 changes: 36 additions & 17 deletions src/templates/home.rs
Original file line number Diff line number Diff line change
@@ -4,19 +4,22 @@ use super::*;
pub(crate) struct HomeHtml {
last: u64,
blocks: Vec<BlockHash>,
inscriptions: Vec<InscriptionId>,
featured_blocks: BTreeMap<BlockHash, Vec<InscriptionId>>,
}

impl HomeHtml {
pub(crate) fn new(blocks: Vec<(u64, BlockHash)>, inscriptions: Vec<InscriptionId>) -> Self {
pub(crate) fn new(
blocks: Vec<(u64, BlockHash)>,
featured_blocks: BTreeMap<BlockHash, Vec<InscriptionId>>,
) -> Self {
Self {
last: blocks
.get(0)
.map(|(height, _)| height)
.cloned()
.unwrap_or(0),
blocks: blocks.into_iter().map(|(_, hash)| hash).collect(),
inscriptions,
featured_blocks,
}
}
}
@@ -33,9 +36,23 @@ mod tests {

#[test]
fn html() {
let mut feature_blocks = BTreeMap::new();
feature_blocks.insert(
"2222222222222222222222222222222222222222222222222222222222222222"
.parse()
.unwrap(),
vec![inscription_id(1), inscription_id(2)],
);

assert_regex_match!(
&HomeHtml::new(
vec![
(
1260002,
"2222222222222222222222222222222222222222222222222222222222222222"
.parse()
.unwrap()
),
(
1260001,
"1111111111111111111111111111111111111111111111111111111111111111"
@@ -49,21 +66,23 @@ mod tests {
.unwrap()
)
],
vec![inscription_id(1), inscription_id(2)],
feature_blocks,
)
.to_string(),
"<h2>Latest Inscriptions</h2>
<div class=thumbnails>
<a href=/inscription/1{64}i1><iframe .* src=/preview/1{64}i1></iframe></a>
<a href=/inscription/2{64}i2><iframe .* src=/preview/2{64}i2></iframe></a>
</div>
<div class=center><a href=/inscriptions>more</a></div>
<h2>Latest Blocks</h2>
<ol start=1260001 reversed class=blocks>
<li><a href=/block/1{64}>1{64}</a></li>
<li><a href=/block/0{64}>0{64}</a></li>
</ol>
",
.to_string()
.unindent(),
"<div class=block>
<h2><a href=/block/1260002>Block 1260002</a></h2>
<div class=thumbnails>
<a href=/inscription/1{64}i1><iframe .* src=/preview/1{64}i1></iframe></a>
<a href=/inscription/2{64}i2><iframe .* src=/preview/2{64}i2></iframe></a>
</div>
</div>
<ol start=1260001 reversed class=block-list>
<li><a href=/block/1{64}>1{64}</a></li>
<li><a href=/block/0{64}>0{64}</a></li>
</ol>
"
.unindent(),
);
}
}
4 changes: 2 additions & 2 deletions src/templates/inscriptions_block.rs
Original file line number Diff line number Diff line change
@@ -67,7 +67,7 @@ mod tests {
next_page: None,
},
"
<h1>Inscriptions in <a href=/block/21>Block 21</a></h1>
<h1 class=light-fg>Inscriptions in <a href=/block/21>Block 21</a></h1>
<div class=thumbnails>
<a href=/inscription/1{64}i1><iframe .* src=/preview/1{64}i1></iframe></a>
<a href=/inscription/2{64}i2><iframe .* src=/preview/2{64}i2></iframe></a>
@@ -93,7 +93,7 @@ mod tests {
prev_page: Some(1),
},
"
<h1>Inscriptions in <a href=/block/21>Block 21</a></h1>
<h1 class=light-fg>Inscriptions in <a href=/block/21>Block 21</a></h1>
<div class=thumbnails>
<a href=/inscription/1{64}i1><iframe .* src=/preview/1{64}i1></iframe></a>
<a href=/inscription/2{64}i2><iframe .* src=/preview/2{64}i2></iframe></a>
23 changes: 21 additions & 2 deletions static/index.css
Original file line number Diff line number Diff line change
@@ -101,13 +101,32 @@ ol, ul {
}
}

.blocks {
.block-list {
font-family: monospace, monospace;
list-style-position: inside;
padding-inline-start: 1rem;
white-space: nowrap;
}

.block {
background-color: var(--light-bg);
box-shadow: rgba(0, 0, 0, 0.16) 0px 1px 4px, var(--light-bg) 0px 0px 0px 3px;
margin: 3%;
padding: 0.5%;
text-align: center;
}

.block a {
color: var(--light-fg);
margin-top: 1%;
}

.block h2 {
margin: 1%;
}

.light-fg a {
color: var(--light-fg);
}
.center {
text-align: center;
}
23 changes: 13 additions & 10 deletions templates/home.html
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
%% if !&self.inscriptions.is_empty() {
<h2>Latest Inscriptions</h2>
<div class=thumbnails>
%% for id in &self.inscriptions {
{{Iframe::thumbnail(*id)}}
%% for (i, hash) in self.blocks.iter().enumerate() {
%% if let Some(inscription_ids) = &self.featured_blocks.get(hash) {
<div class=block>
<h2><a href=/block/{{ self.last - i as u64 }}>Block {{ self.last - i as u64 }}</a></h2>
<div class=thumbnails>
%% for id in *inscription_ids {
{{ Iframe::thumbnail(*id) }}
%% }
</div>
</div>
<div class=center><a href=/inscriptions>more</a></div>
%% } else {
%% if i == self.featured_blocks.len() {
<ol start={{ self.last - self.featured_blocks.len() as u64 }} reversed class=block-list>
%% }
<li><a href=/block/{{ hash }}>{{ hash }}</a></li>
%% }
<h2>Latest Blocks</h2>
<ol start={{self.last}} reversed class=blocks>
%% for hash in &self.blocks {
<li><a href=/block/{{hash}}>{{hash}}</a></li>
%% }
</ol>
2 changes: 1 addition & 1 deletion templates/inscriptions-block.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<h1>Inscriptions in <a href=/block/{{ &self.block }}>Block {{ &self.block }}</a></h1>
<h1 class=light-fg>Inscriptions in <a href=/block/{{ &self.block }}>Block {{ &self.block }}</a></h1>
<div class=thumbnails>
%% for id in &self.inscriptions {
{{ Iframe::thumbnail(*id) }}
43 changes: 0 additions & 43 deletions tests/server.rs
Original file line number Diff line number Diff line change
@@ -195,49 +195,6 @@ fn inscription_content() {
assert_eq!(response.bytes().unwrap(), "FOO");
}

#[test]
fn home_page_includes_latest_inscriptions() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);

let Inscribe { inscription, .. } = inscribe(&rpc_server);

TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
"/",
format!(
".*<h2>Latest Inscriptions</h2>
<div class=thumbnails>
<a href=/inscription/{inscription}><iframe .*></a>
</div>.*",
),
);
}

#[test]
fn home_page_inscriptions_are_sorted() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);

let mut inscriptions = String::new();

for _ in 0..8 {
let Inscribe { inscription, .. } = inscribe(&rpc_server);
inscriptions.insert_str(
0,
&format!("\n <a href=/inscription/{inscription}><iframe .*></a>"),
);
}

TestServer::spawn_with_args(&rpc_server, &[]).assert_response_regex(
"/",
format!(
".*<h2>Latest Inscriptions</h2>
<div class=thumbnails>{inscriptions}
</div>.*"
),
);
}

#[test]
fn inscriptions_page() {
let rpc_server = test_bitcoincore_rpc::spawn();