@@ -143,22 +143,6 @@ impl<B: BlockT> WitnessStorage<B> {
143143 }
144144}
145145
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-
162146impl < B : BlockT > Storage for WitnessStorage < B > {
163147 fn get ( & self , key : & [ u8 ] ) -> Option < Vec < u8 > > {
164148 self . overlay
@@ -184,11 +168,11 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
184168 }
185169
186170 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 > > , _ , _ , _ , _ > (
188172 & mut self . witness_data ,
189173 self . storage_root . clone ( ) ,
190174 self . overlay . drain ( ) ,
191- ) ) ;
175+ ) . expect ( "Calculates storage root" ) ;
192176
193177 root. encode ( )
194178 }
@@ -206,11 +190,11 @@ impl<B: BlockT> Storage for WitnessStorage<B> {
206190 Err ( _) => panic ! ( ) ,
207191 } ;
208192
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" ) ;
211195
212196 for x in iter {
213- let ( key, _) = unwrap_trie_error ( x ) ;
197+ let ( key, _) = x . expect ( "Iterating trie iterator" ) ;
214198
215199 if !key. starts_with ( prefix) {
216200 break ;
0 commit comments