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

Remove outdated rune functionality #760

Merged
merged 2 commits into from
Nov 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
27 changes: 0 additions & 27 deletions src/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@ impl Chain {
}
}

pub(crate) fn default_publish_url(self) -> Option<Url> {
match self {
Self::Mainnet => Some("https://ordinals.com".parse().unwrap()),
Self::Signet => Some("https://signet.ordinals.com".parse().unwrap()),
Self::Regtest | Self::Testnet => None,
}
}

pub(crate) fn default_rpc_port(self) -> u16 {
match self {
Self::Mainnet => 8332,
Expand Down Expand Up @@ -80,22 +72,3 @@ impl Display for Chain {
)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[test]
fn default_publish_url() {
assert_eq!(
Chain::Mainnet.default_publish_url(),
Some("https://ordinals.com".parse().unwrap())
);
assert_eq!(
Chain::Signet.default_publish_url(),
Some("https://signet.ordinals.com".parse().unwrap())
);
assert_eq!(Chain::Testnet.default_publish_url(), None,);
assert_eq!(Chain::Regtest.default_publish_url(), None,);
}
}
52 changes: 1 addition & 51 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ use {
bitcoincore_rpc::{json::GetBlockHeaderResult, Auth, Client},
indicatif::{ProgressBar, ProgressStyle},
log::log_enabled,
redb::{
Database, MultimapTableDefinition, ReadableMultimapTable, ReadableTable, Table,
TableDefinition, WriteStrategy, WriteTransaction,
},
redb::{Database, ReadableTable, Table, TableDefinition, WriteStrategy, WriteTransaction},
std::collections::HashMap,
std::sync::atomic::{AtomicBool, Ordering},
};
Expand All @@ -19,8 +16,6 @@ mod updater;

const HEIGHT_TO_BLOCK_HASH: TableDefinition<u64, [u8; 32]> =
TableDefinition::new("HEIGHT_TO_BLOCK_HASH");
const ORDINAL_TO_RUNE_HASHES: MultimapTableDefinition<u64, [u8; 32]> =
MultimapTableDefinition::new("ORDINAL_TO_RUNE_HASHES");
const ORDINAL_TO_SATPOINT: TableDefinition<u64, [u8; 44]> =
TableDefinition::new("ORDINAL_TO_SATPOINT");
const OUTPOINT_TO_ORDINAL_RANGES: TableDefinition<[u8; 36], [u8]> =
Expand Down Expand Up @@ -151,7 +146,6 @@ impl Index {
tx
};

tx.open_multimap_table(ORDINAL_TO_RUNE_HASHES)?;
tx.open_table(RUNE_HASH_TO_RUNE)?;
tx.open_table(HEIGHT_TO_BLOCK_HASH)?;
tx.open_table(ORDINAL_TO_SATPOINT)?;
Expand Down Expand Up @@ -300,19 +294,6 @@ impl Index {
Ok(blocks)
}

pub(crate) fn inscriptions(&self, ordinal: Ordinal) -> Result<Vec<sha256::Hash>> {
let rtx = self.database.begin_read()?;

let table = rtx.open_multimap_table(ORDINAL_TO_RUNE_HASHES)?;

let mut inscriptions = Vec::new();
for value in table.get(&ordinal.0)? {
inscriptions.push(sha256::Hash::from_inner(*value));
}

Ok(inscriptions)
}

pub(crate) fn rare_ordinal_satpoints(&self) -> Result<Vec<(Ordinal, SatPoint)>> {
let mut result = Vec::new();

Expand Down Expand Up @@ -373,37 +354,6 @@ impl Index {
)
}

pub(crate) fn rune(&self, hash: sha256::Hash) -> Result<Option<Rune>> {
Ok(
self
.database
.begin_read()?
.open_table(RUNE_HASH_TO_RUNE)?
.get(hash.as_inner())?
.map(serde_json::from_str)
.transpose()?,
)
}

pub(crate) fn insert_rune(&self, rune: &Rune) -> Result<(bool, sha256::Hash)> {
let json = serde_json::to_string(rune)?;
let hash = sha256::Hash::hash(json.as_ref());
let wtx = self.begin_write()?;

let created = wtx
.open_table(RUNE_HASH_TO_RUNE)?
.insert(hash.as_inner(), &json)?
.is_none();

wtx
.open_multimap_table(ORDINAL_TO_RUNE_HASHES)?
.insert(&rune.ordinal.n(), &hash.into_inner())?;

wtx.commit()?;

Ok((created, hash))
}

pub(crate) fn find(&self, ordinal: u64) -> Result<Option<SatPoint>> {
if self.height()? < Ordinal(ordinal).height() {
return Ok(None);
Expand Down
5 changes: 1 addition & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use {
options::Options,
ordinal::Ordinal,
rarity::Rarity,
rune::Rune,
sat_point::SatPoint,
subcommand::Subcommand,
tally::Tally,
Expand All @@ -23,7 +22,7 @@ use {
blockdata::constants::COIN_VALUE,
consensus::{self, Decodable, Encodable},
hash_types::BlockHash,
hashes::{sha256, Hash},
hashes::Hash,
Address, Amount, Block, OutPoint, Script, Sequence, Transaction, TxIn, TxOut, Txid,
},
bitcoincore_rpc::RpcApi,
Expand All @@ -32,7 +31,6 @@ use {
clap::Parser,
derive_more::{Display, FromStr},
regex::Regex,
reqwest::Url,
serde::{Deserialize, Serialize},
std::{
cmp::Ordering,
Expand Down Expand Up @@ -75,7 +73,6 @@ mod index;
mod options;
mod ordinal;
mod rarity;
mod rune;
mod sat_point;
mod subcommand;
mod tally;
Expand Down
9 changes: 0 additions & 9 deletions src/options.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,15 +100,6 @@ impl Options {
Ok(client)
}

pub(crate) fn bitcoin_rpc_client_mainnet_forbidden(&self, command: &str) -> Result<Client> {
let client = self.bitcoin_rpc_client()?;

if self.chain == Chain::Mainnet {
bail!("`{command}` is unstable and not yet supported on mainnet.");
}
Ok(client)
}

pub(crate) fn bitcoin_rpc_client_for_wallet_command(&self, command: &str) -> Result<Client> {
let client = self.bitcoin_rpc_client()?;

Expand Down
8 changes: 0 additions & 8 deletions src/rune.rs

This file was deleted.

4 changes: 0 additions & 4 deletions src/subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ mod info;
mod list;
mod parse;
mod range;
mod rune;
mod server;
mod supply;
mod traits;
Expand All @@ -22,8 +21,6 @@ pub(crate) enum Subcommand {
List(list::List),
Parse(parse::Parse),
Range(range::Range),
#[clap(subcommand)]
Rune(rune::Rune),
Server(server::Server),
Supply,
Traits(traits::Traits),
Expand All @@ -41,7 +38,6 @@ impl Subcommand {
Self::List(list) => list.run(options),
Self::Parse(parse) => parse.run(),
Self::Range(range) => range.run(),
Self::Rune(rune) => rune.run(options),
Self::Server(server) => {
let index = Arc::new(Index::open(&options)?);
let handle = axum_server::Handle::new();
Expand Down
16 changes: 0 additions & 16 deletions src/subcommand/rune.rs

This file was deleted.

54 changes: 0 additions & 54 deletions src/subcommand/rune/publish.rs

This file was deleted.

Loading