Skip to content

Commit

Permalink
Rename --index-satoshis → --index-sats (ordinals#993)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey committed Dec 16, 2022
1 parent ddef649 commit f4e115d
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 54 deletions.
2 changes: 1 addition & 1 deletion deploy/ord-dev.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ExecStart=/usr/local/bin/ord-dev \
--bitcoin-data-dir /var/lib/bitcoind \
--chain ${CHAIN} \
--data-dir /var/lib/ord-dev \
--index-satoshis \
--index-sats \
server \
--http-port 8080
Group=ord
Expand Down
2 changes: 1 addition & 1 deletion deploy/ord.service
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ ExecStart=/usr/local/bin/ord \
--bitcoin-data-dir /var/lib/bitcoind \
--data-dir /var/lib/ord \
--chain ${CHAIN} \
--index-satoshis \
--index-sats \
server \
--acme-contact mailto:[email protected] \
--http \
Expand Down
6 changes: 3 additions & 3 deletions docs/src/guides/sat-hunting.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Ordinal Hunting
===============

*This guide is out of date. Since it was written, the `ord` binary was changed
to only build the full satoshi index when the `--index-satoshis` flag is
supplied. Additionally, `ord` now has a built-in wallet that wraps a Bitcoin
Core wallet. See `ord wallet --help`.*
to only build the full satoshi index when the `--index-sats` flag is supplied.
Additionally, `ord` now has a built-in wallet that wraps a Bitcoin Core wallet.
See `ord wallet --help`.*

Ordinal hunting is difficult but rewarding. The feeling of owning a wallet full
of UTXOs, redolent with the scent of rare and exotic sats, is beyond compare.
Expand Down
34 changes: 17 additions & 17 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ impl Index {
tx.open_table(STATISTIC_TO_COUNT)?;
tx.open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)?;

if options.index_satoshis {
if options.index_sats {
tx.open_table(OUTPOINT_TO_SAT_RANGES)?;
}

Expand Down Expand Up @@ -248,7 +248,7 @@ impl Index {

fn require_satoshi_index(&self, feature: &str) -> Result {
if !self.has_satoshi_index()? {
bail!("{feature} requires index created with `--index-satoshis` flag")
bail!("{feature} requires index created with `--index-sats` flag")
}

Ok(())
Expand Down Expand Up @@ -662,7 +662,7 @@ mod tests {

#[test]
fn list_first_coinbase_transaction() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
assert_eq!(
context
.index
Expand All @@ -679,7 +679,7 @@ mod tests {

#[test]
fn list_second_coinbase_transaction() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
let txid = context.rpc_server.mine_blocks(1)[0].txdata[0].txid();
context.index.update().unwrap();
assert_eq!(
Expand All @@ -690,7 +690,7 @@ mod tests {

#[test]
fn list_split_ranges_are_tracked_correctly() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

context.rpc_server.mine_blocks(1);
let split_coinbase_output = TransactionTemplate {
Expand All @@ -716,7 +716,7 @@ mod tests {

#[test]
fn list_merge_ranges_are_tracked_correctly() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

context.rpc_server.mine_blocks(2);
let merge_coinbase_outputs = TransactionTemplate {
Expand All @@ -740,7 +740,7 @@ mod tests {

#[test]
fn list_fee_paying_transaction_range() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

context.rpc_server.mine_blocks(1);
let fee_paying_tx = TransactionTemplate {
Expand Down Expand Up @@ -774,7 +774,7 @@ mod tests {

#[test]
fn list_two_fee_paying_transaction_range() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

context.rpc_server.mine_blocks(2);
let first_fee_paying_tx = TransactionTemplate {
Expand Down Expand Up @@ -809,7 +809,7 @@ mod tests {

#[test]
fn list_null_output() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

context.rpc_server.mine_blocks(1);
let no_value_output = TransactionTemplate {
Expand All @@ -829,7 +829,7 @@ mod tests {

#[test]
fn list_null_input() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

context.rpc_server.mine_blocks(1);
let no_value_output = TransactionTemplate {
Expand Down Expand Up @@ -857,7 +857,7 @@ mod tests {

#[test]
fn list_spent_output() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
context.rpc_server.mine_blocks(1);
context.rpc_server.broadcast_tx(TransactionTemplate {
input_slots: &[(1, 0, 0)],
Expand All @@ -875,7 +875,7 @@ mod tests {

#[test]
fn list_unknown_output() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");

assert_eq!(
context
Expand All @@ -892,7 +892,7 @@ mod tests {

#[test]
fn find_first_sat() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
assert_eq!(
context.index.find(0).unwrap().unwrap(),
SatPoint {
Expand All @@ -906,7 +906,7 @@ mod tests {

#[test]
fn find_second_sat() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
assert_eq!(
context.index.find(1).unwrap().unwrap(),
SatPoint {
Expand All @@ -920,7 +920,7 @@ mod tests {

#[test]
fn find_first_sat_of_second_block() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
context.rpc_server.mine_blocks(1);
context.index.update().unwrap();
assert_eq!(
Expand All @@ -936,13 +936,13 @@ mod tests {

#[test]
fn find_unmined_sat() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
assert_eq!(context.index.find(50 * COIN_VALUE).unwrap(), None);
}

#[test]
fn find_first_satoshi_spent_in_second_block() {
let context = Context::with_args("--index-satoshis");
let context = Context::with_args("--index-sats");
context.rpc_server.mine_blocks(1);
let spend_txid = context.rpc_server.broadcast_tx(TransactionTemplate {
input_slots: &[(1, 0, 0)],
Expand Down
14 changes: 7 additions & 7 deletions src/index/updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl From<Block> for BlockData {
pub struct Updater {
cache: HashMap<OutPointArray, Vec<u8>>,
height: u64,
index_satoshis: bool,
index_sats: bool,
sat_ranges_since_flush: u64,
outputs_cached: u64,
outputs_inserted_since_flush: u64,
Expand Down Expand Up @@ -56,7 +56,7 @@ impl Updater {
let mut updater = Self {
cache: HashMap::new(),
height,
index_satoshis: index.has_satoshi_index()?,
index_sats: index.has_satoshi_index()?,
sat_ranges_since_flush: 0,
outputs_cached: 0,
outputs_inserted_since_flush: 0,
Expand Down Expand Up @@ -90,7 +90,7 @@ impl Updater {
Some(progress_bar)
};

let rx = Self::fetch_blocks_from(index, self.height, self.index_satoshis)?;
let rx = Self::fetch_blocks_from(index, self.height, self.index_sats)?;

let mut uncommitted = 0;
loop {
Expand Down Expand Up @@ -157,7 +157,7 @@ impl Updater {
fn fetch_blocks_from(
index: &Index,
mut height: u64,
index_satoshis: bool,
index_sats: bool,
) -> Result<mpsc::Receiver<BlockData>> {
let (tx, rx) = mpsc::sync_channel(32);

Expand All @@ -166,7 +166,7 @@ impl Updater {
let client =
Client::new(&index.rpc_url, index.auth.clone()).context("failed to connect to RPC URL")?;

let with_transactions = index_satoshis || index.chain != Chain::Mainnet;
let with_transactions = index_sats || index.chain != Chain::Mainnet;

thread::spawn(move || loop {
if let Some(height_limit) = height_limit {
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Updater {
let mut inscription_id_to_satpoint = wtx.open_table(INSCRIPTION_ID_TO_SATPOINT)?;
let mut satpoint_to_inscription_id = wtx.open_table(SATPOINT_TO_INSCRIPTION_ID)?;

if self.index_satoshis {
if self.index_sats {
let mut sat_to_inscription_id = wtx.open_table(SAT_TO_INSCRIPTION_ID)?;
let mut sat_to_satpoint = wtx.open_table(SAT_TO_SATPOINT)?;
let mut outpoint_to_sat_ranges = wtx.open_table(OUTPOINT_TO_SAT_RANGES)?;
Expand Down Expand Up @@ -504,7 +504,7 @@ impl Updater {
self.outputs_cached
);

if self.index_satoshis {
if self.index_sats {
log::info!(
"Flushing {} entries ({:.1}% resulting from {} insertions) from memory to database",
self.cache.len(),
Expand Down
2 changes: 1 addition & 1 deletion src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub(crate) struct Options {
#[clap(long, help = "Use index at <INDEX>.")]
pub(crate) index: Option<PathBuf>,
#[clap(long, help = "Index current location of all satoshis.")]
pub(crate) index_satoshis: bool,
pub(crate) index_sats: bool,
#[clap(long, help = "Use regtest.")]
regtest: bool,
#[clap(long, help = "Connect to Bitcoin Core RPC at <RPC_URL>.")]
Expand Down
18 changes: 9 additions & 9 deletions src/subcommand/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ impl Server {
.map_err(|err| ServerError::Internal(anyhow!("error getting rare sat satpoints: {err}")))?
.ok_or_else(|| {
ServerError::NotFound(
"tracking rare sats requires index created with `--index-satoshis` flag".into(),
"tracking rare sats requires index created with `--index-sats` flag".into(),
)
})?,
))
Expand Down Expand Up @@ -1174,7 +1174,7 @@ mod tests {

#[test]
fn output_with_satoshi_index() {
TestServer::new_with_args(&["--index-satoshis"]).assert_response_regex(
TestServer::new_with_args(&["--index-sats"]).assert_response_regex(
"/output/4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0",
StatusCode::OK,
".*<title>Output 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0</title>.*<h1>Output <span class=monospace>4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0</span></h1>
Expand Down Expand Up @@ -1422,7 +1422,7 @@ next.*",

#[test]
fn rare_with_index() {
TestServer::new_with_args(&["--index-satoshis"]).assert_response(
TestServer::new_with_args(&["--index-sats"]).assert_response(
"/rare.txt",
StatusCode::OK,
"sat\tsatpoint
Expand All @@ -1436,13 +1436,13 @@ next.*",
TestServer::new_with_args(&[]).assert_response(
"/rare.txt",
StatusCode::NOT_FOUND,
"tracking rare sats requires index created with `--index-satoshis` flag",
"tracking rare sats requires index created with `--index-sats` flag",
);
}

#[test]
fn show_rare_txt_in_header_with_satoshi_index() {
TestServer::new_with_args(&["--index-satoshis"]).assert_response_regex(
TestServer::new_with_args(&["--index-sats"]).assert_response_regex(
"/",
StatusCode::OK,
".*
Expand Down Expand Up @@ -1535,7 +1535,7 @@ next.*",

#[test]
fn outputs_traversed_are_tracked() {
let server = TestServer::new_with_args(&["--index-satoshis"]);
let server = TestServer::new_with_args(&["--index-sats"]);

assert_eq!(
server
Expand Down Expand Up @@ -1571,7 +1571,7 @@ next.*",

#[test]
fn coinbase_sat_ranges_are_tracked() {
let server = TestServer::new_with_args(&["--index-satoshis"]);
let server = TestServer::new_with_args(&["--index-sats"]);

assert_eq!(
server
Expand Down Expand Up @@ -1606,7 +1606,7 @@ next.*",

#[test]
fn split_sat_ranges_are_tracked() {
let server = TestServer::new_with_args(&["--index-satoshis"]);
let server = TestServer::new_with_args(&["--index-sats"]);

assert_eq!(
server
Expand Down Expand Up @@ -1636,7 +1636,7 @@ next.*",

#[test]
fn fee_sat_ranges_are_tracked() {
let server = TestServer::new_with_args(&["--index-satoshis"]);
let server = TestServer::new_with_args(&["--index-sats"]);

assert_eq!(
server
Expand Down
6 changes: 3 additions & 3 deletions tests/find.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::*;
#[test]
fn find_command_returns_satpoint_for_sat() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("--index-satoshis find 0")
CommandBuilder::new("--index-sats find 0")
.rpc_server(&rpc_server)
.expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0:0\n")
.run();
Expand All @@ -12,7 +12,7 @@ fn find_command_returns_satpoint_for_sat() {
#[test]
fn unmined_sat() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("--index-satoshis find 5000000000")
CommandBuilder::new("--index-sats find 5000000000")
.rpc_server(&rpc_server)
.expected_stderr("error: sat has not been mined as of index height\n")
.expected_exit_code(1)
Expand All @@ -24,7 +24,7 @@ fn no_satoshi_index() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("find 0")
.rpc_server(&rpc_server)
.expected_stderr("error: find requires index created with `--index-satoshis` flag\n")
.expected_stderr("error: find requires index created with `--index-sats` flag\n")
.expected_exit_code(1)
.run();
}
2 changes: 1 addition & 1 deletion tests/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use super::*;
#[test]
fn json_with_satoshi_index() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("--index-satoshis info")
CommandBuilder::new("--index-sats info")
.rpc_server(&rpc_server)
.stdout_regex(
r#"\{"blocks_indexed":1,"branch_pages":\d+,"fragmented_bytes":\d+,"index_file_size":\d+,"leaf_pages":\d+,"metadata_bytes":\d+,"sat_ranges":1,"outputs_traversed":1,"page_size":\d+,"stored_bytes":\d+,"transactions":\[\{"starting_block_count":0,"starting_timestamp":\d+\}\],"tree_height":\d+,"utxos_indexed":1\}"#
Expand Down
6 changes: 3 additions & 3 deletions tests/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use super::*;
fn output_found() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new(
"--index-satoshis list 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0",
"--index-sats list 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0",
)
.rpc_server(&rpc_server)
.expected_stdout("4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0\t0\t5000000000\tmythic\tnvtdijuwxlp\n")
Expand All @@ -15,7 +15,7 @@ fn output_found() {
fn output_not_found() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new(
"--index-satoshis list 0000000000000000000000000000000000000000000000000000000000000000:0",
"--index-sats list 0000000000000000000000000000000000000000000000000000000000000000:0",
)
.rpc_server(&rpc_server)
.expected_exit_code(1)
Expand All @@ -28,7 +28,7 @@ fn no_satoshi_index() {
let rpc_server = test_bitcoincore_rpc::spawn();
CommandBuilder::new("list 4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b:0")
.rpc_server(&rpc_server)
.expected_stderr("error: list requires index created with `--index-satoshis` flag\n")
.expected_stderr("error: list requires index created with `--index-sats` flag\n")
.expected_exit_code(1)
.run();
}
Loading

0 comments on commit f4e115d

Please sign in to comment.