@@ -55,7 +55,7 @@ pub struct CachedProgramConfig {
5555pub struct PdaCompressor < R : Rpc + Indexer > {
5656 rpc_pool : Arc < SolanaRpcPool < R > > ,
5757 tracker : Arc < PdaAccountTracker > ,
58- payer_keypair : Keypair ,
58+ payer_keypair : Arc < Keypair > ,
5959 transaction_policy : TransactionPolicy ,
6060}
6161
@@ -64,7 +64,7 @@ impl<R: Rpc + Indexer> Clone for PdaCompressor<R> {
6464 Self {
6565 rpc_pool : Arc :: clone ( & self . rpc_pool ) ,
6666 tracker : Arc :: clone ( & self . tracker ) ,
67- payer_keypair : self . payer_keypair . insecure_clone ( ) ,
67+ payer_keypair : Arc :: clone ( & self . payer_keypair ) ,
6868 transaction_policy : self . transaction_policy ,
6969 }
7070 }
@@ -80,7 +80,7 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
8080 Self {
8181 rpc_pool,
8282 tracker,
83- payer_keypair,
83+ payer_keypair : Arc :: new ( payer_keypair ) ,
8484 transaction_policy,
8585 }
8686 }
@@ -171,10 +171,12 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
171171 self . tracker . mark_pending ( & all_pubkeys) ;
172172
173173 // Create futures for each account
174- let compression_futures = account_states. iter ( ) . cloned ( ) . map ( |account_state| {
174+ let program_config = Arc :: new ( program_config. clone ( ) ) ;
175+ let cached_config = Arc :: new ( cached_config. clone ( ) ) ;
176+ let compression_futures = account_states. iter ( ) . map ( |account_state| {
175177 let compressor = self . clone ( ) ;
176- let program_config = program_config . clone ( ) ;
177- let cached_config = cached_config . clone ( ) ;
178+ let program_config = Arc :: clone ( & program_config ) ;
179+ let cached_config = Arc :: clone ( & cached_config ) ;
178180 let cancelled = cancelled. clone ( ) ;
179181
180182 async move {
@@ -183,21 +185,21 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
183185 // Unmark since we won't process this account
184186 compressor. tracker . unmark_pending ( & [ account_state. pubkey ] ) ;
185187 return CompressionOutcome :: Failed {
186- state : account_state,
188+ state : account_state. clone ( ) ,
187189 error : CompressionTaskError :: Cancelled ,
188190 } ;
189191 }
190192
191193 match compressor
192- . compress ( & account_state, & program_config, & cached_config)
194+ . compress ( account_state, & program_config, & cached_config)
193195 . await
194196 {
195197 Ok ( sig) => CompressionOutcome :: Compressed {
196198 signature : sig,
197- state : account_state,
199+ state : account_state. clone ( ) ,
198200 } ,
199201 Err ( e) => CompressionOutcome :: Failed {
200- state : account_state,
202+ state : account_state. clone ( ) ,
201203 error : e. into ( ) ,
202204 } ,
203205 }
@@ -317,7 +319,7 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
317319 send_and_confirm_with_tracking (
318320 & mut * rpc,
319321 & [ ix] ,
320- & self . payer_keypair ,
322+ self . payer_keypair . as_ref ( ) ,
321323 self . transaction_policy ,
322324 & * self . tracker ,
323325 & pubkeys,
@@ -396,7 +398,7 @@ impl<R: Rpc + Indexer> PdaCompressor<R> {
396398 ) ;
397399
398400 let payer_pubkey = self . payer_keypair . pubkey ( ) ;
399- let signers = [ & self . payer_keypair ] ;
401+ let signers = [ self . payer_keypair . as_ref ( ) ] ;
400402 let instructions = vec ! [ ix] ;
401403 let priority_fee_accounts = collect_priority_fee_accounts ( payer_pubkey, & instructions) ;
402404 let signature = send_transaction_with_policy (
0 commit comments