@@ -143,22 +143,6 @@ impl<B: BlockT> WitnessStorage<B> {
143
143
}
144
144
}
145
145
146
- /// TODO: `TrieError` should implement `Debug` on `no_std`
147
- fn unwrap_trie_error < R , T , E > ( result : Result < R , Box < trie_db:: TrieError < T , E > > > ) -> R {
148
- match result {
149
- Ok ( r) => r,
150
- Err ( error) => match * error {
151
- trie_db:: TrieError :: InvalidStateRoot ( _) => panic ! ( "trie_db: Invalid state root" ) ,
152
- trie_db:: TrieError :: IncompleteDatabase ( _) => panic ! ( "trie_db: IncompleteDatabase" ) ,
153
- trie_db:: TrieError :: DecoderError ( _, _) => panic ! ( "trie_db: DecodeError" ) ,
154
- trie_db:: TrieError :: InvalidHash ( _, _) => panic ! ( "trie_db: InvalidHash" ) ,
155
- trie_db:: TrieError :: ValueAtIncompleteKey ( _, _) => {
156
- panic ! ( "trie_db: ValueAtIncompleteKey" )
157
- }
158
- } ,
159
- }
160
- }
161
-
162
146
impl < B : BlockT > Storage for WitnessStorage < B > {
163
147
fn get ( & self , key : & [ u8 ] ) -> Option < Vec < u8 > > {
164
148
self . overlay
@@ -184,11 +168,11 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
184
168
}
185
169
186
170
fn storage_root ( & mut self ) -> Vec < u8 > {
187
- let root = unwrap_trie_error ( delta_trie_root :: < Layout < HasherFor < B > > , _ , _ , _ , _ > (
171
+ let root = delta_trie_root :: < Layout < HasherFor < B > > , _ , _ , _ , _ > (
188
172
& mut self . witness_data ,
189
173
self . storage_root . clone ( ) ,
190
174
self . overlay . drain ( ) ,
191
- ) ) ;
175
+ ) . expect ( "Calculates storage root" ) ;
192
176
193
177
root. encode ( )
194
178
}
@@ -206,11 +190,11 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
206
190
Err ( _) => panic ! ( ) ,
207
191
} ;
208
192
209
- let mut iter = unwrap_trie_error ( trie. iter ( ) ) ;
210
- unwrap_trie_error ( iter. seek ( prefix) ) ;
193
+ let mut iter = trie. iter ( ) . expect ( "Creates trie iterator" ) ;
194
+ iter. seek ( prefix) . expect ( "Seek trie iterator" ) ;
211
195
212
196
for x in iter {
213
- let ( key, _) = unwrap_trie_error ( x ) ;
197
+ let ( key, _) = x . expect ( "Iterating trie iterator" ) ;
214
198
215
199
if !key. starts_with ( prefix) {
216
200
break ;
0 commit comments