Implement get_last_id() with transaction_count()

This is more precice than the previous implementation because it'll
drain the EntryInfo queue and return the most recent last_id instead
of the first one.
This commit is contained in:
Greg Fitzgerald 2018-05-03 13:34:54 -06:00
parent f752e02487
commit 1feff408ff
1 changed files with 1 additions and 8 deletions

View File

@ -108,14 +108,7 @@ impl AccountantStub {
/// Request the last Entry ID from the server. This method blocks
/// until the server sends a response.
pub fn get_last_id(&mut self) -> FutureResult<Hash, ()> {
let mut done = false;
while !done {
let resp = self.recv_response().expect("recv response");
if let &Response::EntryInfo { .. } = &resp {
done = true;
}
self.process_response(resp);
}
self.transaction_count();
ok(self.last_id.unwrap_or(Hash::default()))
}