@@ -58,12 +58,22 @@ pub trait ServiceInterface<Block: BlockT> {
5858 candidate : ParachainCandidate < Block > ,
5959 ) -> Option < ( Collation , ParachainBlockData < Block > ) > ;
6060
61- /// Inform networking systems that the block should be announced after an appropriate
62- /// signal has been received. This returns the sending half of the signal.
61+ /// Inform networking systems that the block should be announced after a signal has
62+ /// been received to indicate the block has been seconded by a relay-chain validator.
63+ ///
64+ /// This sets up the barrier and returns the sending side of a channel, for the signal
65+ /// to be passed through.
6366 fn announce_with_barrier (
6467 & self ,
6568 block_hash : Block :: Hash ,
6669 ) -> oneshot:: Sender < CollationSecondedSignal > ;
70+
71+ /// Directly announce a block on the network.
72+ fn announce_block (
73+ & self ,
74+ block_hash : Block :: Hash ,
75+ data : Option < Vec < u8 > > ,
76+ ) ;
6777}
6878
6979/// The [`CollatorService`] provides common utilities for parachain consensus and authoring.
@@ -74,6 +84,7 @@ pub trait ServiceInterface<Block: BlockT> {
7484pub struct CollatorService < Block : BlockT , BS , RA > {
7585 block_status : Arc < BS > ,
7686 wait_to_announce : Arc < Mutex < WaitToAnnounce < Block > > > ,
87+ announce_block : Arc < dyn Fn ( Block :: Hash , Option < Vec < u8 > > ) + Send + Sync > ,
7788 runtime_api : Arc < RA > ,
7889}
7990
@@ -82,6 +93,7 @@ impl<Block: BlockT, BS, RA> Clone for CollatorService<Block, BS, RA> {
8293 Self {
8394 block_status : self . block_status . clone ( ) ,
8495 wait_to_announce : self . wait_to_announce . clone ( ) ,
96+ announce_block : self . announce_block . clone ( ) ,
8597 runtime_api : self . runtime_api . clone ( ) ,
8698 }
8799 }
@@ -101,9 +113,9 @@ where
101113 announce_block : Arc < dyn Fn ( Block :: Hash , Option < Vec < u8 > > ) + Send + Sync > ,
102114 runtime_api : Arc < RA > ,
103115 ) -> Self {
104- let wait_to_announce = Arc :: new ( Mutex :: new ( WaitToAnnounce :: new ( spawner, announce_block) ) ) ;
116+ let wait_to_announce = Arc :: new ( Mutex :: new ( WaitToAnnounce :: new ( spawner, announce_block. clone ( ) ) ) ) ;
105117
106- Self { block_status, wait_to_announce, runtime_api }
118+ Self { block_status, wait_to_announce, announce_block , runtime_api }
107119 }
108120
109121 /// Checks the status of the given block hash in the Parachain.
@@ -315,4 +327,12 @@ where
315327 ) -> oneshot:: Sender < CollationSecondedSignal > {
316328 CollatorService :: announce_with_barrier ( self , block_hash)
317329 }
330+
331+ fn announce_block (
332+ & self ,
333+ block_hash : Block :: Hash ,
334+ data : Option < Vec < u8 > > ,
335+ ) {
336+ ( self . announce_block ) ( block_hash, data)
337+ }
318338}
0 commit comments