@@ -405,7 +405,6 @@ where
405405 }
406406 }
407407 } ) ;
408- let mut used_txs = HashSet :: new ( ) ;
409408 let timeout = deadline. saturating_duration_since ( ( self . now ) ( ) ) ;
410409 let mut ready_txs = self
411410 . transaction_pool
@@ -432,26 +431,26 @@ where
432431 None
433432 } ;
434433 let preconf_deadline = self . effective_deadline( deadline) ;
435- let sub_block_payload = self
434+ if let Some ( sub_block_payload) = self
436435 . build_sub_block(
437436 & mut block_builder,
438437 preconf_deadline,
439438 block_size_limit,
440439 sub_block_count,
441440 base_only_if_first_block,
442- & mut used_txs,
443441 & mut ready_txs,
444442 )
445- . await ?;
443+ . await ? {
444+ let _ = self
445+ . send_message(
446+ serde_json:: to_string( & sub_block_payload)
447+ . unwrap_or_default( )
448+ . to_string( ) ,
449+ )
450+ . map_err( |e| sp_blockchain:: Error :: Application ( e) ) ?;
451+ // info!(target: "preconf-authorship", "Sent authoring signal for preconf block #{}", sub_block_count);
452+ }
446453 sub_block_count += 1 ;
447- let _ = self
448- . send_message(
449- serde_json:: to_string( & sub_block_payload)
450- . unwrap_or_default( )
451- . to_string( ) ,
452- )
453- . map_err( |e| sp_blockchain:: Error :: Application ( e) ) ?;
454- // info!(target: "preconf-authorship", "Sent authoring signal for preconf block #{}", sub_block_count);
455454 }
456455 None => break ,
457456 }
@@ -477,32 +476,28 @@ where
477476 block_size_limit : usize ,
478477 sub_block_index : u64 ,
479478 preconf_block_base : Option < PreConfBlockBase < Block > > ,
480- used_txs : & mut HashSet < Pool :: Hash > ,
481479 ready_txs : & mut ReadyTxs < Pool > ,
482- ) -> Result < PreConfBlockPayload < Block > , sp_blockchain:: Error > {
480+ ) -> Result < Option < PreConfBlockPayload < Block > > , sp_blockchain:: Error > {
483481 let ( end_reason, extrinsics) = self
484- . apply_extrinsics (
485- block_builder,
486- ready_txs,
487- preconf_deadline,
488- block_size_limit,
489- used_txs,
490- )
482+ . apply_extrinsics ( block_builder, ready_txs, preconf_deadline, block_size_limit)
491483 . await ?;
492484 let extrinsics_count = extrinsics. len ( ) ;
493- let diff = PreConfBlockDiff :: < Block > { extrinsics } ;
494- let payload = PreConfBlockPayload :: < Block > {
495- payload_id : Self :: new_payload_id ( self . parent_hash , sub_block_index) ,
496- index : sub_block_index,
497- base : preconf_block_base,
498- diff,
499- metadata : serde_json:: json!( {
500- "end_reason" : format!( "{:?}" , end_reason) ,
501- "extrinsics_count" : extrinsics_count,
502- } ) ,
503- } ;
504- info ! ( target: "preconf-authorship" , "Built preconf block #{} with {} extrinsics" , sub_block_index, extrinsics_count) ;
505- Ok ( payload)
485+ if extrinsics_count > 0 {
486+ let diff = PreConfBlockDiff :: < Block > { extrinsics } ;
487+ let payload = PreConfBlockPayload :: < Block > {
488+ payload_id : Self :: new_payload_id ( self . parent_hash , sub_block_index) ,
489+ index : sub_block_index,
490+ base : preconf_block_base,
491+ diff,
492+ metadata : serde_json:: json!( {
493+ "end_reason" : format!( "{:?}" , end_reason) ,
494+ "extrinsics_count" : extrinsics_count,
495+ } ) ,
496+ } ;
497+ Ok ( Some ( payload) )
498+ } else {
499+ Ok ( None )
500+ }
506501 }
507502
508503 fn apply_inherents (
@@ -557,7 +552,6 @@ where
557552 ready_txs : & mut ReadyTxs < Pool > ,
558553 deadline : time:: Instant ,
559554 block_size_limit : usize ,
560- used_txs : & mut HashSet < Pool :: Hash > ,
561555 ) -> Result < ( EndProposingReason , Vec < Block :: Extrinsic > ) , sp_blockchain:: Error > {
562556 let now = ( self . now ) ( ) ;
563557 let left = deadline. saturating_duration_since ( now) ;
@@ -575,7 +569,7 @@ where
575569 let pending_tx = if let Some ( pending_tx) = ready_txs. next ( ) {
576570 pending_tx
577571 } else {
578- info ! (
572+ debug ! (
579573 target: LOG_TARGET ,
580574 "No more transactions, proceeding with proposing."
581575 ) ;
0 commit comments