From 272cdbcf7c74a1d9bbe3401bd18c70598d2031d7 Mon Sep 17 00:00:00 2001 From: "Tobin C. Harding" Date: Tue, 14 Feb 2023 06:45:37 +1100 Subject: [PATCH] Flatten the types directory We recently created a `types` subdirectory under `script` to keep all the `Script` and `ScriptBuf` impls together. Turns out this additional level of subdirectory is a bit annoying and we can achieve the same grouping by just using `script/mod.rs`. Move code from `types/mod.rs` to `script/mod.rs`, move the two submodules up a level, remove the `types` directory. --- .../blockdata/script/{types => }/borrowed.rs | 0 bitcoin/src/blockdata/script/mod.rs | 520 ++++++++++++++++- .../src/blockdata/script/{types => }/owned.rs | 0 bitcoin/src/blockdata/script/types/mod.rs | 527 ------------------ 4 files changed, 517 insertions(+), 530 deletions(-) rename bitcoin/src/blockdata/script/{types => }/borrowed.rs (100%) rename bitcoin/src/blockdata/script/{types => }/owned.rs (100%) delete mode 100644 bitcoin/src/blockdata/script/types/mod.rs diff --git a/bitcoin/src/blockdata/script/types/borrowed.rs b/bitcoin/src/blockdata/script/borrowed.rs similarity index 100% rename from bitcoin/src/blockdata/script/types/borrowed.rs rename to bitcoin/src/blockdata/script/borrowed.rs diff --git a/bitcoin/src/blockdata/script/mod.rs b/bitcoin/src/blockdata/script/mod.rs index b843ac82..b13088d0 100644 --- a/bitcoin/src/blockdata/script/mod.rs +++ b/bitcoin/src/blockdata/script/mod.rs @@ -48,20 +48,35 @@ //! At the time of writing there's only one operation using the cache - `push_verify`, so the cache //! is minimal but we may extend it in the future if needed. +use alloc::rc::Rc; +use alloc::sync::Arc; + +use core::cmp::Ordering; +use core::borrow::{Borrow, BorrowMut}; use core::fmt; +use core::ops::{Deref, DerefMut}; + +#[cfg(feature = "serde")] +use serde; use crate::blockdata::opcodes::{self, all::*}; -use crate::OutPoint; +use crate::consensus::{encode, Decodable, Encodable}; +use crate::hash_types::{ScriptHash, WScriptHash}; +use crate::hashes::hex; +use crate::{io, OutPoint}; +use crate::prelude::*; +mod borrowed; mod builder; mod instruction; -mod types; +mod owned; #[cfg(test)] mod tests; +pub use self::borrowed::*; pub use self::builder::*; pub use self::instruction::*; -pub use self::types::*; +pub use self::owned::*; /// Encodes an integer in script(minimal CScriptNum) format. /// @@ -213,6 +228,505 @@ fn opcode_to_verify(opcode: Option) -> Option { }) } +// We keep all the `Script` and `ScriptBuf` impls together since its easier to see side-by-side. + +impl From for Box