@@ -15,10 +15,16 @@ use {
1515 } ,
1616 } ,
1717 anyhow:: {
18- anyhow, bail, Context , Result
18+ anyhow,
19+ bail,
20+ Context ,
21+ Result ,
1922 } ,
2023 bincode:: Options ,
21- bytemuck:: { bytes_of, cast_slice} ,
24+ bytemuck:: {
25+ bytes_of,
26+ cast_slice,
27+ } ,
2228 chrono:: Utc ,
2329 futures_util:: future:: join_all,
2430 pyth_price_publisher:: accounts:: buffer:: BufferedPrice ,
@@ -81,6 +87,8 @@ pub struct ExporterState {
8187 /// Currently known permissioned prices of this publisher along with their market hours
8288 our_prices : RwLock < HashMap < Pubkey , PricePublishingMetadata > > ,
8389
90+ publisher_buffer_key : RwLock < Option < Pubkey > > ,
91+
8492 /// Recent compute unit price in micro lamports (set if dynamic compute unit pricing is enabled)
8593 recent_compute_unit_price_micro_lamports : RwLock < Option < u64 > > ,
8694}
@@ -106,6 +114,7 @@ where
106114 staleness_threshold : Duration ,
107115 unchanged_publish_threshold : Duration ,
108116 ) -> Result < Vec < PermissionedUpdate > > ;
117+ async fn get_publisher_buffer_key ( & self ) -> Option < Pubkey > ;
109118 async fn get_recent_compute_unit_price_micro_lamports ( & self ) -> Option < u64 > ;
110119 async fn update_recent_compute_unit_price (
111120 & self ,
@@ -114,11 +123,12 @@ where
114123 staleness_threshold : Duration ,
115124 unchanged_publish_threshold : Duration ,
116125 ) -> Result < ( ) > ;
117- async fn update_permissions (
126+ async fn update_on_chain_state (
118127 & self ,
119128 network : Network ,
120129 publish_keypair : Option < & Keypair > ,
121130 publisher_permissions : HashMap < Pubkey , HashMap < Pubkey , PricePublishingMetadata > > ,
131+ publisher_buffer_key : Option < Pubkey > ,
122132 ) -> Result < ( ) > ;
123133}
124134
@@ -267,6 +277,10 @@ where
267277 . collect :: < Vec < _ > > ( ) )
268278 }
269279
280+ async fn get_publisher_buffer_key ( & self ) -> Option < Pubkey > {
281+ * self . into ( ) . publisher_buffer_key . read ( ) . await
282+ }
283+
270284 async fn get_recent_compute_unit_price_micro_lamports ( & self ) -> Option < u64 > {
271285 * self
272286 . into ( )
@@ -313,11 +327,12 @@ where
313327 }
314328
315329 #[ instrument( skip( self , publish_keypair, publisher_permissions) ) ]
316- async fn update_permissions (
330+ async fn update_on_chain_state (
317331 & self ,
318332 network : Network ,
319333 publish_keypair : Option < & Keypair > ,
320334 publisher_permissions : HashMap < Pubkey , HashMap < Pubkey , PricePublishingMetadata > > ,
335+ publisher_buffer_key : Option < Pubkey > ,
321336 ) -> Result < ( ) > {
322337 let publish_keypair = get_publish_keypair ( self , network, publish_keypair) . await ?;
323338 * self . into ( ) . our_prices . write ( ) . await = publisher_permissions
@@ -330,6 +345,7 @@ where
330345 ) ;
331346 HashMap :: new ( )
332347 } ) ;
348+ * self . into ( ) . publisher_buffer_key . write ( ) . await = publisher_buffer_key;
333349
334350 Ok ( ( ) )
335351 }
@@ -580,7 +596,8 @@ where
580596 let instruction = create_instruction_with_publish_program (
581597 publish_keypair. pubkey ( ) ,
582598 publish_program_key,
583- publisher_buffer_key. context ( "must specify publisher_buffer_key if publish_program_key is specified" ) ?,
599+ publisher_buffer_key
600+ . context ( "must specify publisher_buffer_key if publish_program_key is specified" ) ?,
584601 updates,
585602 ) ?;
586603 instructions. push ( instruction) ;
@@ -805,7 +822,11 @@ fn create_instruction_with_publish_program(
805822 publisher_buffer_key : Pubkey ,
806823 prices : Vec < PermissionedUpdate > ,
807824) -> Result < Instruction > {
808- use pyth_price_publisher:: instruction:: { Instruction as PublishInstruction , SubmitPricesArgsHeader , PUBLISHER_CONFIG_SEED } ;
825+ use pyth_price_publisher:: instruction:: {
826+ Instruction as PublishInstruction ,
827+ SubmitPricesArgsHeader ,
828+ PUBLISHER_CONFIG_SEED ,
829+ } ;
809830 let ( publisher_config_key, publisher_config_bump) = Pubkey :: find_program_address (
810831 & [ PUBLISHER_CONFIG_SEED . as_bytes ( ) , & publish_pubkey. to_bytes ( ) ] ,
811832 & publish_program_key,
0 commit comments