From d0f46d6a8aab917250ed05c861b46cc8c4ee9464 Mon Sep 17 00:00:00 2001 From: Jack May Date: Thu, 11 Apr 2019 00:25:14 -0700 Subject: [PATCH] Cleanup client traits and create super trait (#3728) --- bench-tps/src/bench.rs | 3 +- client/src/rpc_client.rs | 2 +- client/src/thin_client.rs | 42 +++++---- core/src/cluster_tests.rs | 1 + core/src/local_cluster.rs | 2 +- core/src/replicator.rs | 3 +- core/src/storage_stage.rs | 3 +- programs/bpf/tests/programs.rs | 4 +- programs/budget_api/src/budget_processor.rs | 2 +- programs/config_api/src/config_processor.rs | 2 +- .../exchange_api/src/exchange_processor.rs | 2 +- programs/failure_program/tests/failure.rs | 2 +- programs/noop_program/tests/noop.rs | 2 +- programs/storage_api/src/storage_processor.rs | 2 +- programs/vote_api/src/vote_instruction.rs | 2 +- runtime/src/bank_client.rs | 29 +++++-- runtime/src/loader_utils.rs | 3 +- runtime/src/system_instruction_processor.rs | 2 +- sdk/src/async_client.rs | 35 -------- sdk/src/client.rs | 86 +++++++++++++++++++ sdk/src/lib.rs | 3 +- sdk/src/sync_client.rs | 36 -------- 22 files changed, 153 insertions(+), 115 deletions(-) delete mode 100644 sdk/src/async_client.rs create mode 100644 sdk/src/client.rs delete mode 100644 sdk/src/sync_client.rs diff --git a/bench-tps/src/bench.rs b/bench-tps/src/bench.rs index 3bf0d913a..096e77730 100644 --- a/bench-tps/src/bench.rs +++ b/bench-tps/src/bench.rs @@ -10,11 +10,10 @@ use solana_client::thin_client::create_client; use solana_client::thin_client::ThinClient; use solana_drone::drone::request_airdrop_transaction; use solana_metrics::influxdb; -use solana_sdk::async_client::AsyncClient; +use solana_sdk::client::{AsyncClient, SyncClient}; use solana_sdk::hash::Hash; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; -use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; use solana_sdk::system_transaction; use solana_sdk::timing::timestamp; diff --git a/client/src/rpc_client.rs b/client/src/rpc_client.rs index de71c30a2..93d06ab2b 100644 --- a/client/src/rpc_client.rs +++ b/client/src/rpc_client.rs @@ -266,7 +266,7 @@ impl RpcClient { /// Request the transaction count. If the response packet is dropped by the network, /// this method will try again 5 times. - pub fn get_transaction_count(&self) -> Result> { + pub fn get_transaction_count(&self) -> io::Result { debug!("get_transaction_count"); let mut num_retries = 5; diff --git a/client/src/thin_client.rs b/client/src/thin_client.rs index 1fd9fc860..8f0f0201a 100644 --- a/client/src/thin_client.rs +++ b/client/src/thin_client.rs @@ -6,18 +6,16 @@ use crate::rpc_client::RpcClient; use bincode::{serialize_into, serialized_size}; use log::*; -use solana_sdk::async_client::AsyncClient; +use solana_sdk::client::{AsyncClient, Client, SyncClient}; use solana_sdk::hash::Hash; use solana_sdk::instruction::Instruction; use solana_sdk::message::Message; use solana_sdk::packet::PACKET_DATA_SIZE; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; -use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; use solana_sdk::transaction::{self, Transaction}; use solana_sdk::transport::Result as TransportResult; -use std::error; use std::io; use std::net::{SocketAddr, UdpSocket}; use std::time::Duration; @@ -109,7 +107,7 @@ impl ThinClient { return Ok(transaction.signatures[0]); } info!("{} tries failed transfer to {}", x, self.transactions_addr); - transaction.sign(keypairs, self.get_recent_blockhash()?); + transaction.sign(keypairs, self.rpc_client.get_recent_blockhash()?); } Err(io::Error::new( io::ErrorKind::Other, @@ -117,14 +115,6 @@ impl ThinClient { )) } - pub fn get_transaction_count(&self) -> Result> { - self.rpc_client.get_transaction_count() - } - - pub fn get_recent_blockhash(&self) -> io::Result { - self.rpc_client.get_recent_blockhash() - } - pub fn get_new_blockhash(&self, blockhash: &Hash) -> io::Result { self.rpc_client.get_new_blockhash(blockhash) } @@ -178,6 +168,8 @@ impl ThinClient { } } +impl Client for ThinClient {} + impl SyncClient for ThinClient { fn send_message(&self, keypairs: &[&Keypair], message: Message) -> TransportResult { let blockhash = self.get_recent_blockhash()?; @@ -230,6 +222,16 @@ impl SyncClient for ThinClient { })?; Ok(status) } + + fn get_recent_blockhash(&self) -> TransportResult { + let recent_blockhash = self.rpc_client.get_recent_blockhash()?; + Ok(recent_blockhash) + } + + fn get_transaction_count(&self) -> TransportResult { + let transaction_count = self.rpc_client.get_transaction_count()?; + Ok(transaction_count) + } } impl AsyncClient for ThinClient { @@ -243,28 +245,34 @@ impl AsyncClient for ThinClient { .send_to(&buf[..], &self.transactions_addr)?; Ok(transaction.signatures[0]) } - fn async_send_message(&self, keypairs: &[&Keypair], message: Message) -> io::Result { - let blockhash = self.get_recent_blockhash()?; - let transaction = Transaction::new(&keypairs, message, blockhash); + fn async_send_message( + &self, + keypairs: &[&Keypair], + message: Message, + recent_blockhash: Hash, + ) -> io::Result { + let transaction = Transaction::new(&keypairs, message, recent_blockhash); self.async_send_transaction(transaction) } fn async_send_instruction( &self, keypair: &Keypair, instruction: Instruction, + recent_blockhash: Hash, ) -> io::Result { let message = Message::new(vec![instruction]); - self.async_send_message(&[keypair], message) + self.async_send_message(&[keypair], message, recent_blockhash) } fn async_transfer( &self, lamports: u64, keypair: &Keypair, pubkey: &Pubkey, + recent_blockhash: Hash, ) -> io::Result { let transfer_instruction = system_instruction::transfer(&keypair.pubkey(), pubkey, lamports); - self.async_send_instruction(keypair, transfer_instruction) + self.async_send_instruction(keypair, transfer_instruction, recent_blockhash) } } diff --git a/core/src/cluster_tests.rs b/core/src/cluster_tests.rs index 6b4bed68d..2b3b8f6cb 100644 --- a/core/src/cluster_tests.rs +++ b/core/src/cluster_tests.rs @@ -10,6 +10,7 @@ use crate::gossip_service::discover_nodes; use crate::locktower::VOTE_THRESHOLD_DEPTH; use crate::poh_service::PohServiceConfig; use solana_client::thin_client::create_client; +use solana_sdk::client::SyncClient; use solana_sdk::hash::Hash; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; use solana_sdk::system_transaction; diff --git a/core/src/local_cluster.rs b/core/src/local_cluster.rs index c25a2d2b9..5cd9cc920 100644 --- a/core/src/local_cluster.rs +++ b/core/src/local_cluster.rs @@ -8,10 +8,10 @@ use crate::replicator::Replicator; use crate::service::Service; use solana_client::thin_client::create_client; use solana_client::thin_client::ThinClient; +use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; -use solana_sdk::sync_client::SyncClient; use solana_sdk::system_transaction; use solana_sdk::timing::DEFAULT_SLOTS_PER_EPOCH; use solana_sdk::timing::DEFAULT_TICKS_PER_SLOT; diff --git a/core/src/replicator.rs b/core/src/replicator.rs index c8c22f15a..a065ee420 100644 --- a/core/src/replicator.rs +++ b/core/src/replicator.rs @@ -19,7 +19,8 @@ use rand::Rng; use solana_client::rpc_client::RpcClient; use solana_client::rpc_request::RpcRequest; use solana_client::thin_client::{create_client, ThinClient}; -use solana_sdk::async_client::AsyncClient; +use solana_sdk::client::{AsyncClient, SyncClient}; + use solana_sdk::hash::{Hash, Hasher}; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; use solana_sdk::system_transaction; diff --git a/core/src/storage_stage.rs b/core/src/storage_stage.rs index 9aecc8f3d..01d2ac1f0 100644 --- a/core/src/storage_stage.rs +++ b/core/src/storage_stage.rs @@ -13,11 +13,10 @@ use bincode::deserialize; use rand::{Rng, SeedableRng}; use rand_chacha::ChaChaRng; use solana_client::thin_client::{create_client_with_timeout, ThinClient}; -use solana_sdk::async_client::AsyncClient; +use solana_sdk::client::{AsyncClient, SyncClient}; use solana_sdk::hash::Hash; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; -use solana_sdk::sync_client::SyncClient; use solana_sdk::system_transaction; use solana_sdk::transaction::Transaction; use solana_storage_api::storage_instruction::{self, StorageInstruction}; diff --git a/programs/bpf/tests/programs.rs b/programs/bpf/tests/programs.rs index 4fc15998f..a1abaa33f 100644 --- a/programs/bpf/tests/programs.rs +++ b/programs/bpf/tests/programs.rs @@ -28,8 +28,8 @@ mod bpf { mod bpf_c { use super::*; use solana_sdk::bpf_loader; + use solana_sdk::client::SyncClient; use solana_sdk::signature::KeypairUtil; - use solana_sdk::sync_client::SyncClient; use std::io::Read; #[test] @@ -100,8 +100,8 @@ mod bpf { #[cfg(feature = "bpf_rust")] mod bpf_rust { use super::*; + use solana_sdk::client::SyncClient; use solana_sdk::signature::KeypairUtil; - use solana_sdk::sync_client::SyncClient; use std::io::Read; #[test] diff --git a/programs/budget_api/src/budget_processor.rs b/programs/budget_api/src/budget_processor.rs index 4c76a78f8..78f80b6fc 100644 --- a/programs/budget_api/src/budget_processor.rs +++ b/programs/budget_api/src/budget_processor.rs @@ -147,11 +147,11 @@ mod tests { use crate::id; use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; + use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::instruction::InstructionError; use solana_sdk::message::Message; use solana_sdk::signature::{Keypair, KeypairUtil}; - use solana_sdk::sync_client::SyncClient; use solana_sdk::transaction::TransactionError; fn create_bank(lamports: u64) -> (Bank, Keypair) { diff --git a/programs/config_api/src/config_processor.rs b/programs/config_api/src/config_processor.rs index b20687e8e..4488b3888 100644 --- a/programs/config_api/src/config_processor.rs +++ b/programs/config_api/src/config_processor.rs @@ -33,10 +33,10 @@ mod tests { use serde_derive::{Deserialize, Serialize}; use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; + use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::message::Message; use solana_sdk::signature::{Keypair, KeypairUtil}; - use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; #[derive(Serialize, Deserialize, Default, Debug, PartialEq)] diff --git a/programs/exchange_api/src/exchange_processor.rs b/programs/exchange_api/src/exchange_processor.rs index 7fdab85b7..8767c5fc2 100644 --- a/programs/exchange_api/src/exchange_processor.rs +++ b/programs/exchange_api/src/exchange_processor.rs @@ -451,9 +451,9 @@ mod test { use crate::exchange_instruction; use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; + use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::signature::{Keypair, KeypairUtil}; - use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; use std::mem; diff --git a/programs/failure_program/tests/failure.rs b/programs/failure_program/tests/failure.rs index a75f45459..da8c8d42d 100644 --- a/programs/failure_program/tests/failure.rs +++ b/programs/failure_program/tests/failure.rs @@ -1,11 +1,11 @@ use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; use solana_runtime::loader_utils::{create_invoke_instruction, load_program}; +use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::instruction::InstructionError; use solana_sdk::native_loader; use solana_sdk::signature::KeypairUtil; -use solana_sdk::sync_client::SyncClient; use solana_sdk::transaction::TransactionError; #[test] diff --git a/programs/noop_program/tests/noop.rs b/programs/noop_program/tests/noop.rs index 63d1500c0..64f744245 100644 --- a/programs/noop_program/tests/noop.rs +++ b/programs/noop_program/tests/noop.rs @@ -1,10 +1,10 @@ use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; use solana_runtime::loader_utils::{create_invoke_instruction, load_program}; +use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::native_loader; use solana_sdk::signature::KeypairUtil; -use solana_sdk::sync_client::SyncClient; #[test] fn test_program_native_noop() { diff --git a/programs/storage_api/src/storage_processor.rs b/programs/storage_api/src/storage_processor.rs index 86686fc49..230a03f86 100644 --- a/programs/storage_api/src/storage_processor.rs +++ b/programs/storage_api/src/storage_processor.rs @@ -90,12 +90,12 @@ mod tests { use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; use solana_sdk::account::{create_keyed_accounts, Account}; + use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::hash::{hash, Hash}; use solana_sdk::instruction::Instruction; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil, Signature}; - use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; fn test_instruction( diff --git a/programs/vote_api/src/vote_instruction.rs b/programs/vote_api/src/vote_instruction.rs index c77811e06..4dd137c1b 100644 --- a/programs/vote_api/src/vote_instruction.rs +++ b/programs/vote_api/src/vote_instruction.rs @@ -103,12 +103,12 @@ mod tests { use crate::vote_state::{Vote, VoteState}; use solana_runtime::bank::Bank; use solana_runtime::bank_client::BankClient; + use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::instruction::InstructionError; use solana_sdk::message::Message; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; - use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; use solana_sdk::transaction::{Result, TransactionError}; diff --git a/runtime/src/bank_client.rs b/runtime/src/bank_client.rs index bd4fd694a..a5dfe5211 100644 --- a/runtime/src/bank_client.rs +++ b/runtime/src/bank_client.rs @@ -1,11 +1,11 @@ use crate::bank::Bank; -use solana_sdk::async_client::AsyncClient; +use solana_sdk::client::{AsyncClient, SyncClient}; +use solana_sdk::hash::Hash; use solana_sdk::instruction::Instruction; use solana_sdk::message::Message; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::Signature; use solana_sdk::signature::{Keypair, KeypairUtil}; -use solana_sdk::sync_client::SyncClient; use solana_sdk::system_instruction; use solana_sdk::transaction::{self, Transaction}; use solana_sdk::transport::Result; @@ -23,9 +23,13 @@ impl<'a> AsyncClient for BankClient<'a> { Ok(transaction.signatures.get(0).cloned().unwrap_or_default()) } - fn async_send_message(&self, keypairs: &[&Keypair], message: Message) -> io::Result { - let blockhash = self.bank.last_blockhash(); - let transaction = Transaction::new(&keypairs, message, blockhash); + fn async_send_message( + &self, + keypairs: &[&Keypair], + message: Message, + recent_blockhash: Hash, + ) -> io::Result { + let transaction = Transaction::new(&keypairs, message, recent_blockhash); self.async_send_transaction(transaction) } @@ -33,9 +37,10 @@ impl<'a> AsyncClient for BankClient<'a> { &self, keypair: &Keypair, instruction: Instruction, + recent_blockhash: Hash, ) -> io::Result { let message = Message::new(vec![instruction]); - self.async_send_message(&[keypair], message) + self.async_send_message(&[keypair], message, recent_blockhash) } /// Transfer `lamports` from `keypair` to `pubkey` @@ -44,10 +49,11 @@ impl<'a> AsyncClient for BankClient<'a> { lamports: u64, keypair: &Keypair, pubkey: &Pubkey, + recent_blockhash: Hash, ) -> io::Result { let transfer_instruction = system_instruction::transfer(&keypair.pubkey(), pubkey, lamports); - self.async_send_instruction(keypair, transfer_instruction) + self.async_send_instruction(keypair, transfer_instruction, recent_blockhash) } } @@ -86,6 +92,15 @@ impl<'a> SyncClient for BankClient<'a> { ) -> Result>> { Ok(self.bank.get_signature_status(signature)) } + + fn get_recent_blockhash(&self) -> Result { + let last_blockhash = self.bank.last_blockhash(); + Ok(last_blockhash) + } + + fn get_transaction_count(&self) -> Result { + Ok(self.bank.transaction_count()) + } } impl<'a> BankClient<'a> { diff --git a/runtime/src/loader_utils.rs b/runtime/src/loader_utils.rs index ee3cec7f3..f96aa066c 100644 --- a/runtime/src/loader_utils.rs +++ b/runtime/src/loader_utils.rs @@ -1,10 +1,11 @@ use crate::bank_client::BankClient; use serde::Serialize; +use solana_sdk::client::SyncClient; use solana_sdk::instruction::{AccountMeta, Instruction}; use solana_sdk::loader_instruction; use solana_sdk::pubkey::Pubkey; use solana_sdk::signature::{Keypair, KeypairUtil}; -use solana_sdk::sync_client::SyncClient; + use solana_sdk::system_instruction; pub fn load_program( diff --git a/runtime/src/system_instruction_processor.rs b/runtime/src/system_instruction_processor.rs index d6b635c04..5439d4958 100644 --- a/runtime/src/system_instruction_processor.rs +++ b/runtime/src/system_instruction_processor.rs @@ -107,10 +107,10 @@ mod tests { use crate::bank::Bank; use crate::bank_client::BankClient; use solana_sdk::account::Account; + use solana_sdk::client::SyncClient; use solana_sdk::genesis_block::GenesisBlock; use solana_sdk::instruction::{AccountMeta, Instruction, InstructionError}; use solana_sdk::signature::{Keypair, KeypairUtil}; - use solana_sdk::sync_client::SyncClient; use solana_sdk::system_program; use solana_sdk::transaction::TransactionError; diff --git a/sdk/src/async_client.rs b/sdk/src/async_client.rs deleted file mode 100644 index 64440a1aa..000000000 --- a/sdk/src/async_client.rs +++ /dev/null @@ -1,35 +0,0 @@ -//! Defines a trait for non-blocking (asynchronous) communication with a Solana server. -//! Implementations are expected to create tranasctions, sign them, and send -//! them but without waiting to see if the server accepted it. - -use crate::instruction::Instruction; -use crate::message::Message; -use crate::pubkey::Pubkey; -use crate::signature::{Keypair, Signature}; -use crate::transaction::Transaction; -use std::io; - -pub trait AsyncClient { - /// Send a signed transaction, but don't wait to see if the server accepted it. - fn async_send_transaction(&self, transaction: Transaction) -> io::Result; - - /// Create a transaction from the given message, and send it to the - /// server, but don't wait for to see if the server accepted it. - fn async_send_message(&self, keypairs: &[&Keypair], message: Message) -> io::Result; - - /// Create a transaction from a single instruction that only requires - /// a single signer. Then send it to the server, but don't wait for a reply. - fn async_send_instruction( - &self, - keypair: &Keypair, - instruction: Instruction, - ) -> io::Result; - - /// Attempt to transfer lamports from `keypair` to `pubkey`, but don't wait to confirm. - fn async_transfer( - &self, - lamports: u64, - keypair: &Keypair, - pubkey: &Pubkey, - ) -> io::Result; -} diff --git a/sdk/src/client.rs b/sdk/src/client.rs new file mode 100644 index 000000000..034627934 --- /dev/null +++ b/sdk/src/client.rs @@ -0,0 +1,86 @@ +//! Defines traits for blocking (synchronous) and non-blocking (asynchronous) +//! communication with a Solana server as well a a trait that encompasses both. +//! +//! //! Synchronous implementations are expected to create transactions, sign them, and send +//! them with multiple retries, updating blockhashes and resigning as-needed. +//! +//! Asynchronous implementations are expected to create transactions, sign them, and send +//! them but without waiting to see if the server accepted it. + +use crate::hash::Hash; +use crate::instruction::Instruction; +use crate::message::Message; +use crate::pubkey::Pubkey; +use crate::signature::{Keypair, Signature}; +use crate::transaction; +use crate::transport::Result; +use std::io; + +pub trait Client: SyncClient + AsyncClient {} + +pub trait SyncClient { + /// Create a transaction from the given message, and send it to the + /// server, retrying as-needed. + fn send_message(&self, keypairs: &[&Keypair], message: Message) -> Result; + + /// Create a transaction from a single instruction that only requires + /// a single signer. Then send it to the server, retrying as-needed. + fn send_instruction(&self, keypair: &Keypair, instruction: Instruction) -> Result; + + /// Transfer lamports from `keypair` to `pubkey`, retrying until the + /// transfer completes or produces and error. + fn transfer(&self, lamports: u64, keypair: &Keypair, pubkey: &Pubkey) -> Result; + + /// Get an account or None if not found. + fn get_account_data(&self, pubkey: &Pubkey) -> Result>>; + + /// Get account balance or 0 if not found. + fn get_balance(&self, pubkey: &Pubkey) -> Result; + + /// Get signature status. + fn get_signature_status( + &self, + signature: &Signature, + ) -> Result>>; + + /// Get recent blockhash + fn get_recent_blockhash(&self) -> Result; + + /// Get transaction count + fn get_transaction_count(&self) -> Result; +} + +pub trait AsyncClient { + /// Send a signed transaction, but don't wait to see if the server accepted it. + fn async_send_transaction( + &self, + transaction: transaction::Transaction, + ) -> io::Result; + + /// Create a transaction from the given message, and send it to the + /// server, but don't wait for to see if the server accepted it. + fn async_send_message( + &self, + keypairs: &[&Keypair], + message: Message, + recent_blockhash: Hash, + ) -> io::Result; + + /// Create a transaction from a single instruction that only requires + /// a single signer. Then send it to the server, but don't wait for a reply. + fn async_send_instruction( + &self, + keypair: &Keypair, + instruction: Instruction, + recent_blockhash: Hash, + ) -> io::Result; + + /// Attempt to transfer lamports from `keypair` to `pubkey`, but don't wait to confirm. + fn async_transfer( + &self, + lamports: u64, + keypair: &Keypair, + pubkey: &Pubkey, + recent_blockhash: Hash, + ) -> io::Result; +} diff --git a/sdk/src/lib.rs b/sdk/src/lib.rs index 49f25fd5f..ff53e3651 100644 --- a/sdk/src/lib.rs +++ b/sdk/src/lib.rs @@ -1,6 +1,6 @@ pub mod account; -pub mod async_client; pub mod bpf_loader; +pub mod client; pub mod fee_calculator; pub mod genesis_block; pub mod hash; @@ -14,7 +14,6 @@ pub mod pubkey; pub mod rpc_port; pub mod short_vec; pub mod signature; -pub mod sync_client; pub mod system_instruction; pub mod system_program; pub mod system_transaction; diff --git a/sdk/src/sync_client.rs b/sdk/src/sync_client.rs deleted file mode 100644 index adb2a6226..000000000 --- a/sdk/src/sync_client.rs +++ /dev/null @@ -1,36 +0,0 @@ -//! Defines a trait for blocking (synchronous) communication with a Solana server. -//! Implementations are expected to create tranasctions, sign them, and send -//! them with multiple retries, updating blockhashes and resigning as-needed. - -use crate::instruction::Instruction; -use crate::message::Message; -use crate::pubkey::Pubkey; -use crate::signature::{Keypair, Signature}; -use crate::transaction; -use crate::transport::Result; - -pub trait SyncClient { - /// Create a transaction from the given message, and send it to the - /// server, retrying as-needed. - fn send_message(&self, keypairs: &[&Keypair], message: Message) -> Result; - - /// Create a transaction from a single instruction that only requires - /// a single signer. Then send it to the server, retrying as-needed. - fn send_instruction(&self, keypair: &Keypair, instruction: Instruction) -> Result; - - /// Transfer lamports from `keypair` to `pubkey`, retrying until the - /// transfer completes or produces and error. - fn transfer(&self, lamports: u64, keypair: &Keypair, pubkey: &Pubkey) -> Result; - - /// Get an account or None if not found. - fn get_account_data(&self, pubkey: &Pubkey) -> Result>>; - - /// Get account balance or 0 if not found. - fn get_balance(&self, pubkey: &Pubkey) -> Result; - - /// Get signature status. - fn get_signature_status( - &self, - signature: &Signature, - ) -> Result>>; -}