-
Notifications
You must be signed in to change notification settings - Fork 254
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
added at_latest #900
added at_latest #900
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,15 +39,31 @@ where | |
T: Config, | ||
Client: OnlineClientT<T>, | ||
{ | ||
/// Obtain block details given the provided block hash, or the latest block if `None` is | ||
/// provided. | ||
/// Obtain block details given the provided block hash. | ||
/// | ||
/// # Warning | ||
/// | ||
/// This call only supports blocks produced since the most recent | ||
/// runtime upgrade. You can attempt to retrieve older blocks, | ||
/// but may run into errors attempting to work with them. | ||
pub fn at( | ||
&self, | ||
block_hash: T::Hash, | ||
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static { | ||
self.at_optional_block_hash(Some(block_hash)) | ||
} | ||
|
||
/// Obtain block details of the latest block hash. | ||
pub fn at_latest( | ||
&self, | ||
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static { | ||
self.at_optional_block_hash(None) | ||
} | ||
|
||
/// Obtain block details given the provided block hash, or the latest block if `None` is | ||
/// provided. | ||
#[inline] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would like some consistency here w.r.t. to @lexnv what do you prefer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @niklasad1 I wanted to keep consistency to how it was before. Before, the pub method was also not inlined. Now the inline will just generate two pub functions There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, makes sense but let's hear what @lexnv thinks :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't have the But more to the point, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see; it would have to be async anyway! In that case let';s just remove the |
||
fn at_optional_block_hash( | ||
&self, | ||
block_hash: Option<T::Hash>, | ||
) -> impl Future<Output = Result<Block<T, Client>, Error>> + Send + 'static { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,32 @@ where | |
/// runtime upgrade. You can attempt to retrieve events from older blocks, | ||
/// but may run into errors attempting to work with them. | ||
pub fn at( | ||
&self, | ||
block_hash: T::Hash, | ||
) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static { | ||
self.at_optional_block_hash(Some(block_hash)) | ||
} | ||
|
||
/// Obtain events at the latest block hash. | ||
/// | ||
/// # Warning | ||
/// | ||
/// This call only supports blocks produced since the most recent | ||
/// runtime upgrade. You can attempt to retrieve events from older blocks, | ||
/// but may run into errors attempting to work with them. | ||
pub fn at_latest(&self) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static { | ||
self.at_optional_block_hash(None) | ||
} | ||
|
||
/// Obtain events at some block hash. | ||
/// | ||
/// # Warning | ||
/// | ||
/// This call only supports blocks produced since the most recent | ||
/// runtime upgrade. You can attempt to retrieve events from older blocks, | ||
/// but may run into errors attempting to work with them. | ||
#[inline] | ||
fn at_optional_block_hash( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As above, let's put this code directly into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah I see; both have to be In this case, let's just remove the |
||
&self, | ||
block_hash: Option<T::Hash>, | ||
) -> impl Future<Output = Result<Events<T>, Error>> + Send + 'static { | ||
|
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.
We could also change the documentation of this function to state
/// Obtain block details given the block hash.