-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
141 add futures #148
141 add futures #148
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely what I had in mind - thanks for taking this on! This is an important step in moving to an async client. Just a few nits (comments inline). Also, can you run rustfmt
on this code? The CI job will fail otherwise.
@@ -81,6 +81,12 @@ impl Accountant { | |||
true | |||
} | |||
|
|||
// fn forget_signature_with_last_id(&self, last_id: &Hash) -> bool { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't need this. Even if not commented out, it's not right. It should remove last_id
, not the last item.
@@ -51,35 +52,38 @@ impl AccountantStub { | |||
/// Request the balance of the user holding `pubkey`. This method blocks | |||
/// until the server sends a response. If the response packet is dropped | |||
/// by the network, this method will hang indefinitely. | |||
pub fn get_balance(&self, pubkey: &PublicKey) -> io::Result<Option<i64>> { | |||
pub fn get_balance(&self, pubkey: &PublicKey) -> FutureResult<i64, i64> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about something likeFutureResult<Option<i64>, io::Error>
? Or perhaps the library offers a futures::io::FutureResult<Option<i64>>
?
let req = Request::GetBalance { key: *pubkey }; | ||
let data = serialize(&req).expect("serialize GetBalance"); | ||
self.socket.send_to(&data, &self.addr)?; | ||
self.socket.send_to(&data, &self.addr).expect("buffer error"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't panic on this one. It's too likely to happen.
} | ||
|
||
/// Request the last Entry ID from the server. This method blocks | ||
/// until the server sends a response. At the time of this writing, | ||
/// it also has the side-effect of causing the server to log any | ||
/// entries that have been published by the Historian. | ||
pub fn get_last_id(&self) -> io::Result<Hash> { | ||
pub fn get_last_id(&self) -> FutureResult<Hash, ()> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again, io::Errror
instead of ()
?
sure thing, i'll knock this out in a few hours |
See #150 |
No description provided.