29
29
//!
30
30
31
31
#![ cfg_attr( all( not( feature = "std" ) , not( test) ) , no_std) ]
32
-
33
32
// Experimental features we need.
34
33
#![ cfg_attr( bench, feature( test) ) ]
35
34
#![ cfg_attr( docsrs, feature( doc_cfg) ) ]
36
-
37
35
// Coding conventions
38
36
#![ forbid( unsafe_code) ]
39
37
#![ deny( non_upper_case_globals) ]
@@ -55,7 +53,8 @@ compile_error!(
55
53
know if you want 16-bit support. Note that we do NOT guarantee that we will implement it!"
56
54
) ;
57
55
58
- #[ cfg( bench) ] extern crate test;
56
+ #[ cfg( bench) ]
57
+ extern crate test;
59
58
60
59
#[ cfg( feature = "no-std" ) ]
61
60
#[ macro_use]
@@ -64,9 +63,10 @@ extern crate alloc;
64
63
extern crate core2;
65
64
66
65
// Re-exported dependencies.
67
- #[ macro_use] pub extern crate bitcoin_hashes as hashes ;
68
- pub extern crate secp256k1 ;
66
+ #[ macro_use]
67
+ pub extern crate bitcoin_hashes as hashes ;
69
68
pub extern crate bech32;
69
+ pub extern crate secp256k1;
70
70
71
71
#[ cfg( feature = "no-std" ) ]
72
72
extern crate hashbrown;
@@ -75,12 +75,19 @@ extern crate hashbrown;
75
75
#[ cfg_attr( docsrs, doc( cfg( feature = "base64" ) ) ) ]
76
76
pub extern crate base64;
77
77
78
- #[ cfg( feature="bitcoinconsensus" ) ] extern crate bitcoinconsensus;
79
- #[ cfg( feature = "serde" ) ] #[ macro_use] extern crate actual_serde as serde;
80
- #[ cfg( all( test, feature = "serde" ) ) ] extern crate serde_json;
81
- #[ cfg( all( test, feature = "serde" ) ) ] extern crate serde_test;
82
- #[ cfg( all( test, feature = "serde" ) ) ] extern crate bincode;
83
- #[ cfg( all( test, feature = "unstable" ) ) ] extern crate test;
78
+ #[ cfg( feature = "bitcoinconsensus" ) ]
79
+ extern crate bitcoinconsensus;
80
+ #[ cfg( feature = "serde" ) ]
81
+ #[ macro_use]
82
+ extern crate actual_serde as serde;
83
+ #[ cfg( all( test, feature = "serde" ) ) ]
84
+ extern crate bincode;
85
+ #[ cfg( all( test, feature = "serde" ) ) ]
86
+ extern crate serde_json;
87
+ #[ cfg( all( test, feature = "serde" ) ) ]
88
+ extern crate serde_test;
89
+ #[ cfg( all( test, feature = "unstable" ) ) ]
90
+ extern crate test;
84
91
85
92
#[ cfg( test) ]
86
93
#[ macro_use]
@@ -93,44 +100,36 @@ mod serde_utils;
93
100
#[ macro_use]
94
101
pub mod network;
95
102
pub mod blockdata;
96
- pub mod util;
97
103
pub mod consensus;
98
104
pub mod hash_types;
99
105
pub mod policy;
106
+ pub mod util;
100
107
101
- pub use crate :: hash_types:: * ;
102
- pub use crate :: blockdata:: block:: Block ;
103
- pub use crate :: blockdata:: block:: BlockHeader ;
108
+ #[ cfg( feature = "std" ) ]
109
+ use std:: io;
110
+
111
+ #[ cfg( not( feature = "std" ) ) ]
112
+ use core2:: io;
113
+
114
+ pub use crate :: blockdata:: block:: { Block , BlockHeader } ;
104
115
pub use crate :: blockdata:: script:: Script ;
105
- pub use crate :: blockdata:: transaction:: Transaction ;
106
- pub use crate :: blockdata:: transaction:: TxIn ;
107
- pub use crate :: blockdata:: transaction:: Sequence ;
108
- pub use crate :: blockdata:: transaction:: TxOut ;
109
- pub use crate :: blockdata:: transaction:: OutPoint ;
110
- pub use crate :: blockdata:: transaction:: EcdsaSighashType ;
116
+ #[ allow( deprecated) ]
117
+ pub use crate :: blockdata:: transaction:: SigHashType ;
118
+ pub use crate :: blockdata:: transaction:: {
119
+ EcdsaSighashType , OutPoint , Sequence , Transaction , TxIn , TxOut ,
120
+ } ;
111
121
pub use crate :: blockdata:: witness:: Witness ;
112
122
pub use crate :: consensus:: encode:: VarInt ;
123
+ pub use crate :: hash_types:: * ;
113
124
pub use crate :: network:: constants:: Network ;
114
- pub use crate :: util:: Error ;
115
- pub use crate :: util:: address:: Address ;
116
- pub use crate :: util:: address:: AddressType ;
117
- pub use crate :: util:: amount:: Amount ;
118
- pub use crate :: util:: amount:: Denomination ;
119
- pub use crate :: util:: amount:: SignedAmount ;
120
- pub use crate :: util:: merkleblock:: MerkleBlock ;
121
- pub use crate :: util:: sighash:: SchnorrSighashType ;
122
-
125
+ pub use crate :: util:: address:: { Address , AddressType } ;
126
+ pub use crate :: util:: amount:: { Amount , Denomination , SignedAmount } ;
123
127
pub use crate :: util:: ecdsa:: { self , EcdsaSig , EcdsaSigError } ;
128
+ pub use crate :: util:: key:: { KeyPair , PrivateKey , PublicKey , XOnlyPublicKey } ;
129
+ pub use crate :: util:: merkleblock:: MerkleBlock ;
124
130
pub use crate :: util:: schnorr:: { self , SchnorrSig , SchnorrSigError } ;
125
- pub use crate :: util:: key:: { PrivateKey , PublicKey , XOnlyPublicKey , KeyPair } ;
126
- pub use crate :: util:: psbt;
127
- #[ allow( deprecated) ]
128
- pub use crate :: blockdata:: transaction:: SigHashType ;
129
-
130
- #[ cfg( feature = "std" ) ]
131
- use std:: io;
132
- #[ cfg( not( feature = "std" ) ) ]
133
- use core2:: io;
131
+ pub use crate :: util:: sighash:: SchnorrSighashType ;
132
+ pub use crate :: util:: { psbt, Error } ;
134
133
135
134
#[ cfg( not( feature = "std" ) ) ]
136
135
mod io_extras {
@@ -140,20 +139,14 @@ mod io_extras {
140
139
}
141
140
142
141
/// Creates an instance of a writer which will successfully consume all data.
143
- pub const fn sink ( ) -> Sink {
144
- Sink { _priv : ( ) }
145
- }
142
+ pub const fn sink ( ) -> Sink { Sink { _priv : ( ) } }
146
143
147
144
impl core2:: io:: Write for Sink {
148
145
#[ inline]
149
- fn write ( & mut self , buf : & [ u8 ] ) -> core2:: io:: Result < usize > {
150
- Ok ( buf. len ( ) )
151
- }
146
+ fn write ( & mut self , buf : & [ u8 ] ) -> core2:: io:: Result < usize > { Ok ( buf. len ( ) ) }
152
147
153
148
#[ inline]
154
- fn flush ( & mut self ) -> core2:: io:: Result < ( ) > {
155
- Ok ( ( ) )
156
- }
149
+ fn flush ( & mut self ) -> core2:: io:: Result < ( ) > { Ok ( ( ) ) }
157
150
}
158
151
}
159
152
@@ -184,32 +177,26 @@ mod prelude {
184
177
pub use std:: collections:: HashSet ;
185
178
}
186
179
187
- #[ cfg( bench) ] use bench:: EmptyWrite ;
180
+ #[ cfg( bench) ]
181
+ use bench:: EmptyWrite ;
188
182
189
183
#[ cfg( bench) ]
190
184
mod bench {
191
185
use core:: fmt:: Arguments ;
186
+
192
187
use crate :: io:: { IoSlice , Result , Write } ;
193
188
194
189
#[ derive( Default , Clone , Debug , PartialEq , Eq ) ]
195
190
pub struct EmptyWrite ;
196
191
197
192
impl Write for EmptyWrite {
198
- fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize > {
199
- Ok ( buf. len ( ) )
200
- }
193
+ fn write ( & mut self , buf : & [ u8 ] ) -> Result < usize > { Ok ( buf. len ( ) ) }
201
194
fn write_vectored ( & mut self , bufs : & [ IoSlice ] ) -> Result < usize > {
202
195
Ok ( bufs. iter ( ) . map ( |s| s. len ( ) ) . sum ( ) )
203
196
}
204
- fn flush ( & mut self ) -> Result < ( ) > {
205
- Ok ( ( ) )
206
- }
197
+ fn flush ( & mut self ) -> Result < ( ) > { Ok ( ( ) ) }
207
198
208
- fn write_all ( & mut self , _: & [ u8 ] ) -> Result < ( ) > {
209
- Ok ( ( ) )
210
- }
211
- fn write_fmt ( & mut self , _: Arguments ) -> Result < ( ) > {
212
- Ok ( ( ) )
213
- }
199
+ fn write_all ( & mut self , _: & [ u8 ] ) -> Result < ( ) > { Ok ( ( ) ) }
200
+ fn write_fmt ( & mut self , _: Arguments ) -> Result < ( ) > { Ok ( ( ) ) }
214
201
}
215
202
}
0 commit comments