File tree 7 files changed +16
-17
lines changed 7 files changed +16
-17
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ pub struct Config {
49
49
fn str_to_socketaddr ( address : & str , what : & str ) -> SocketAddr {
50
50
address
51
51
. to_socket_addrs ( )
52
- . expect ( & format ! ( "unable to resolve {} address" , what) )
52
+ . unwrap_or_else ( |_| panic ! ( "unable to resolve {} address" , what) )
53
53
. collect :: < Vec < _ > > ( )
54
54
. pop ( )
55
55
. unwrap ( )
Original file line number Diff line number Diff line change @@ -576,7 +576,8 @@ impl RPC {
576
576
let chan = Channel :: unbounded ( ) ;
577
577
let acceptor = chan. sender ( ) ;
578
578
spawn_thread ( "acceptor" , move || {
579
- let listener = TcpListener :: bind ( addr) . expect ( & format ! ( "bind({}) failed" , addr) ) ;
579
+ let listener =
580
+ TcpListener :: bind ( addr) . unwrap_or_else ( |_| panic ! ( "bind({}) failed" , addr) ) ;
580
581
info ! ( "Electrum RPC server running on {}" , addr) ;
581
582
loop {
582
583
let ( stream, addr) = listener. accept ( ) . expect ( "accept failed" ) ;
Original file line number Diff line number Diff line change @@ -67,10 +67,8 @@ impl Metrics {
67
67
}
68
68
69
69
pub fn start ( & self ) {
70
- let server = tiny_http:: Server :: http ( self . addr ) . expect ( & format ! (
71
- "failed to start monitoring HTTP server at {}" ,
72
- self . addr
73
- ) ) ;
70
+ let server = tiny_http:: Server :: http ( self . addr )
71
+ . unwrap_or_else ( |_| panic ! ( "failed to start monitoring HTTP server at {}" , self . addr) ) ;
74
72
start_process_exporter ( & self ) ;
75
73
let reg = self . reg . clone ( ) ;
76
74
spawn_thread ( "metrics" , move || loop {
Original file line number Diff line number Diff line change @@ -158,10 +158,10 @@ fn blkfiles_reader(blk_files: Vec<PathBuf>) -> Fetcher<Vec<u8>> {
158
158
spawn_thread ( "blkfiles_reader" , move || {
159
159
for path in blk_files {
160
160
trace ! ( "reading {:?}" , path) ;
161
- let blob = fs:: read ( & path) . expect ( & format ! ( "failed to read {:?}" , path) ) ;
161
+ let blob = fs:: read ( & path) . unwrap_or_else ( |_| panic ! ( "failed to read {:?}" , path) ) ;
162
162
sender
163
163
. send ( blob)
164
- . expect ( & format ! ( "failed to send {:?} contents" , path) ) ;
164
+ . unwrap_or_else ( |_| panic ! ( "failed to send {:?} contents" , path) ) ;
165
165
}
166
166
} ) ,
167
167
)
Original file line number Diff line number Diff line change @@ -323,8 +323,9 @@ impl Mempool {
323
323
. map ( |( index, txi) | {
324
324
(
325
325
index as u32 ,
326
- txos. get ( & txi. previous_output )
327
- . expect ( & format ! ( "missing outpoint {:?}" , txi. previous_output) ) ,
326
+ txos. get ( & txi. previous_output ) . unwrap_or_else ( || {
327
+ panic ! ( "missing outpoint {:?}" , txi. previous_output)
328
+ } ) ,
328
329
)
329
330
} )
330
331
. collect ( ) ;
@@ -445,7 +446,7 @@ impl Mempool {
445
446
for txid in & to_remove {
446
447
self . txstore
447
448
. remove ( * txid)
448
- . expect ( & format ! ( "missing mempool tx {}" , txid) ) ;
449
+ . unwrap_or_else ( || panic ! ( "missing mempool tx {}" , txid) ) ;
449
450
450
451
self . feeinfo . remove ( * txid) . or_else ( || {
451
452
warn ! ( "missing mempool tx feeinfo {}" , txid) ;
Original file line number Diff line number Diff line change @@ -1056,7 +1056,7 @@ fn index_transaction(
1056
1056
}
1057
1057
let prev_txo = previous_txos_map
1058
1058
. get ( & txi. previous_output )
1059
- . expect ( & format ! ( "missing previous txo {}" , txi. previous_output) ) ;
1059
+ . unwrap_or_else ( || panic ! ( "missing previous txo {}" , txi. previous_output) ) ;
1060
1060
1061
1061
let history = TxHistoryRow :: new (
1062
1062
& prev_txo. script_pubkey ,
Original file line number Diff line number Diff line change @@ -92,10 +92,9 @@ impl HeaderList {
92
92
let null_hash = BlockHash :: default ( ) ;
93
93
94
94
while blockhash != null_hash {
95
- let header = headers_map. remove ( & blockhash) . expect ( & format ! (
96
- "missing expected blockhash in headers map: {:?}" ,
97
- blockhash
98
- ) ) ;
95
+ let header = headers_map. remove ( & blockhash) . unwrap_or_else ( || {
96
+ panic ! ( "missing expected blockhash in headers map: {:?}" , blockhash)
97
+ } ) ;
99
98
blockhash = header. prev_blockhash ;
100
99
headers_chain. push ( header) ;
101
100
}
@@ -138,7 +137,7 @@ impl HeaderList {
138
137
0
139
138
} else {
140
139
self . header_by_blockhash ( & prev_blockhash)
141
- . expect ( & format ! ( "{} is not part of the blockchain" , prev_blockhash) )
140
+ . unwrap_or_else ( || panic ! ( "{} is not part of the blockchain" , prev_blockhash) )
142
141
. height ( )
143
142
+ 1
144
143
} ;
You can’t perform that action at this time.
0 commit comments