I am trying to connect to solana using the ThinClient provided by the solana client library: https://docs.rs/solana-client/latest/solana_client/thin_client/struct.ThinClient.html
It requires a Rpc Address and a TPU address and a connection Cache. The Rpc address seems to be working fine(since the rpc client functions are working), however for the TPU address (I guess that's the problem since the error doesn't really tell much) gives a connection timeout error when I try to do something with it(like sending a transaction)
Here is the function where I am trying to send a transaction:
fn thinclientsendtransaction(program_id: Pubkey, payer: &Keypair){
let rpc_addr="127.0.0.1:8899".parse::<SocketAddr>().unwrap();
let tpu_addr="0.0.0.0:1027".parse::<SocketAddr>().unwrap();
let connectioncache=connection_cache::ConnectionCache::new(20000000);
let client=ThinClient::new(rpc_addr, tpu_addr, Arc::new(connectioncache));
let bankins=BankInstruction::Initialize;
let instruction = Instruction::new_with_borsh(
program_id,
&bankins,
vec![],
);
let message = Message::new(
&[instruction],
Some(&payer.pubkey()),
);
let blockhash = client.rpc_client().get_latest_blockhash().unwrap();
let tx = Transaction::new(&[payer], message, blockhash);
let x=client.async_send_transaction(tx).unwrap();
//let x=client.get_account(&program_id).unwrap();
println!("{:#?}",x);
}
The full project can be found here: https://github.com/Lioncat2002/SolanaProjectTest
Any help/pointers to the right direction will be highly appreciated!