Clean up get_last_id()
This commit is contained in:
@ -38,7 +38,6 @@ pub struct ThinClient {
|
|||||||
rpc_addr: SocketAddr,
|
rpc_addr: SocketAddr,
|
||||||
transactions_addr: SocketAddr,
|
transactions_addr: SocketAddr,
|
||||||
transactions_socket: UdpSocket,
|
transactions_socket: UdpSocket,
|
||||||
last_id: Option<Hash>,
|
|
||||||
transaction_count: u64,
|
transaction_count: u64,
|
||||||
balances: HashMap<Pubkey, Account>,
|
balances: HashMap<Pubkey, Account>,
|
||||||
signature_status: bool,
|
signature_status: bool,
|
||||||
@ -83,7 +82,6 @@ impl ThinClient {
|
|||||||
rpc_addr,
|
rpc_addr,
|
||||||
transactions_addr,
|
transactions_addr,
|
||||||
transactions_socket,
|
transactions_socket,
|
||||||
last_id: None,
|
|
||||||
transaction_count: 0,
|
transaction_count: 0,
|
||||||
balances: HashMap::new(),
|
balances: HashMap::new(),
|
||||||
signature_status: false,
|
signature_status: false,
|
||||||
@ -248,25 +246,20 @@ impl ThinClient {
|
|||||||
/// Request the last Entry ID from the server. This method blocks
|
/// Request the last Entry ID from the server. This method blocks
|
||||||
/// until the server sends a response.
|
/// until the server sends a response.
|
||||||
pub fn get_last_id(&mut self) -> Hash {
|
pub fn get_last_id(&mut self) -> Hash {
|
||||||
trace!("get_last_id");
|
loop {
|
||||||
let mut done = false;
|
trace!("get_last_id send_to {}", &self.rpc_addr);
|
||||||
while !done {
|
|
||||||
debug!("get_last_id send_to {}", &self.rpc_addr);
|
|
||||||
let resp = self
|
let resp = self
|
||||||
.rpc_client
|
.rpc_client
|
||||||
.make_rpc_request(1, RpcRequest::GetLastId, None);
|
.make_rpc_request(1, RpcRequest::GetLastId, None);
|
||||||
|
|
||||||
if let Ok(value) = resp {
|
if let Ok(value) = resp {
|
||||||
done = true;
|
|
||||||
let last_id_str = value.as_str().unwrap();
|
let last_id_str = value.as_str().unwrap();
|
||||||
let last_id_vec = bs58::decode(last_id_str).into_vec().unwrap();
|
let last_id_vec = bs58::decode(last_id_str).into_vec().unwrap();
|
||||||
let last_id = Hash::new(&last_id_vec);
|
return Hash::new(&last_id_vec);
|
||||||
self.last_id = Some(last_id);
|
|
||||||
} else {
|
} else {
|
||||||
debug!("thin_client get_last_id error: {:?}", resp);
|
debug!("thin_client get_last_id error: {:?}", resp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.last_id.expect("some last_id")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn submit_poll_balance_metrics(elapsed: &Duration) {
|
pub fn submit_poll_balance_metrics(elapsed: &Duration) {
|
||||||
|
Reference in New Issue
Block a user