Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

[PIE-1632] newHeads subscription emits events only for canonical blocks #1798

Merged
merged 2 commits into from
Jul 30, 2019

Conversation

lucassaldanha
Copy link
Contributor

#PR description

  • Updated NewBlockHeadersSubscriptionService#onBlockAdded logic to check if the block is in the canonical chain before sending a notification
  • Added unit test to cover scenario
  • Refactored some of the other unit tests to improve readability

Copy link
Contributor

@mark-terry mark-terry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

NewBlockHeadersSubscription.class,
subscribers -> {
final Hash newBlockHash = event.getBlock().getHash();
if (event.isNewCanonicalHead()) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick ... if (!event.isNewCanonicalHead()) { return; }

would cause less code change :)

@lucassaldanha lucassaldanha merged commit fc6afda into PegaSysEng:master Jul 30, 2019
@lucassaldanha lucassaldanha deleted the PIE-1632 branch July 30, 2019 23:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants