diff --git a/src/drone.rs b/src/drone.rs index d23baea6c1..55da973f7c 100644 --- a/src/drone.rs +++ b/src/drone.rs @@ -141,7 +141,7 @@ impl Drone { ) .to_owned(), ); - client.transfer_signed(&tx) + client.retry_transfer_signed(&tx, 10) } else { Err(Error::new(ErrorKind::Other, "token limit reached")) } diff --git a/src/thin_client.rs b/src/thin_client.rs index 1e5758c7aa..8ec6178be7 100644 --- a/src/thin_client.rs +++ b/src/thin_client.rs @@ -114,6 +114,27 @@ impl ThinClient { Ok(tx.signature) } + /// Retry a sending a signed Transaction to the server for processing. + pub fn retry_transfer_signed( + &mut self, + tx: &Transaction, + tries: usize, + ) -> io::Result { + let data = serialize(&tx).expect("serialize Transaction in pub fn transfer_signed"); + for x in 0..tries { + self.transactions_socket + .send_to(&data, &self.transactions_addr)?; + if self.poll_for_signature(&tx.signature).is_ok() { + return Ok(tx.signature); + } + info!("{} tries failed transfer to {}", x, self.transactions_addr); + } + Err(io::Error::new( + io::ErrorKind::Other, + "retry_transfer_signed failed", + )) + } + /// Creates, signs, and processes a Transaction. Useful for writing unit-tests. pub fn transfer( &self,