retry transfer and poll
This commit is contained in:
parent
90ae662e4d
commit
a002148098
|
@ -141,7 +141,7 @@ impl Drone {
|
||||||
)
|
)
|
||||||
.to_owned(),
|
.to_owned(),
|
||||||
);
|
);
|
||||||
client.transfer_signed(&tx)
|
client.retry_transfer_signed(&tx, 10)
|
||||||
} else {
|
} else {
|
||||||
Err(Error::new(ErrorKind::Other, "token limit reached"))
|
Err(Error::new(ErrorKind::Other, "token limit reached"))
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,6 +114,27 @@ impl ThinClient {
|
||||||
Ok(tx.signature)
|
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<Signature> {
|
||||||
|
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.
|
/// Creates, signs, and processes a Transaction. Useful for writing unit-tests.
|
||||||
pub fn transfer(
|
pub fn transfer(
|
||||||
&self,
|
&self,
|
||||||
|
|
Loading…
Reference in New Issue