1
1
use jito_protos:: {
2
2
bundle:: { bundle_result:: Result as BundleResultType , rejected:: Reason , Bundle } ,
3
3
searcher:: {
4
- searcher_service_client:: SearcherServiceClient , NextScheduledLeaderRequest ,
5
- SubscribeBundleResultsRequest , GetTipAccountsRequest
4
+ searcher_service_client:: SearcherServiceClient , GetTipAccountsRequest ,
5
+ NextScheduledLeaderRequest , SubscribeBundleResultsRequest ,
6
6
} ,
7
7
} ;
8
- use std:: str:: FromStr ;
9
8
use jito_searcher_client:: { get_searcher_client_no_auth, send_bundle_with_confirmation} ;
10
9
use solana_client:: nonblocking:: rpc_client:: RpcClient ;
11
10
use solana_sdk:: {
12
- commitment_config:: CommitmentConfig , instruction:: Instruction , pubkey:: Pubkey , signature:: { Keypair , Signer } , system_instruction:: transfer, transaction:: { Transaction , VersionedTransaction }
11
+ commitment_config:: CommitmentConfig ,
12
+ instruction:: Instruction ,
13
+ pubkey:: Pubkey ,
14
+ signature:: { Keypair , Signer } ,
15
+ system_instruction:: transfer,
16
+ transaction:: { Transaction , VersionedTransaction } ,
13
17
} ;
18
+ use std:: str:: FromStr ;
14
19
use tokio:: time:: sleep;
15
20
use tonic:: transport:: Channel ;
16
21
17
22
pub struct JitoClient {
18
23
rpc : RpcClient ,
19
24
searcher_client : SearcherServiceClient < Channel > ,
20
25
keypair : Keypair ,
21
- tip_accounts : Vec < String >
26
+ tip_accounts : Vec < String > ,
22
27
}
23
28
24
29
impl JitoClient {
@@ -32,7 +37,7 @@ impl JitoClient {
32
37
rpc,
33
38
searcher_client,
34
39
keypair,
35
- tip_accounts : Vec :: new ( )
40
+ tip_accounts : Vec :: new ( ) ,
36
41
}
37
42
}
38
43
@@ -48,7 +53,8 @@ impl JitoClient {
48
53
49
54
let mut is_jito_leader = false ;
50
55
while !is_jito_leader {
51
- let next_leader = self . searcher_client
56
+ let next_leader = self
57
+ . searcher_client
52
58
. get_next_scheduled_leader ( NextScheduledLeaderRequest { } )
53
59
. await
54
60
. expect ( "Failed to get next scheduled leader" )
@@ -63,7 +69,11 @@ impl JitoClient {
63
69
Transaction :: new_signed_with_payer(
64
70
& [
65
71
ix,
66
- transfer( & self . keypair. pubkey( ) , & Pubkey :: from_str( & self . tip_accounts[ 0 ] ) ?, lamports) ,
72
+ transfer(
73
+ & self . keypair. pubkey( ) ,
74
+ & Pubkey :: from_str( & self . tip_accounts[ 0 ] ) ?,
75
+ lamports,
76
+ ) ,
67
77
] ,
68
78
Some ( & self . keypair. pubkey( ) ) ,
69
79
& [ & self . keypair] ,
@@ -90,28 +100,10 @@ impl JitoClient {
90
100
. await
91
101
. expect ( "Failed to get tip accounts" )
92
102
. into_inner ( ) ;
93
-
103
+
94
104
self . tip_accounts = tip_accounts. accounts ;
95
105
96
106
Ok ( ( ) )
97
107
}
98
-
99
108
}
100
109
101
- #[ cfg( test) ]
102
- mod tests {
103
- use solana_sdk:: signer:: keypair;
104
-
105
- use super :: * ;
106
- #[ tokio:: test]
107
- async fn test_leader ( ) {
108
- let keypair = Keypair :: new ( ) ;
109
- let mut jito_client = JitoClient :: new (
110
- "https://rpc.ironforge.network/mainnet?apiKey=01HTYZW4C7W74CTK8N8XN2GMR5" . to_string ( ) ,
111
- keypair,
112
- "https://mainnet.block-engine.jito.wtf" . to_string ( ) ,
113
- )
114
- . await ;
115
- jito_client. get_tip_accounts ( ) . await ;
116
- }
117
- }
0 commit comments