@@ -270,14 +270,10 @@ impl MagicValidator {
270
270
None
271
271
} ;
272
272
273
- let accounts_config =
274
- try_convert_accounts_config ( & config. validator_config . accounts )
275
- . map_err ( ApiError :: ConfigError ) ?;
276
-
277
- let remote_rpc_config = RpcProviderConfig :: new (
278
- try_rpc_cluster_from_cluster ( & accounts_config. remote_cluster ) ?,
279
- Some ( CommitmentLevel :: Confirmed ) ,
280
- ) ;
273
+ let ( accounts_config, remote_rpc_config) =
274
+ try_get_remote_accounts_and_rpc_config (
275
+ & config. validator_config . accounts ,
276
+ ) ?;
281
277
282
278
let remote_account_fetcher_worker =
283
279
RemoteAccountFetcherWorker :: new ( remote_rpc_config. clone ( ) ) ;
@@ -656,20 +652,10 @@ impl MagicValidator {
656
652
}
657
653
658
654
async fn ensure_validator_funded_on_chain ( & self ) -> ApiResult < ( ) > {
659
- // TODO(thlorenz) make this configurable in the future
655
+ // NOTE: 5 SOL seems reasonable, but we may require a different amount in the future
660
656
const MIN_BALANCE_SOL : u64 = 5 ;
661
- // TODO: @@ duplicate code getting remote_rpc_config
662
- let accounts_config = try_convert_accounts_config (
663
- & self . config . accounts ,
664
- )
665
- . expect (
666
- "Failed to derive accounts config from provided magicblock config" ,
667
- ) ;
668
- let remote_rpc_config = RpcProviderConfig :: new (
669
- try_rpc_cluster_from_cluster ( & accounts_config. remote_cluster ) ?,
670
- Some ( CommitmentLevel :: Confirmed ) ,
671
- ) ;
672
-
657
+ let ( _, remote_rpc_config) =
658
+ try_get_remote_accounts_and_rpc_config ( & self . config . accounts ) ?;
673
659
let validator_pubkey = self . bank ( ) . get_identity ( ) ;
674
660
675
661
let lamports = RpcClient :: new_with_commitment (
@@ -895,3 +881,15 @@ fn create_worker_runtime(thread_name: &str) -> tokio::runtime::Runtime {
895
881
. build ( )
896
882
. unwrap ( )
897
883
}
884
+
885
+ fn try_get_remote_accounts_and_rpc_config (
886
+ accounts : & magicblock_config:: AccountsConfig ,
887
+ ) -> ApiResult < ( magicblock_accounts:: AccountsConfig , RpcProviderConfig ) > {
888
+ let accounts_config =
889
+ try_convert_accounts_config ( accounts) . map_err ( ApiError :: ConfigError ) ?;
890
+ let remote_rpc_config = RpcProviderConfig :: new (
891
+ try_rpc_cluster_from_cluster ( & accounts_config. remote_cluster ) ?,
892
+ Some ( CommitmentLevel :: Confirmed ) ,
893
+ ) ;
894
+ Ok ( ( accounts_config, remote_rpc_config) )
895
+ }
0 commit comments