From ff13019efab8d0fcdba185b147eaa6b7aa45439a Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Sat, 10 Feb 2024 03:57:34 +0700 Subject: [PATCH 1/5] remove duplicate code --- src/index/updater.rs | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/index/updater.rs b/src/index/updater.rs index af3789b5da..db24d37af2 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -57,15 +57,20 @@ impl<'index> Updater<'_> { let mut wtx = self.index.begin_write()?; let starting_height = u32::try_from(self.index.client.get_block_count()?).unwrap() + 1; - wtx - .open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)? - .insert( - &self.height, - &SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .map(|duration| duration.as_millis()) - .unwrap_or(0), - )?; + let write_height_to_ts = |wtx: &mut WriteTransaction, height: &u32| { + wtx + .open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP) + .expect("open table failed") + .insert( + height, + &SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|duration| duration.as_millis()) + .unwrap_or(0), + ) + .expect("insert height failed"); + }; + write_height_to_ts(&mut wtx, &self.height); let mut progress_bar = if cfg!(test) || log_enabled!(log::Level::Info) @@ -128,15 +133,7 @@ impl<'index> Updater<'_> { // write transaction break; } - wtx - .open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)? - .insert( - &self.height, - &SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .map(|duration| duration.as_millis()) - .unwrap_or(0), - )?; + write_height_to_ts(&mut wtx, &self.height); } if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) { From c0ea31179c9abefcabafb26eeaeb0356b60f21eb Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:46:20 +0700 Subject: [PATCH 2/5] format code/IDE warning import --- crates/ordinals/src/epoch.rs | 4 +- crates/ordinals/src/height.rs | 2 +- crates/test-bitcoincore-rpc/src/lib.rs | 2 +- crates/test-bitcoincore-rpc/src/server.rs | 4 +- src/decimal.rs | 2 +- src/index.rs | 6 +- src/index/entry.rs | 4 +- src/index/fetcher.rs | 4 +- src/index/reorg.rs | 4 +- src/index/updater.rs | 2 +- src/index/updater/rune_updater.rs | 4 +- src/inscriptions/envelope.rs | 32 +- src/inscriptions/media.rs | 8 +- src/lib.rs | 4 +- src/object.rs | 1 + src/outgoing.rs | 2 +- src/runes.rs | 472 +++++++++++----------- src/runes/pile.rs | 4 +- src/runes/rune.rs | 12 +- src/runes/rune_id.rs | 2 +- src/runes/runestone.rs | 58 +-- src/runes/varint.rs | 2 +- src/subcommand/server.rs | 44 +- src/subcommand/wallet/restore.rs | 2 +- src/templates/preview.rs | 20 +- src/templates/rune.rs | 6 +- src/wallet.rs | 4 +- src/wallet/inscribe/batch.rs | 4 +- src/wallet/transaction_builder.rs | 4 +- tests/index.rs | 2 +- 30 files changed, 361 insertions(+), 360 deletions(-) diff --git a/crates/ordinals/src/epoch.rs b/crates/ordinals/src/epoch.rs index 9e7b861ee9..43d0b872dc 100644 --- a/crates/ordinals/src/epoch.rs +++ b/crates/ordinals/src/epoch.rs @@ -225,7 +225,7 @@ mod tests { assert_eq!(Epoch::from(Sat(1)), 0); assert_eq!(Epoch::from(Epoch(1).starting_sat()), 1); assert_eq!(Epoch::from(Epoch(1).starting_sat() + 1), 1); - assert_eq!(Epoch::from(Sat(u64::max_value())), 33); + assert_eq!(Epoch::from(Sat(u64::MAX)), 33); } #[test] @@ -237,6 +237,6 @@ mod tests { #[test] fn first_post_subsidy() { assert_eq!(Epoch::FIRST_POST_SUBSIDY.subsidy(), 0); - assert!((Epoch(Epoch::FIRST_POST_SUBSIDY.0 - 1)).subsidy() > 0); + assert!(Epoch(Epoch::FIRST_POST_SUBSIDY.0 - 1).subsidy() > 0); } } diff --git a/crates/ordinals/src/height.rs b/crates/ordinals/src/height.rs index ffae6b5bb2..0aaa38921e 100644 --- a/crates/ordinals/src/height.rs +++ b/crates/ordinals/src/height.rs @@ -106,7 +106,7 @@ mod tests { u64::from(SUBSIDY_HALVING_INTERVAL) * 5000000000 + 2500000000 ); assert_eq!( - Height(u32::max_value()).starting_sat(), + Height(u32::MAX).starting_sat(), *Epoch::STARTING_SATS.last().unwrap() ); } diff --git a/crates/test-bitcoincore-rpc/src/lib.rs b/crates/test-bitcoincore-rpc/src/lib.rs index 840067e274..c5b11244b4 100644 --- a/crates/test-bitcoincore-rpc/src/lib.rs +++ b/crates/test-bitcoincore-rpc/src/lib.rs @@ -139,7 +139,7 @@ pub struct TransactionTemplate<'a> { #[derive(Serialize, Deserialize)] pub struct JsonOutPoint { - txid: bitcoin::Txid, + txid: Txid, vout: u32, } diff --git a/crates/test-bitcoincore-rpc/src/server.rs b/crates/test-bitcoincore-rpc/src/server.rs index 9cc80a6034..94b93a698a 100644 --- a/crates/test-bitcoincore-rpc/src/server.rs +++ b/crates/test-bitcoincore-rpc/src/server.rs @@ -180,7 +180,7 @@ impl Api for Server { .utxos .get(&OutPoint { txid, vout }) .map(|&value| GetTxOutResult { - bestblock: bitcoin::BlockHash::all_zeros(), + bestblock: BlockHash::all_zeros(), confirmations: 0, value, script_pub_key: GetRawTransactionResultVoutScriptPubKey { @@ -651,7 +651,7 @@ impl Api for Server { &self, _label: Option, _address_type: Option, - ) -> Result { + ) -> Result { let secp256k1 = Secp256k1::new(); let key_pair = KeyPair::new(&secp256k1, &mut rand::thread_rng()); let (public_key, _parity) = XOnlyPublicKey::from_keypair(&key_pair); diff --git a/src/decimal.rs b/src/decimal.rs index 051ed907fd..b20593bfe3 100644 --- a/src/decimal.rs +++ b/src/decimal.rs @@ -25,7 +25,7 @@ impl Decimal { } impl Display for Decimal { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { let magnitude = 10u128.pow(self.scale.into()); let integer = self.value / magnitude; diff --git a/src/index.rs b/src/index.rs index a2e27b6b13..5b69b704a6 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1026,7 +1026,7 @@ impl Index { }; self - .get_children_by_sequence_number_paginated(sequence_number, usize::max_value(), 0) + .get_children_by_sequence_number_paginated(sequence_number, usize::MAX, 0) .map(|(children, _more)| children) } @@ -1885,7 +1885,7 @@ impl Index { Some(sat) => { if self.index_sats { // unbound inscriptions should not be assigned to a sat - assert!(satpoint.outpoint != unbound_outpoint()); + assert_ne!(satpoint.outpoint, unbound_outpoint()); assert!(rtx .open_multimap_table(SAT_TO_SEQUENCE_NUMBER) @@ -1913,7 +1913,7 @@ impl Index { } None => { if self.index_sats { - assert!(satpoint.outpoint == unbound_outpoint()) + assert_eq!(satpoint.outpoint, unbound_outpoint()) } } } diff --git a/src/index/entry.rs b/src/index/entry.rs index 11f7e8c829..91923082fe 100644 --- a/src/index/entry.rs +++ b/src/index/entry.rs @@ -326,7 +326,7 @@ impl Entry for OutPoint { type Value = OutPointValue; fn load(value: Self::Value) -> Self { - Decodable::consensus_decode(&mut io::Cursor::new(value)).unwrap() + Decodable::consensus_decode(&mut Cursor::new(value)).unwrap() } fn store(self) -> Self::Value { @@ -342,7 +342,7 @@ impl Entry for SatPoint { type Value = SatPointValue; fn load(value: Self::Value) -> Self { - Decodable::consensus_decode(&mut io::Cursor::new(value)).unwrap() + Decodable::consensus_decode(&mut Cursor::new(value)).unwrap() } fn store(self) -> Self::Value { diff --git a/src/index/fetcher.rs b/src/index/fetcher.rs index 46d160da4b..fd5b221090 100644 --- a/src/index/fetcher.rs +++ b/src/index/fetcher.rs @@ -79,7 +79,7 @@ impl Fetcher { log::info!("failed to fetch raw transactions, retrying: {}", error); - tokio::time::sleep(tokio::time::Duration::from_millis( + tokio::time::sleep(Duration::from_millis( 100 * u64::pow(2, retries), )) .await; @@ -113,7 +113,7 @@ impl Fetcher { .map_err(|e| anyhow!("Result for batched JSON-RPC response not valid hex: {e}")) }) .and_then(|hex| { - bitcoin::consensus::deserialize(&hex).map_err(|e| { + consensus::deserialize(&hex).map_err(|e| { anyhow!("Result for batched JSON-RPC response not valid bitcoin tx: {e}") }) }) diff --git a/src/index/reorg.rs b/src/index/reorg.rs index e9db3471e7..9337103f96 100644 --- a/src/index/reorg.rs +++ b/src/index/reorg.rs @@ -6,8 +6,8 @@ pub(crate) enum ReorgError { Unrecoverable, } -impl fmt::Display for ReorgError { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +impl Display for ReorgError { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { ReorgError::Recoverable { height, depth } => { write!(f, "{depth} block deep reorg detected at height {height}") diff --git a/src/index/updater.rs b/src/index/updater.rs index db24d37af2..22f2e42376 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -254,7 +254,7 @@ impl<'index> Updater<'_> { // else runs a request, we keep this to 12. const PARALLEL_REQUESTS: usize = 12; - std::thread::spawn(move || { + thread::spawn(move || { let rt = tokio::runtime::Builder::new_multi_thread() .enable_all() .build() diff --git a/src/index/updater/rune_updater.rs b/src/index/updater/rune_updater.rs index b6217b5e40..6bed6f14a6 100644 --- a/src/index/updater/rune_updater.rs +++ b/src/index/updater/rune_updater.rs @@ -124,7 +124,7 @@ impl<'a, 'db, 'tx> RuneUpdater<'a, 'db, 'tx> { mint.limit.unwrap_or(runes::MAX_LIMIT) } } else { - u128::max_value() + u128::MAX }, divisibility: etching.divisibility, id: u128::from(self.height) << 16 | u128::from(index), @@ -307,7 +307,7 @@ impl<'a, 'db, 'tx> RuneUpdater<'a, 'db, 'tx> { mint.limit.unwrap_or(runes::MAX_LIMIT) } } else { - u128::max_value() + u128::MAX } - balance, symbol, timestamp: self.timestamp, diff --git a/src/inscriptions/envelope.rs b/src/inscriptions/envelope.rs index 76836f7733..0ef863c831 100644 --- a/src/inscriptions/envelope.rs +++ b/src/inscriptions/envelope.rs @@ -283,11 +283,11 @@ mod tests { #[test] fn ignore_key_path_spends() { assert_eq!( - parse(&[Witness::from_slice(&[bitcoin::script::Builder::new() - .push_opcode(bitcoin::opcodes::OP_FALSE) - .push_opcode(bitcoin::opcodes::all::OP_IF) + parse(&[Witness::from_slice(&[script::Builder::new() + .push_opcode(opcodes::OP_FALSE) + .push_opcode(opcodes::all::OP_IF) .push_slice(PROTOCOL_ID) - .push_opcode(bitcoin::opcodes::all::OP_ENDIF) + .push_opcode(opcodes::all::OP_ENDIF) .into_script() .into_bytes()])]), Vec::new() @@ -298,11 +298,11 @@ mod tests { fn ignore_key_path_spends_with_annex() { assert_eq!( parse(&[Witness::from_slice(&[ - bitcoin::script::Builder::new() - .push_opcode(bitcoin::opcodes::OP_FALSE) - .push_opcode(bitcoin::opcodes::all::OP_IF) + script::Builder::new() + .push_opcode(opcodes::OP_FALSE) + .push_opcode(opcodes::all::OP_IF) .push_slice(PROTOCOL_ID) - .push_opcode(bitcoin::opcodes::all::OP_ENDIF) + .push_opcode(opcodes::all::OP_ENDIF) .into_script() .into_bytes(), vec![0x50] @@ -315,11 +315,11 @@ mod tests { fn parse_from_tapscript() { assert_eq!( parse(&[Witness::from_slice(&[ - bitcoin::script::Builder::new() - .push_opcode(bitcoin::opcodes::OP_FALSE) - .push_opcode(bitcoin::opcodes::all::OP_IF) + script::Builder::new() + .push_opcode(opcodes::OP_FALSE) + .push_opcode(opcodes::all::OP_IF) .push_slice(PROTOCOL_ID) - .push_opcode(bitcoin::opcodes::all::OP_ENDIF) + .push_opcode(opcodes::all::OP_ENDIF) .into_script() .into_bytes(), Vec::new() @@ -332,11 +332,11 @@ mod tests { #[test] fn ignore_unparsable_scripts() { - let mut script_bytes = bitcoin::script::Builder::new() - .push_opcode(bitcoin::opcodes::OP_FALSE) - .push_opcode(bitcoin::opcodes::all::OP_IF) + let mut script_bytes = script::Builder::new() + .push_opcode(opcodes::OP_FALSE) + .push_opcode(opcodes::all::OP_IF) .push_slice(PROTOCOL_ID) - .push_opcode(bitcoin::opcodes::all::OP_ENDIF) + .push_opcode(opcodes::all::OP_ENDIF) .into_script() .into_bytes(); script_bytes.push(0x01); diff --git a/src/inscriptions/media.rs b/src/inscriptions/media.rs index d2ac81acff..8d21b0922d 100644 --- a/src/inscriptions/media.rs +++ b/src/inscriptions/media.rs @@ -166,21 +166,21 @@ mod tests { fn for_extension() { assert_eq!( Media::content_type_for_path(Path::new("pepe.jpg")).unwrap(), - ("image/jpeg", BrotliEncoderMode::BROTLI_MODE_GENERIC) + ("image/jpeg", BROTLI_MODE_GENERIC) ); assert_eq!( Media::content_type_for_path(Path::new("pepe.jpeg")).unwrap(), - ("image/jpeg", BrotliEncoderMode::BROTLI_MODE_GENERIC) + ("image/jpeg", BROTLI_MODE_GENERIC) ); assert_eq!( Media::content_type_for_path(Path::new("pepe.JPG")).unwrap(), - ("image/jpeg", BrotliEncoderMode::BROTLI_MODE_GENERIC) + ("image/jpeg", BROTLI_MODE_GENERIC) ); assert_eq!( Media::content_type_for_path(Path::new("pepe.txt")).unwrap(), ( "text/plain;charset=utf-8", - BrotliEncoderMode::BROTLI_MODE_TEXT + BROTLI_MODE_TEXT ) ); assert_regex_match!( diff --git a/src/lib.rs b/src/lib.rs index e2fdc9449c..0341b549de 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -123,7 +123,7 @@ type Result = std::result::Result; static SHUTTING_DOWN: AtomicBool = AtomicBool::new(false); static LISTENERS: Mutex> = Mutex::new(Vec::new()); -static INDEXER: Mutex>> = Mutex::new(Option::None); +static INDEXER: Mutex>> = Mutex::new(None); const TARGET_POSTAGE: Amount = Amount::from_sat(10_000); @@ -183,7 +183,7 @@ fn unbound_outpoint() -> OutPoint { } } -pub fn parse_ord_server_args(args: &str) -> (Options, crate::subcommand::server::Server) { +pub fn parse_ord_server_args(args: &str) -> (Options, subcommand::server::Server) { match Arguments::try_parse_from(args.split_whitespace()) { Ok(arguments) => match arguments.subcommand { Subcommand::Server(server) => (arguments.options, server), diff --git a/src/object.rs b/src/object.rs index 611f592934..4f737ccfda 100644 --- a/src/object.rs +++ b/src/object.rs @@ -1,4 +1,5 @@ use super::*; +use bitcoin::hashes::Hash; #[derive(Debug, PartialEq, Clone)] pub enum Object { diff --git a/src/outgoing.rs b/src/outgoing.rs index 63927e3dd8..108b565b43 100644 --- a/src/outgoing.rs +++ b/src/outgoing.rs @@ -9,7 +9,7 @@ pub enum Outgoing { } impl Display for Outgoing { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Self::Amount(amount) => write!(f, "{}", amount.to_string().to_lowercase()), Self::InscriptionId(inscription_id) => inscription_id.fmt(f), diff --git a/src/runes.rs b/src/runes.rs index 3ee6a73400..47adc3410a 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -50,7 +50,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -140,7 +140,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -167,12 +167,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -194,7 +194,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -224,7 +224,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -251,12 +251,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(block_two_minimum), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } } @@ -274,7 +274,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -304,7 +304,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -331,12 +331,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RESERVED - 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } } @@ -354,7 +354,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -381,7 +381,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RESERVED), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -391,7 +391,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], )], ); @@ -403,7 +403,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -431,7 +431,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RESERVED), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -441,7 +441,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RESERVED + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 4, number: 1, ..Default::default() @@ -454,14 +454,14 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ( OutPoint { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ], ); @@ -479,7 +479,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -508,12 +508,12 @@ mod tests { rune: Rune(RUNE), etching: txid, divisibility: 1, - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -530,12 +530,12 @@ mod tests { edicts: vec![ Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -563,12 +563,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -585,12 +585,12 @@ mod tests { edicts: vec![ Edict { id: 0, - amount: u128::max_value() / 2, + amount: u128::MAX / 2, output: 0, }, Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -618,13 +618,13 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, symbol: None, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -799,7 +799,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -826,7 +826,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -836,7 +836,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -846,7 +846,7 @@ mod tests { Runestone { edicts: vec![Edict { id: id.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], ..Default::default() @@ -864,7 +864,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -874,7 +874,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -891,7 +891,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -939,7 +939,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1001,7 +1001,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching::default()), @@ -1046,7 +1046,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1073,7 +1073,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1083,7 +1083,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1105,10 +1105,10 @@ mod tests { [( id, RuneEntry { - burned: u128::max_value(), + burned: u128::MAX, etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1129,7 +1129,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1156,7 +1156,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1166,7 +1166,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1184,7 +1184,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1194,7 +1194,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -1211,7 +1211,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1238,7 +1238,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1248,7 +1248,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1267,9 +1267,9 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, - burned: u128::max_value(), + burned: u128::MAX, ..Default::default() }, )], @@ -1289,7 +1289,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1316,7 +1316,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1326,7 +1326,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1351,7 +1351,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1361,7 +1361,7 @@ mod tests { txid: txid1, vout: 1, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -1378,7 +1378,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1405,7 +1405,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1415,7 +1415,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1440,7 +1440,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1450,7 +1450,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -1467,7 +1467,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1494,7 +1494,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1504,7 +1504,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1529,8 +1529,8 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), - burned: u128::max_value(), + supply: u128::MAX, + burned: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1552,7 +1552,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1579,7 +1579,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1589,7 +1589,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -1607,7 +1607,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1617,7 +1617,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -1634,7 +1634,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1661,12 +1661,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); context.rpc_server.broadcast_tx(TransactionTemplate { @@ -1675,7 +1675,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1697,12 +1697,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -1718,7 +1718,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1745,7 +1745,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1755,7 +1755,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], )], ); @@ -1765,7 +1765,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1793,7 +1793,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1803,7 +1803,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -1816,14 +1816,14 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ( OutPoint { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ], ); @@ -1842,7 +1842,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1852,7 +1852,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -1864,7 +1864,7 @@ mod tests { txid: txid2, vout: 0, }, - vec![(id0, u128::max_value()), (id1, u128::max_value())], + vec![(id0, u128::MAX), (id1, u128::MAX)], )], ); } @@ -1881,7 +1881,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1908,7 +1908,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1918,7 +1918,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], )], ); @@ -1928,7 +1928,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -1956,7 +1956,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -1966,7 +1966,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -1979,14 +1979,14 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ( OutPoint { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ], ); @@ -2005,7 +2005,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2015,7 +2015,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2027,7 +2027,7 @@ mod tests { txid: txid2, vout: 0, }, - vec![(id0, u128::max_value()), (id1, u128::max_value())], + vec![(id0, u128::MAX), (id1, u128::MAX)], )], ); @@ -2039,12 +2039,12 @@ mod tests { edicts: vec![ Edict { id: id0.into(), - amount: u128::max_value() / 2, + amount: u128::MAX / 2, output: 1, }, Edict { id: id1.into(), - amount: u128::max_value() / 2, + amount: u128::MAX / 2, output: 1, }, ], @@ -2064,7 +2064,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2074,7 +2074,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2088,8 +2088,8 @@ mod tests { vout: 0, }, vec![ - (id0, u128::max_value() / 2 + 1), - (id1, u128::max_value() / 2 + 1), + (id0, u128::MAX / 2 + 1), + (id1, u128::MAX / 2 + 1), ], ), ( @@ -2097,7 +2097,7 @@ mod tests { txid: txid3, vout: 1, }, - vec![(id0, u128::max_value() / 2), (id1, u128::max_value() / 2)], + vec![(id0, u128::MAX / 2), (id1, u128::MAX / 2)], ), ], ); @@ -2115,7 +2115,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2142,7 +2142,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2152,7 +2152,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], )], ); @@ -2162,7 +2162,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2190,7 +2190,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2200,7 +2200,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2213,14 +2213,14 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ( OutPoint { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ], ); @@ -2232,12 +2232,12 @@ mod tests { edicts: vec![ Edict { id: id0.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, Edict { id: id1.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -2257,7 +2257,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2267,7 +2267,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2279,7 +2279,7 @@ mod tests { txid: txid2, vout: 0, }, - vec![(id0, u128::max_value()), (id1, u128::max_value())], + vec![(id0, u128::MAX), (id1, u128::MAX)], )], ); } @@ -2297,7 +2297,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2324,7 +2324,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2334,7 +2334,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -2357,12 +2357,12 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 1 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 1 }, vec![(id, u128::MAX)])], ); } @@ -2378,7 +2378,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2403,7 +2403,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2431,7 +2431,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, ..Default::default() }, @@ -2441,7 +2441,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2454,14 +2454,14 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ( OutPoint { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ], ); @@ -2479,7 +2479,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2506,7 +2506,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2516,7 +2516,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -2532,7 +2532,7 @@ mod tests { }, Edict { id: id.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -2551,7 +2551,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2561,7 +2561,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -2578,7 +2578,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2605,7 +2605,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2615,7 +2615,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], )], ); @@ -2625,7 +2625,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2653,7 +2653,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2663,7 +2663,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2676,14 +2676,14 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ( OutPoint { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ], ); @@ -2695,12 +2695,12 @@ mod tests { edicts: vec![ Edict { id: id0.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, Edict { id: id1.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -2720,7 +2720,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2730,7 +2730,7 @@ mod tests { RuneEntry { etching: txid1, rune: Rune(RUNE + 1), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 3, number: 1, ..Default::default() @@ -2743,14 +2743,14 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id1, u128::max_value())], + vec![(id1, u128::MAX)], ), ( OutPoint { txid: txid2, vout: 0, }, - vec![(id0, u128::max_value())], + vec![(id0, u128::MAX)], ), ], ); @@ -2768,7 +2768,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value() / 2, + amount: u128::MAX / 2, output: 0, }], etching: Some(Etching { @@ -2795,7 +2795,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value() / 2, + supply: u128::MAX / 2, timestamp: 2, ..Default::default() }, @@ -2805,7 +2805,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value() / 2)], + vec![(id, u128::MAX / 2)], )], ); @@ -2815,7 +2815,7 @@ mod tests { Runestone { edicts: vec![Edict { id: id.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], ..Default::default() @@ -2833,7 +2833,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value() / 2, + supply: u128::MAX / 2, timestamp: 2, ..Default::default() }, @@ -2843,7 +2843,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value() / 2)], + vec![(id, u128::MAX / 2)], )], ); } @@ -2860,7 +2860,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 1, }], etching: Some(Etching { @@ -2885,10 +2885,10 @@ mod tests { [( id, RuneEntry { - burned: u128::max_value(), + burned: u128::MAX, etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -2910,7 +2910,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2937,12 +2937,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -2960,7 +2960,7 @@ mod tests { edicts: vec![ Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, Edict { @@ -2993,12 +2993,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -3042,7 +3042,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3050,19 +3050,19 @@ mod tests { [ ( OutPoint { txid, vout: 0 }, - vec![(id, u128::max_value() / 4 + 1)], + vec![(id, u128::MAX / 4 + 1)], ), ( OutPoint { txid, vout: 1 }, - vec![(id, u128::max_value() / 4 + 1)], + vec![(id, u128::MAX / 4 + 1)], ), ( OutPoint { txid, vout: 2 }, - vec![(id, u128::max_value() / 4 + 1)], + vec![(id, u128::MAX / 4 + 1)], ), ( OutPoint { txid, vout: 3 }, - vec![(id, u128::max_value() / 4)], + vec![(id, u128::MAX / 4)], ), ], ); @@ -3115,7 +3115,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3123,19 +3123,19 @@ mod tests { [ ( OutPoint { txid, vout: 0 }, - vec![(id, 1000 + (u128::max_value() - 1000) / 4 + 1)], + vec![(id, 1000 + (u128::MAX - 1000) / 4 + 1)], ), ( OutPoint { txid, vout: 1 }, - vec![(id, (u128::max_value() - 1000) / 4 + 1)], + vec![(id, (u128::MAX - 1000) / 4 + 1)], ), ( OutPoint { txid, vout: 2 }, - vec![(id, (u128::max_value() - 1000) / 4 + 1)], + vec![(id, (u128::MAX - 1000) / 4 + 1)], ), ( OutPoint { txid, vout: 3 }, - vec![(id, (u128::max_value() - 1000) / 4)], + vec![(id, (u128::MAX - 1000) / 4)], ), ], ); @@ -3188,7 +3188,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3196,19 +3196,19 @@ mod tests { [ ( OutPoint { txid, vout: 0 }, - vec![(id, u128::max_value() / 4 + 1)], + vec![(id, u128::MAX / 4 + 1)], ), ( OutPoint { txid, vout: 1 }, - vec![(id, u128::max_value() / 4 + 1)], + vec![(id, u128::MAX / 4 + 1)], ), ( OutPoint { txid, vout: 2 }, - vec![(id, u128::max_value() / 4 + 1)], + vec![(id, u128::MAX / 4 + 1)], ), ( OutPoint { txid, vout: 3 }, - vec![(id, u128::max_value() / 4)], + vec![(id, u128::MAX / 4)], ), ], ); @@ -3282,7 +3282,7 @@ mod tests { edicts: vec![ Edict { id: 0, - amount: u128::max_value() - 3000, + amount: u128::MAX - 3000, output: 0, }, Edict { @@ -3315,7 +3315,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3323,7 +3323,7 @@ mod tests { [ ( OutPoint { txid, vout: 0 }, - vec![(id, u128::max_value() - 2000)], + vec![(id, u128::MAX - 2000)], ), (OutPoint { txid, vout: 1 }, vec![(id, 1000)]), (OutPoint { txid, vout: 2 }, vec![(id, 1000)]), @@ -3350,7 +3350,7 @@ mod tests { }, Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -3378,7 +3378,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3386,7 +3386,7 @@ mod tests { [ ( OutPoint { txid, vout: 0 }, - vec![(id, u128::max_value() - 4000 + 1000)], + vec![(id, u128::MAX - 4000 + 1000)], ), (OutPoint { txid, vout: 1 }, vec![(id, 1000)]), (OutPoint { txid, vout: 2 }, vec![(id, 1000)]), @@ -3407,7 +3407,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -3434,7 +3434,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3444,7 +3444,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -3473,7 +3473,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3484,14 +3484,14 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value() / 2 + 1)], + vec![(id, u128::MAX / 2 + 1)], ), ( OutPoint { txid: txid1, vout: 1, }, - vec![(id, u128::max_value() / 2)], + vec![(id, u128::MAX / 2)], ), ], ); @@ -3509,7 +3509,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -3536,7 +3536,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3546,7 +3546,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -3582,7 +3582,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3593,14 +3593,14 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, 1000 + (u128::max_value() - 1000) / 2 + 1)], + vec![(id, 1000 + (u128::MAX - 1000) / 2 + 1)], ), ( OutPoint { txid: txid1, vout: 1, }, - vec![(id, (u128::max_value() - 1000) / 2)], + vec![(id, (u128::MAX - 1000) / 2)], ), ], ); @@ -3618,7 +3618,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -3645,7 +3645,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3655,7 +3655,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -3691,7 +3691,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3702,14 +3702,14 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value() / 2 + 1)], + vec![(id, u128::MAX / 2 + 1)], ), ( OutPoint { txid: txid1, vout: 1, }, - vec![(id, u128::max_value() / 2)], + vec![(id, u128::MAX / 2)], ), ], ); @@ -3727,7 +3727,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -3754,7 +3754,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3764,7 +3764,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -3793,7 +3793,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3804,7 +3804,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value() - 1000)], + vec![(id, u128::MAX - 1000)], ), ( OutPoint { @@ -3829,7 +3829,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -3856,7 +3856,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3866,7 +3866,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -3878,7 +3878,7 @@ mod tests { edicts: vec![ Edict { id: id.into(), - amount: u128::max_value() - 2000, + amount: u128::MAX - 2000, output: 0, }, Edict { @@ -3902,7 +3902,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3913,7 +3913,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value() - 2000 + 1000)], + vec![(id, u128::MAX - 2000 + 1000)], ), ( OutPoint { @@ -3938,7 +3938,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -3965,7 +3965,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -3975,7 +3975,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -3992,7 +3992,7 @@ mod tests { }, Edict { id: id.into(), - amount: u128::max_value(), + amount: u128::MAX, output: 0, }, ], @@ -4011,7 +4011,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -4022,7 +4022,7 @@ mod tests { txid: txid1, vout: 0, }, - vec![(id, u128::max_value() - 4000 + 1000)], + vec![(id, u128::MAX - 4000 + 1000)], ), ( OutPoint { @@ -4061,7 +4061,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -4089,13 +4089,13 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, symbol: Some('$'), timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -4138,12 +4138,12 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, )], - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])], + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])], ); } @@ -4159,7 +4159,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -4186,7 +4186,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -4196,7 +4196,7 @@ mod tests { txid: txid0, vout: 0, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); @@ -4225,7 +4225,7 @@ mod tests { RuneEntry { etching: txid0, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() }, @@ -4235,7 +4235,7 @@ mod tests { txid: txid1, vout: 1, }, - vec![(id, u128::max_value())], + vec![(id, u128::MAX)], )], ); } @@ -4243,7 +4243,7 @@ mod tests { #[test] fn max_limit() { MAX_LIMIT - .checked_mul(u128::from(u16::max_value()) * 144 * 365 * 1_000_000_000) + .checked_mul(u128::from(u16::MAX) * 144 * 365 * 1_000_000_000) .unwrap(); } diff --git a/src/runes/pile.rs b/src/runes/pile.rs index 8ab1a4e4ee..f3f004f1fc 100644 --- a/src/runes/pile.rs +++ b/src/runes/pile.rs @@ -123,7 +123,7 @@ mod tests { ); assert_eq!( Pile { - amount: u128::max_value(), + amount: u128::MAX, divisibility: 18, symbol: None, } @@ -132,7 +132,7 @@ mod tests { ); assert_eq!( Pile { - amount: u128::max_value(), + amount: u128::MAX, divisibility: MAX_DIVISIBILITY, symbol: None, } diff --git a/src/runes/rune.rs b/src/runes/rune.rs index 4f2acbd81f..04bbc3e00e 100644 --- a/src/runes/rune.rs +++ b/src/runes/rune.rs @@ -95,7 +95,7 @@ impl<'de> Deserialize<'de> for Rune { impl Display for Rune { fn fmt(&self, f: &mut Formatter) -> fmt::Result { let mut n = self.0; - if n == u128::max_value() { + if n == u128::MAX { return write!(f, "BCGDENLQRQWDSLRUGSNLBTMFIJAV"); } @@ -120,7 +120,7 @@ impl Display for Rune { } impl FromStr for Rune { - type Err = crate::Error; + type Err = Error; fn from_str(s: &str) -> crate::Result { let mut x = 0u128; @@ -183,9 +183,9 @@ mod tests { case(27, "AB"); case(51, "AZ"); case(52, "BA"); - case(u128::max_value() - 2, "BCGDENLQRQWDSLRUGSNLBTMFIJAT"); - case(u128::max_value() - 1, "BCGDENLQRQWDSLRUGSNLBTMFIJAU"); - case(u128::max_value(), "BCGDENLQRQWDSLRUGSNLBTMFIJAV"); + case(u128::MAX - 2, "BCGDENLQRQWDSLRUGSNLBTMFIJAT"); + case(u128::MAX - 1, "BCGDENLQRQWDSLRUGSNLBTMFIJAU"); + case(u128::MAX, "BCGDENLQRQWDSLRUGSNLBTMFIJAV"); } #[test] @@ -217,7 +217,7 @@ mod tests { case(END - 1, "A"); case(END, "A"); case(END + 1, "A"); - case(u32::max_value(), "A"); + case(u32::MAX, "A"); case(START + INTERVAL * 00 - 1, "AAAAAAAAAAAAA"); case(START + INTERVAL * 00 + 0, "ZZYZXBRKWXVA"); diff --git a/src/runes/rune_id.rs b/src/runes/rune_id.rs index 63fd756a99..8586b9eea0 100644 --- a/src/runes/rune_id.rs +++ b/src/runes/rune_id.rs @@ -30,7 +30,7 @@ impl Display for RuneId { } impl FromStr for RuneId { - type Err = crate::Error; + type Err = Error; fn from_str(s: &str) -> Result { let (height, index) = s diff --git a/src/runes/runestone.rs b/src/runes/runestone.rs index b3e770a97d..7bbf0c0578 100644 --- a/src/runes/runestone.rs +++ b/src/runes/runestone.rs @@ -197,8 +197,8 @@ impl Runestone { .push_opcode(opcodes::all::OP_RETURN) .push_slice(b"RUNE_TEST"); - for chunk in payload.chunks(bitcoin::blockdata::constants::MAX_SCRIPT_ELEMENT_SIZE) { - let push: &bitcoin::script::PushBytes = chunk.try_into().unwrap(); + for chunk in payload.chunks(MAX_SCRIPT_ELEMENT_SIZE) { + let push: &script::PushBytes = chunk.try_into().unwrap(); builder = builder.push_slice(push); } @@ -1058,7 +1058,7 @@ mod tests { #[test] fn id_deltas_saturate_to_max() { assert_eq!( - decipher(&[Tag::Body.into(), 1, 2, 3, u128::max_value(), 5, 6]), + decipher(&[Tag::Body.into(), 1, 2, 3, u128::MAX, 5, 6]), Runestone { edicts: vec![ Edict { @@ -1067,7 +1067,7 @@ mod tests { output: 3, }, Edict { - id: u128::max_value(), + id: u128::MAX, amount: 5, output: 6, }, @@ -1270,7 +1270,7 @@ mod tests { case( Vec::new(), Some(Etching { - rune: Some(Rune(u128::max_value())), + rune: Some(Rune(u128::MAX)), ..Default::default() }), 24, @@ -1288,7 +1288,7 @@ mod tests { }], Some(Etching { divisibility: MAX_DIVISIBILITY, - rune: Some(Rune(u128::max_value())), + rune: Some(Rune(u128::MAX)), ..Default::default() }), 30, @@ -1296,7 +1296,7 @@ mod tests { case( vec![Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 0, index: 0, @@ -1306,7 +1306,7 @@ mod tests { }], Some(Etching { divisibility: MAX_DIVISIBILITY, - rune: Some(Rune(u128::max_value())), + rune: Some(Rune(u128::MAX)), ..Default::default() }), 48, @@ -1317,7 +1317,7 @@ mod tests { amount: 0, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1338,10 +1338,10 @@ mod tests { case( vec![Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1353,19 +1353,19 @@ mod tests { case( vec![ Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, }, Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1378,28 +1378,28 @@ mod tests { case( vec![ Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, }, Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, }, Edict { - amount: u128::max_value(), + amount: u128::MAX, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1412,10 +1412,10 @@ mod tests { case( vec![ Edict { - amount: u64::max_value().into(), + amount: u64::MAX.into(), id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1429,10 +1429,10 @@ mod tests { case( vec![ Edict { - amount: u64::max_value().into(), + amount: u64::MAX.into(), id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1446,10 +1446,10 @@ mod tests { case( vec![ Edict { - amount: u64::max_value().into(), + amount: u64::MAX.into(), id: RuneId { height: 0, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1466,7 +1466,7 @@ mod tests { amount: 1_000_000_000_000_000_000, id: RuneId { height: 1_000_000, - index: u16::max_value(), + index: u16::MAX, } .into(), output: 0, @@ -1485,7 +1485,7 @@ mod tests { Tag::Flags.into(), Flag::Etch.mask(), Tag::Term.into(), - u128::from(u64::max_value()) + 1, + u128::from(u64::MAX) + 1, ]), Runestone { etching: Some(Etching::default()), diff --git a/src/runes/varint.rs b/src/runes/varint.rs index 0a9ff7a90e..438673a836 100644 --- a/src/runes/varint.rs +++ b/src/runes/varint.rs @@ -48,7 +48,7 @@ mod tests { #[test] fn u128_max_round_trips_successfully() { - let n = u128::max_value(); + let n = u128::MAX; let encoded = encode(n); let (decoded, length) = decode(&encoded); assert_eq!(decoded, n); diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index de6a09e132..5ddab416d1 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -1721,7 +1721,7 @@ mod tests { fn new_with_regtest() -> Self { Self::new_server( test_bitcoincore_rpc::builder() - .network(bitcoin::network::constants::Network::Regtest) + .network(Network::Regtest) .build(), None, &["--chain", "regtest"], @@ -1732,7 +1732,7 @@ mod tests { fn new_with_regtest_with_json_api() -> Self { Self::new_server( test_bitcoincore_rpc::builder() - .network(bitcoin::network::constants::Network::Regtest) + .network(Network::Regtest) .build(), None, &["--chain", "regtest"], @@ -1743,7 +1743,7 @@ mod tests { fn new_with_regtest_with_index_sats() -> Self { Self::new_server( test_bitcoincore_rpc::builder() - .network(bitcoin::Network::Regtest) + .network(Network::Regtest) .build(), None, &["--chain", "regtest", "--index-sats"], @@ -1754,7 +1754,7 @@ mod tests { fn new_with_regtest_with_index_runes() -> Self { Self::new_server( test_bitcoincore_rpc::builder() - .network(bitcoin::Network::Regtest) + .network(Network::Regtest) .build(), None, &["--chain", "regtest", "--index-runes"], @@ -1864,7 +1864,7 @@ mod tests { let response = client .get(self.join_url(path.as_ref())) - .header(reqwest::header::ACCEPT, "application/json") + .header(header::ACCEPT, "application/json") .send() .unwrap(); @@ -1928,7 +1928,7 @@ mod tests { assert_eq!(response.headers().get(header::LOCATION).unwrap(), location); } - fn mine_blocks(&self, n: u64) -> Vec { + fn mine_blocks(&self, n: u64) -> Vec { let blocks = self.bitcoin_rpc_server.mine_blocks(n); self.index.update().unwrap(); blocks @@ -2232,7 +2232,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2278,7 +2278,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2306,7 +2306,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() } @@ -2315,7 +2315,7 @@ mod tests { assert_eq!( server.index.get_rune_balances().unwrap(), - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])] + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])] ); server.assert_response_regex( @@ -2345,7 +2345,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2374,7 +2374,7 @@ mod tests { RuneEntry { etching: txid, rune, - supply: u128::max_value(), + supply: u128::MAX, symbol: Some('%'), timestamp: 2, ..Default::default() @@ -2384,7 +2384,7 @@ mod tests { assert_eq!( server.index.get_rune_balances().unwrap(), - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])] + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])] ); server.assert_response_regex( @@ -2453,7 +2453,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2483,7 +2483,7 @@ mod tests { RuneEntry { etching: txid, rune, - supply: u128::max_value(), + supply: u128::MAX, symbol: Some('%'), timestamp: 2, spacers: 1, @@ -2494,7 +2494,7 @@ mod tests { assert_eq!( server.index.get_rune_balances().unwrap(), - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])] + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])] ); server.assert_response_regex( @@ -2552,7 +2552,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2580,7 +2580,7 @@ mod tests { RuneEntry { etching: txid, rune: Rune(RUNE), - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() } @@ -2589,7 +2589,7 @@ mod tests { assert_eq!( server.index.get_rune_balances().unwrap(), - [(OutPoint { txid, vout: 0 }, vec![(id, u128::max_value())])] + [(OutPoint { txid, vout: 0 }, vec![(id, u128::MAX)])] ); server.assert_response_regex( @@ -2618,7 +2618,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching { @@ -2648,7 +2648,7 @@ mod tests { divisibility: 1, etching: txid, rune, - supply: u128::max_value(), + supply: u128::MAX, timestamp: 2, ..Default::default() } @@ -2659,7 +2659,7 @@ mod tests { assert_eq!( server.index.get_rune_balances().unwrap(), - [(output, vec![(id, u128::max_value())])] + [(output, vec![(id, u128::MAX)])] ); server.assert_response_regex( diff --git a/src/subcommand/wallet/restore.rs b/src/subcommand/wallet/restore.rs index 76b61beb80..9615af28e0 100644 --- a/src/subcommand/wallet/restore.rs +++ b/src/subcommand/wallet/restore.rs @@ -23,7 +23,7 @@ impl Restore { if self.descriptor { let mut buffer = Vec::new(); - std::io::stdin().read_to_end(&mut buffer)?; + io::stdin().read_to_end(&mut buffer)?; let wallet_descriptors: ListDescriptorsResult = serde_json::from_slice(&buffer)?; diff --git a/src/templates/preview.rs b/src/templates/preview.rs index b69ffcea21..d6931415c0 100644 --- a/src/templates/preview.rs +++ b/src/templates/preview.rs @@ -1,50 +1,50 @@ use super::*; -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewAudioHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewCodeHtml { pub(crate) inscription_id: InscriptionId, pub(crate) language: media::Language, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewFontHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewImageHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewMarkdownHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewModelHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewPdfHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewTextHtml { pub(crate) inscription_id: InscriptionId, } -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewUnknownHtml; -#[derive(boilerplate::Boilerplate)] +#[derive(Boilerplate)] pub(crate) struct PreviewVideoHtml { pub(crate) inscription_id: InscriptionId, } diff --git a/src/templates/rune.rs b/src/templates/rune.rs index 83651b4045..0c9073f538 100644 --- a/src/templates/rune.rs +++ b/src/templates/rune.rs @@ -34,7 +34,7 @@ mod tests { limit: Some(1000000001), deadline: Some(7), }), - rune: Rune(u128::max_value()), + rune: Rune(u128::MAX), spacers: 1, supply: 123456789123456789, symbol: Some('%'), @@ -103,7 +103,7 @@ mod tests { etching: Txid::all_zeros(), mints: 0, number: 25, - rune: Rune(u128::max_value()), + rune: Rune(u128::MAX), spacers: 1, supply: 123456789123456789, symbol: Some('%'), @@ -159,7 +159,7 @@ mod tests { etching: Txid::all_zeros(), mints: 0, number: 25, - rune: Rune(u128::max_value()), + rune: Rune(u128::MAX), spacers: 1, supply: 123456789123456789, symbol: Some('%'), diff --git a/src/wallet.rs b/src/wallet.rs index 9ead9861c1..bccbc8b74b 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -291,7 +291,7 @@ impl Wallet { pub(crate) fn get_locked_outputs(&self) -> Result> { #[derive(Deserialize)] pub(crate) struct JsonOutPoint { - txid: bitcoin::Txid, + txid: Txid, vout: u32, } @@ -489,7 +489,7 @@ impl Wallet { let public_key = secret_key.to_public(secp)?; - let mut key_map = std::collections::HashMap::new(); + let mut key_map = HashMap::new(); key_map.insert(public_key.clone(), secret_key); let descriptor = miniscript::descriptor::Descriptor::new_tr(public_key, None)?; diff --git a/src/wallet/inscribe/batch.rs b/src/wallet/inscribe/batch.rs index f5acd056a2..f2f25baa3a 100644 --- a/src/wallet/inscribe/batch.rs +++ b/src/wallet/inscribe/batch.rs @@ -128,7 +128,7 @@ impl Batch { reveal: Txid, total_fees: u64, inscriptions: Vec, - ) -> super::Output { + ) -> Output { let mut inscriptions_output = Vec::new(); for index in 0..inscriptions.len() { let index = u32::try_from(index).unwrap(); @@ -170,7 +170,7 @@ impl Batch { }); } - super::Output { + Output { commit, reveal, total_fees, diff --git a/src/wallet/transaction_builder.rs b/src/wallet/transaction_builder.rs index 3ba052508c..9945b8f3c7 100644 --- a/src/wallet/transaction_builder.rs +++ b/src/wallet/transaction_builder.rs @@ -61,8 +61,8 @@ pub enum Target { ExactPostage(Amount), } -impl fmt::Display for Error { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +impl Display for Error { + fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result { match self { Error::Dust { output_value, diff --git a/tests/index.rs b/tests/index.rs index 5d44449cac..815bb90dd4 100644 --- a/tests/index.rs +++ b/tests/index.rs @@ -102,7 +102,7 @@ fn export_inscription_number_to_id_tsv() { .temp_dir(Arc::new(temp_dir)) .run_and_extract_file("foo.tsv"); - let entries: std::collections::BTreeMap = tsv + let entries: BTreeMap = tsv .lines() .filter(|line| !line.is_empty() && !line.starts_with('#')) .map(|line| { From 3319cf7b0bc19bcf1945265cb3da19a42247c7ad Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:53:04 +0700 Subject: [PATCH 3/5] fix lint --- src/index/fetcher.rs | 5 +--- src/inscriptions/media.rs | 5 +--- src/runes.rs | 50 ++++++++------------------------------- 3 files changed, 12 insertions(+), 48 deletions(-) diff --git a/src/index/fetcher.rs b/src/index/fetcher.rs index fd5b221090..d65485e26c 100644 --- a/src/index/fetcher.rs +++ b/src/index/fetcher.rs @@ -79,10 +79,7 @@ impl Fetcher { log::info!("failed to fetch raw transactions, retrying: {}", error); - tokio::time::sleep(Duration::from_millis( - 100 * u64::pow(2, retries), - )) - .await; + tokio::time::sleep(Duration::from_millis(100 * u64::pow(2, retries))).await; retries += 1; continue; } diff --git a/src/inscriptions/media.rs b/src/inscriptions/media.rs index 8d21b0922d..20acd04c49 100644 --- a/src/inscriptions/media.rs +++ b/src/inscriptions/media.rs @@ -178,10 +178,7 @@ mod tests { ); assert_eq!( Media::content_type_for_path(Path::new("pepe.txt")).unwrap(), - ( - "text/plain;charset=utf-8", - BROTLI_MODE_TEXT - ) + ("text/plain;charset=utf-8", BROTLI_MODE_TEXT) ); assert_regex_match!( Media::content_type_for_path(Path::new("pepe.foo")).unwrap_err(), diff --git a/src/runes.rs b/src/runes.rs index 47adc3410a..39c101d7ac 100644 --- a/src/runes.rs +++ b/src/runes.rs @@ -2087,10 +2087,7 @@ mod tests { txid: txid3, vout: 0, }, - vec![ - (id0, u128::MAX / 2 + 1), - (id1, u128::MAX / 2 + 1), - ], + vec![(id0, u128::MAX / 2 + 1), (id1, u128::MAX / 2 + 1)], ), ( OutPoint { @@ -3048,22 +3045,10 @@ mod tests { }, )], [ - ( - OutPoint { txid, vout: 0 }, - vec![(id, u128::MAX / 4 + 1)], - ), - ( - OutPoint { txid, vout: 1 }, - vec![(id, u128::MAX / 4 + 1)], - ), - ( - OutPoint { txid, vout: 2 }, - vec![(id, u128::MAX / 4 + 1)], - ), - ( - OutPoint { txid, vout: 3 }, - vec![(id, u128::MAX / 4)], - ), + (OutPoint { txid, vout: 0 }, vec![(id, u128::MAX / 4 + 1)]), + (OutPoint { txid, vout: 1 }, vec![(id, u128::MAX / 4 + 1)]), + (OutPoint { txid, vout: 2 }, vec![(id, u128::MAX / 4 + 1)]), + (OutPoint { txid, vout: 3 }, vec![(id, u128::MAX / 4)]), ], ); } @@ -3194,22 +3179,10 @@ mod tests { }, )], [ - ( - OutPoint { txid, vout: 0 }, - vec![(id, u128::MAX / 4 + 1)], - ), - ( - OutPoint { txid, vout: 1 }, - vec![(id, u128::MAX / 4 + 1)], - ), - ( - OutPoint { txid, vout: 2 }, - vec![(id, u128::MAX / 4 + 1)], - ), - ( - OutPoint { txid, vout: 3 }, - vec![(id, u128::MAX / 4)], - ), + (OutPoint { txid, vout: 0 }, vec![(id, u128::MAX / 4 + 1)]), + (OutPoint { txid, vout: 1 }, vec![(id, u128::MAX / 4 + 1)]), + (OutPoint { txid, vout: 2 }, vec![(id, u128::MAX / 4 + 1)]), + (OutPoint { txid, vout: 3 }, vec![(id, u128::MAX / 4)]), ], ); } @@ -3321,10 +3294,7 @@ mod tests { }, )], [ - ( - OutPoint { txid, vout: 0 }, - vec![(id, u128::MAX - 2000)], - ), + (OutPoint { txid, vout: 0 }, vec![(id, u128::MAX - 2000)]), (OutPoint { txid, vout: 1 }, vec![(id, 1000)]), (OutPoint { txid, vout: 2 }, vec![(id, 1000)]), ], From c28d6dc0a0a44bd32431ed6cc6a55ebbb067695d Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Sat, 17 Feb 2024 13:28:51 +0700 Subject: [PATCH 4/5] revert fn write_height_to_ts --- src/index/updater.rs | 33 +++++++++++++++++--------------- src/object.rs | 1 - src/subcommand/wallet/restore.rs | 2 +- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/src/index/updater.rs b/src/index/updater.rs index 22f2e42376..b480078a2f 100644 --- a/src/index/updater.rs +++ b/src/index/updater.rs @@ -57,20 +57,15 @@ impl<'index> Updater<'_> { let mut wtx = self.index.begin_write()?; let starting_height = u32::try_from(self.index.client.get_block_count()?).unwrap() + 1; - let write_height_to_ts = |wtx: &mut WriteTransaction, height: &u32| { - wtx - .open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP) - .expect("open table failed") - .insert( - height, - &SystemTime::now() - .duration_since(SystemTime::UNIX_EPOCH) - .map(|duration| duration.as_millis()) - .unwrap_or(0), - ) - .expect("insert height failed"); - }; - write_height_to_ts(&mut wtx, &self.height); + wtx + .open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)? + .insert( + &self.height, + &SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|duration| duration.as_millis()) + .unwrap_or(0), + )?; let mut progress_bar = if cfg!(test) || log_enabled!(log::Level::Info) @@ -133,7 +128,15 @@ impl<'index> Updater<'_> { // write transaction break; } - write_height_to_ts(&mut wtx, &self.height); + wtx + .open_table(WRITE_TRANSACTION_STARTING_BLOCK_COUNT_TO_TIMESTAMP)? + .insert( + &self.height, + &SystemTime::now() + .duration_since(SystemTime::UNIX_EPOCH) + .map(|duration| duration.as_millis()) + .unwrap_or(0), + )?; } if SHUTTING_DOWN.load(atomic::Ordering::Relaxed) { diff --git a/src/object.rs b/src/object.rs index 4f737ccfda..611f592934 100644 --- a/src/object.rs +++ b/src/object.rs @@ -1,5 +1,4 @@ use super::*; -use bitcoin::hashes::Hash; #[derive(Debug, PartialEq, Clone)] pub enum Object { diff --git a/src/subcommand/wallet/restore.rs b/src/subcommand/wallet/restore.rs index 9615af28e0..76b61beb80 100644 --- a/src/subcommand/wallet/restore.rs +++ b/src/subcommand/wallet/restore.rs @@ -23,7 +23,7 @@ impl Restore { if self.descriptor { let mut buffer = Vec::new(); - io::stdin().read_to_end(&mut buffer)?; + std::io::stdin().read_to_end(&mut buffer)?; let wallet_descriptors: ListDescriptorsResult = serde_json::from_slice(&buffer)?; From 0af2bdedfe232ed10be94a99b2b59a15563c2899 Mon Sep 17 00:00:00 2001 From: Lugon LQ <48004924+lugondev@users.noreply.github.com> Date: Sun, 25 Feb 2024 16:43:23 +0700 Subject: [PATCH 5/5] fix conflict and lint code --- src/inscriptions/media.rs | 25 ++++++++++++++----------- src/subcommand/server.rs | 2 +- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/inscriptions/media.rs b/src/inscriptions/media.rs index 69d9718f5f..f61833e99a 100644 --- a/src/inscriptions/media.rs +++ b/src/inscriptions/media.rs @@ -38,11 +38,11 @@ impl Display for Language { f, "{}", match self { - Self::Css => "css", - Self::JavaScript => "javascript", - Self::Json => "json", - Self::Python => "python", - Self::Yaml => "yaml", + Css => "css", + JavaScript => "javascript", + Json => "json", + Python => "python", + Yaml => "yaml", } ) } @@ -60,8 +60,8 @@ impl Display for ImageRendering { f, "{}", match self { - Self::Auto => "auto", - Self::Pixelated => "pixelated", + Auto => "auto", + Pixelated => "pixelated", } ) } @@ -187,19 +187,22 @@ mod tests { fn for_extension() { assert_eq!( Media::content_type_for_path(Path::new("pepe.jpg")).unwrap(), - ("image/jpeg", BROTLI_MODE_GENERIC) + ("image/jpeg", BrotliEncoderMode::BROTLI_MODE_GENERIC) ); assert_eq!( Media::content_type_for_path(Path::new("pepe.jpeg")).unwrap(), - ("image/jpeg", BROTLI_MODE_GENERIC) + ("image/jpeg", BrotliEncoderMode::BROTLI_MODE_GENERIC) ); assert_eq!( Media::content_type_for_path(Path::new("pepe.JPG")).unwrap(), - ("image/jpeg", BROTLI_MODE_GENERIC) + ("image/jpeg", BrotliEncoderMode::BROTLI_MODE_GENERIC) ); assert_eq!( Media::content_type_for_path(Path::new("pepe.txt")).unwrap(), - ("text/plain;charset=utf-8", BROTLI_MODE_TEXT) + ( + "text/plain;charset=utf-8", + BrotliEncoderMode::BROTLI_MODE_TEXT + ) ); assert_regex_match!( Media::content_type_for_path(Path::new("pepe.foo")).unwrap_err(), diff --git a/src/subcommand/server.rs b/src/subcommand/server.rs index 1451bd3248..b5e9e97eba 100644 --- a/src/subcommand/server.rs +++ b/src/subcommand/server.rs @@ -2314,7 +2314,7 @@ mod tests { Runestone { edicts: vec![Edict { id: 0, - amount: u128::max_value(), + amount: u128::MAX, output: 0, }], etching: Some(Etching {