@@ -863,7 +863,7 @@ ServiceBuilder<
863863 let network_status_sinks = Arc :: new ( Mutex :: new ( status_sinks:: StatusSinks :: new ( ) ) ) ;
864864
865865 let offchain_storage = backend. offchain_storage ( ) ;
866- let offchain_workers = match ( config. offchain_worker , offchain_storage) {
866+ let offchain_workers = match ( config. offchain_worker , offchain_storage. clone ( ) ) {
867867 ( true , Some ( db) ) => {
868868 Some ( Arc :: new ( sc_offchain:: OffchainWorkers :: new ( client. clone ( ) , db) ) )
869869 } ,
@@ -1008,7 +1008,7 @@ ServiceBuilder<
10081008 // RPC
10091009 let ( system_rpc_tx, system_rpc_rx) = mpsc:: unbounded ( ) ;
10101010 let gen_handler = || {
1011- use sc_rpc:: { chain, state, author, system} ;
1011+ use sc_rpc:: { chain, state, author, system, offchain } ;
10121012
10131013 let system_info = sc_rpc:: system:: SystemInfo {
10141014 chain_name : config. chain_spec . name ( ) . into ( ) ,
@@ -1054,13 +1054,26 @@ ServiceBuilder<
10541054 ) ;
10551055 let system = system:: System :: new ( system_info, system_rpc_tx. clone ( ) ) ;
10561056
1057- sc_rpc_server:: rpc_handler ( (
1058- state:: StateApi :: to_delegate ( state) ,
1059- chain:: ChainApi :: to_delegate ( chain) ,
1060- author:: AuthorApi :: to_delegate ( author) ,
1061- system:: SystemApi :: to_delegate ( system) ,
1062- rpc_extensions. clone ( ) ,
1063- ) )
1057+ match offchain_storage. clone ( ) {
1058+ Some ( storage) => {
1059+ let offchain = sc_rpc:: offchain:: Offchain :: new ( storage) ;
1060+ sc_rpc_server:: rpc_handler ( (
1061+ state:: StateApi :: to_delegate ( state) ,
1062+ chain:: ChainApi :: to_delegate ( chain) ,
1063+ offchain:: OffchainApi :: to_delegate ( offchain) ,
1064+ author:: AuthorApi :: to_delegate ( author) ,
1065+ system:: SystemApi :: to_delegate ( system) ,
1066+ rpc_extensions. clone ( ) ,
1067+ ) )
1068+ } ,
1069+ None => sc_rpc_server:: rpc_handler ( (
1070+ state:: StateApi :: to_delegate ( state) ,
1071+ chain:: ChainApi :: to_delegate ( chain) ,
1072+ author:: AuthorApi :: to_delegate ( author) ,
1073+ system:: SystemApi :: to_delegate ( system) ,
1074+ rpc_extensions. clone ( ) ,
1075+ ) )
1076+ }
10641077 } ;
10651078 let rpc_handlers = gen_handler ( ) ;
10661079 let rpc = start_rpc_servers ( & config, gen_handler) ?;
0 commit comments