-
Notifications
You must be signed in to change notification settings - Fork 126
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
Provide an async example #551
Conversation
limitations under the License. | ||
*/ | ||
|
||
//! Very simple example that shows how to fetch chain metadata with async. |
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.
metadata?
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.
In get_block.rs, the example description is also about metadata. ;)
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.
Yeah I took this from the other example. It might be confusing because metadata has a special meaning in the polkadot eco-system. How about just using chain information
in both examples?
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.
Works for me 👍
@@ -27,6 +28,7 @@ use substrate_api_client::{ | |||
#[tokio::main] | |||
async fn main() { |
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.
What do you think: Do we still need the sync variant of get_blocks? We have different sync examples and the difference between sync and async is not that big.
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.
Initially I thought it would be nice to show that the async version is faster. Unfortunately that's not really the case. The sync has the small advantage of outputting something directly after each getter, so if something fails later on there is at least the output of the previous stuff.
ad6195a
to
6e4f912
Compare
cfd5757
to
aae0005
Compare
|
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.
Absolutely awesome, thanks a lot! One last wish: Could you update the PR description? 😇
Done |
get_blocks
example such that it takes advantage of async by awaiting multiple futures at the same time.get_blocks_async