File tree Expand file tree Collapse file tree 5 files changed +24
-0
lines changed Expand file tree Collapse file tree 5 files changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -505,6 +505,16 @@ impl EngineInfo for Client {
505505 } )
506506 }
507507
508+ fn metadata_seq ( & self , block_id : BlockId ) -> Option < u64 > {
509+ self . state_info ( block_id. into ( ) ) . map ( |state| {
510+ state
511+ . metadata ( )
512+ . unwrap_or_else ( |err| unreachable ! ( "Unexpected failure. Maybe DB was corrupted: {:?}" , err) )
513+ . unwrap ( )
514+ . seq ( )
515+ } )
516+ }
517+
508518 fn block_reward ( & self , block_number : u64 ) -> u64 {
509519 self . engine ( ) . block_reward ( block_number)
510520 }
Original file line number Diff line number Diff line change @@ -88,6 +88,7 @@ pub trait BlockChainTrait {
8888
8989pub trait EngineInfo : Send + Sync {
9090 fn common_params ( & self , block_id : BlockId ) -> Option < CommonParams > ;
91+ fn metadata_seq ( & self , block_id : BlockId ) -> Option < u64 > ;
9192 fn block_reward ( & self , block_number : u64 ) -> u64 ;
9293 fn mining_reward ( & self , block_number : u64 ) -> Option < u64 > ;
9394 fn recommended_confirmation ( & self ) -> u32 ;
Original file line number Diff line number Diff line change @@ -589,6 +589,10 @@ impl EngineInfo for TestBlockChainClient {
589589 unimplemented ! ( )
590590 }
591591
592+ fn metadata_seq ( & self , _block_id : BlockId ) -> Option < u64 > {
593+ unimplemented ! ( )
594+ }
595+
592596 fn block_reward ( & self , _block_number : u64 ) -> u64 {
593597 unimplemented ! ( )
594598 }
Original file line number Diff line number Diff line change @@ -316,6 +316,11 @@ where
316316 }
317317 }
318318
319+ fn get_metadata_seq ( & self , block_number : Option < u64 > ) -> Result < Option < u64 > > {
320+ let block_id = block_number. map ( BlockId :: Number ) . unwrap_or ( BlockId :: Latest ) ;
321+ Ok ( self . client . metadata_seq ( block_id) )
322+ }
323+
319324 fn get_possible_authors ( & self , block_number : Option < u64 > ) -> Result < Option < Vec < PlatformAddress > > > {
320325 Ok ( self . client . possible_authors ( block_number) . map_err ( errors:: core) ?)
321326 }
Original file line number Diff line number Diff line change @@ -145,6 +145,10 @@ build_rpc_trait! {
145145 #[ rpc( name = "chain_getTermMetadata" ) ]
146146 fn get_term_metadata( & self , Option <u64 >) -> Result <Option <( u64 , u64 ) >>;
147147
148+ /// Return the current metadata seq at given block number
149+ #[ rpc( name = "chain_getMetadataSeq" ) ]
150+ fn get_metadata_seq( & self , Option <u64 >) -> Result <Option <u64 >>;
151+
148152 /// Return the valid block authors
149153 #[ rpc( name = "chain_getPossibleAuthors" ) ]
150154 fn get_possible_authors( & self , Option <u64 >) -> Result <Option <Vec <PlatformAddress >>>;
You can’t perform that action at this time.
0 commit comments