Skip to content

Commit

Permalink
Clarify firing of import_notification_stream in doc comment (#5811)
Browse files Browse the repository at this point in the history
# Description

Updates the doc comment on the `import_notification_stream` to make its
behaviour clearer.

Closes [Unexpected behaviour of block
`import_notification_stream`](#5596).

## Integration

Doesn't apply.

## Review Notes

The old comment docs caused some confusion to myself and some members of
my team, on when this notification stream is triggered. This is
reflected in the linked
[issue](#5596), and as
discussed there, this PR aims to prevent this confusion in future devs
looking to make use of this functionality.

# Checklist

* [x] My PR includes a detailed description as outlined in the
"Description" and its two subsections above.
* [ ] My PR follows the [labeling requirements](

https://github.com/paritytech/polkadot-sdk/blob/master/docs/contributor/CONTRIBUTING.md#Process
) of this project (at minimum one label for `T` required)
* External contributors: ask maintainers to put the right label on your
PR.
* [x] I have made corresponding changes to the documentation (if
applicable)
* [x] I have added tests that prove my fix is effective or that my
feature works (if applicable)

You can remove the "Checklist" section once all have been checked. Thank
you for your contribution!

---------

Co-authored-by: Michal Kucharczyk <[email protected]>
Co-authored-by: Bastian Köcher <[email protected]>
  • Loading branch information
3 people authored Sep 28, 2024
1 parent a5e40d0 commit 8dfff11
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
13 changes: 13 additions & 0 deletions prdoc/pr_5811.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://raw.githubusercontent.com/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "Improve `import_notification_stream` documentation"

doc:
- audience: Node Dev
description: |
"Updates the doc comment on the `import_notification_stream` to make its behaviour clearer. Now it specifically states that this notification stream is fired on every import notification after the initial sync, and only when there are re-orgs in the initial sync."

crates:
- name: sc-client-api
bump: patch
13 changes: 10 additions & 3 deletions substrate/client/api/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,16 @@ pub trait BlockOf {
pub trait BlockchainEvents<Block: BlockT> {
/// Get block import event stream.
///
/// Not guaranteed to be fired for every imported block, only fired when the node
/// has synced to the tip or there is a re-org. Use `every_import_notification_stream()`
/// if you want a notification of every imported block regardless.
/// Not guaranteed to be fired for every imported block. Use
/// `every_import_notification_stream()` if you want a notification of every imported block
/// regardless.
///
/// The events for this notification stream are emitted:
/// - During initial sync process: if there is a re-org while importing blocks. See
/// [here](https://github.com/paritytech/substrate/pull/7118#issuecomment-694091901) for the
/// rationale behind this.
/// - After initial sync process: on every imported block, regardless of whether it is
/// the new best block or not, causes a re-org or not.
fn import_notification_stream(&self) -> ImportNotifications<Block>;

/// Get a stream of every imported block.
Expand Down

0 comments on commit 8dfff11

Please sign in to comment.