File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
domains/pallets/messenger/src Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -142,14 +142,17 @@ impl<T: Config> Pallet<T> {
142142 let mut inbox_fees = BalanceOf :: < T > :: zero ( ) ;
143143 let mut removed_weight_tags = vec ! [ ] ;
144144 while let Some ( nonce) = current_nonce {
145- // note weight tags for inbox response messages
146- removed_weight_tags. push ( ( dst_chain_id, ( channel_id, nonce) ) ) ;
147-
148- // for every inbox response we take, distribute the reward to the operators.
149145 if InboxResponses :: < T > :: take ( ( dst_chain_id, channel_id, nonce) ) . is_none ( ) {
146+ // Make the loop efficient, by breaking as soon as there are no more responses.
147+ // If we didn't break here, we'd spend a lot of CPU hashing missing StorageMap
148+ // keys.
150149 break ;
151150 }
152151
152+ // Note removed weight tags for inbox response messages.
153+ removed_weight_tags. push ( ( dst_chain_id, ( channel_id, nonce) ) ) ;
154+
155+ // For every inbox response we take, distribute the reward to the operators.
153156 if let Some ( inbox_fee) = InboxFee :: < T > :: take ( ( dst_chain_id, ( channel_id, nonce) ) ) {
154157 inbox_fees = inbox_fees. saturating_add ( inbox_fee) ;
155158 }
You can’t perform that action at this time.
0 commit comments