Skip to content
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

Closed
wants to merge 4 commits into from
Closed

Conversation

rlkelly
Copy link
Contributor

@rlkelly rlkelly commented Apr 24, 2018

No description provided.

Copy link
Contributor

@garious garious left a 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 {
Copy link
Contributor

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> {
Copy link
Contributor

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");
Copy link
Contributor

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, ()> {
Copy link
Contributor

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 ()?

@rlkelly
Copy link
Contributor Author

rlkelly commented Apr 25, 2018

sure thing, i'll knock this out in a few hours

@garious
Copy link
Contributor

garious commented Apr 26, 2018

See #150

@garious garious closed this Apr 26, 2018
vkomenda pushed a commit to vkomenda/solana that referenced this pull request Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants