@@ -43,6 +43,7 @@ impl BlockProducerState {
4343}
4444
4545impl BlockProducerEnabled {
46+ /// Substate is accesses from global state, because applied blocks from transition frontier are required
4647 pub fn reducer ( mut state_context : Substate < State > , action : BlockProducerActionWithMetaRef < ' _ > ) {
4748 let ( action, meta) = action. split ( ) ;
4849 let Ok ( global_state) = state_context. get_substate_mut ( ) else {
@@ -88,11 +89,10 @@ impl BlockProducerEnabled {
8889 won_slot : won_slot. clone ( ) ,
8990 } ;
9091
91- state_context
92- . into_dispatcher ( )
93- . push ( BlockProducerEffectfulAction :: WonSlot {
94- won_slot : won_slot. clone ( ) ,
95- } ) ;
92+ let dispatcher = state_context. into_dispatcher ( ) ;
93+ dispatcher. push ( BlockProducerEffectfulAction :: WonSlot {
94+ won_slot : won_slot. clone ( ) ,
95+ } ) ;
9696 }
9797 BlockProducerAction :: WonSlotDiscard { reason } => {
9898 if let Some ( won_slot) = state. current . won_slot ( ) {
@@ -103,9 +103,8 @@ impl BlockProducerEnabled {
103103 } ;
104104 }
105105
106- state_context
107- . into_dispatcher ( )
108- . push ( BlockProducerEffectfulAction :: WonSlotDiscard { reason : * reason } ) ;
106+ let dispatcher = state_context. into_dispatcher ( ) ;
107+ dispatcher. push ( BlockProducerEffectfulAction :: WonSlotDiscard { reason : * reason } ) ;
109108 }
110109 BlockProducerAction :: WonSlotWait => {
111110 if let Some ( won_slot) = state. current . won_slot ( ) {
@@ -129,9 +128,8 @@ impl BlockProducerEnabled {
129128 chain : chain. clone ( ) ,
130129 } ;
131130
132- state_context
133- . into_dispatcher ( )
134- . push ( TransactionPoolAction :: CollectTransactionsByFee ) ;
131+ let dispatcher = state_context. into_dispatcher ( ) ;
132+ dispatcher. push ( TransactionPoolAction :: CollectTransactionsByFee ) ;
135133 }
136134 BlockProducerAction :: WonSlotTransactionsSuccess {
137135 transactions_by_fee,
@@ -150,9 +148,8 @@ impl BlockProducerEnabled {
150148 transactions_by_fee : transactions_by_fee. clone ( ) ,
151149 } ;
152150
153- state_context
154- . into_dispatcher ( )
155- . push ( BlockProducerAction :: StagedLedgerDiffCreateInit ) ;
151+ let dispatcher = state_context. into_dispatcher ( ) ;
152+ dispatcher. push ( BlockProducerAction :: StagedLedgerDiffCreateInit ) ;
156153 }
157154 BlockProducerAction :: WonSlotProduceInit => {
158155 if let Some ( won_slot) = state. current . won_slot ( ) {
@@ -173,14 +170,12 @@ impl BlockProducerEnabled {
173170 } ;
174171 }
175172
176- state_context
177- . into_dispatcher ( )
178- . push ( BlockProducerAction :: WonSlotTransactionsGet ) ;
173+ let dispatcher = state_context. into_dispatcher ( ) ;
174+ dispatcher. push ( BlockProducerAction :: WonSlotTransactionsGet ) ;
179175 }
180176 BlockProducerAction :: StagedLedgerDiffCreateInit => {
181- state_context
182- . into_dispatcher ( )
183- . push ( BlockProducerEffectfulAction :: StagedLedgerDiffCreateInit ) ;
177+ let dispatcher = state_context. into_dispatcher ( ) ;
178+ dispatcher. push ( BlockProducerEffectfulAction :: StagedLedgerDiffCreateInit ) ;
184179 }
185180 BlockProducerAction :: StagedLedgerDiffCreatePending => {
186181 let BlockProducerCurrentState :: WonSlotTransactionsSuccess {
@@ -221,21 +216,18 @@ impl BlockProducerEnabled {
221216 stake_proof_sparse_ledger : output. stake_proof_sparse_ledger . clone ( ) ,
222217 } ;
223218
224- state_context
225- . into_dispatcher ( )
226- . push ( BlockProducerEffectfulAction :: StagedLedgerDiffCreateSuccess ) ;
219+ let dispatcher = state_context. into_dispatcher ( ) ;
220+ dispatcher. push ( BlockProducerEffectfulAction :: StagedLedgerDiffCreateSuccess ) ;
227221 }
228222 BlockProducerAction :: BlockUnprovenBuild => {
229223 state. reduce_block_unproved_build ( meta. time ( ) ) ;
230224
231- state_context
232- . into_dispatcher ( )
233- . push ( BlockProducerEffectfulAction :: BlockUnprovenBuild ) ;
225+ let dispatcher = state_context. into_dispatcher ( ) ;
226+ dispatcher. push ( BlockProducerEffectfulAction :: BlockUnprovenBuild ) ;
234227 }
235228 BlockProducerAction :: BlockProveInit => {
236- state_context
237- . into_dispatcher ( )
238- . push ( BlockProducerEffectfulAction :: BlockProveInit ) ;
229+ let dispatcher = state_context. into_dispatcher ( ) ;
230+ dispatcher. push ( BlockProducerEffectfulAction :: BlockProveInit ) ;
239231 }
240232 BlockProducerAction :: BlockProvePending => {
241233 if let BlockProducerCurrentState :: BlockUnprovenBuilt {
@@ -282,9 +274,8 @@ impl BlockProducerEnabled {
282274 } ;
283275 }
284276
285- state_context
286- . into_dispatcher ( )
287- . push ( BlockProducerEffectfulAction :: BlockProveSuccess ) ;
277+ let dispatcher = state_context. into_dispatcher ( ) ;
278+ dispatcher. push ( BlockProducerEffectfulAction :: BlockProveSuccess ) ;
288279 }
289280 BlockProducerAction :: BlockProduced => {
290281 if let BlockProducerCurrentState :: BlockProveSuccess {
@@ -304,9 +295,8 @@ impl BlockProducerEnabled {
304295 } ;
305296 }
306297
307- state_context
308- . into_dispatcher ( )
309- . push ( BlockProducerAction :: BlockInject ) ;
298+ let dispatcher = state_context. into_dispatcher ( ) ;
299+ dispatcher. push ( BlockProducerAction :: BlockInject ) ;
310300 }
311301 BlockProducerAction :: BlockInject => {
312302 let ( dispatcher, state) = state_context. into_dispatcher_and_state ( ) ;
@@ -355,9 +345,8 @@ impl BlockProducerEnabled {
355345 } ;
356346 }
357347
358- state_context
359- . into_dispatcher ( )
360- . push ( BlockProducerAction :: WonSlotSearch ) ;
348+ let dispatcher = state_context. into_dispatcher ( ) ;
349+ dispatcher. push ( BlockProducerAction :: WonSlotSearch ) ;
361350 }
362351 }
363352 }
0 commit comments