Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Expose NewBlockEvent on the event bus #822

Merged
merged 2 commits into from
Jul 23, 2019

Conversation

cburgdorf
Copy link
Contributor

What was wrong?

This is a little spin off from #721 that splits peer pool and sync into two separate processes. This exposes a NewBlockEvent on the event bus which is an important event for components to utilize (e.g. to build sync strategies on)

How was it fixed?

  • Created NewBlockEvent
  • Dispatch the NewBlockEvent whenever the native NewBlock command pops up

To-Do

  • Clean up commit history

Cute Animal Picture

put a cute animal picture link inside the parentheses

@cburgdorf cburgdorf force-pushed the christoph/feat/new-block-event branch from d41d195 to 5ff3a80 Compare July 23, 2019 13:50
@@ -16,6 +16,7 @@ develop-eggs
.installed.cfg
lib
lib64
pip-wheel-metadata
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This seems to be an issue with recent pip versions pypa/pip#6213

@cburgdorf cburgdorf changed the title Christoph/feat/new block event Expose NewBlockEvent on the event bus Jul 23, 2019
@cburgdorf cburgdorf force-pushed the christoph/feat/new-block-event branch from 5ff3a80 to 5c3bc19 Compare July 23, 2019 13:56
@cburgdorf cburgdorf requested a review from pipermerriam July 23, 2019 14:03
Copy link
Member

@pipermerriam pipermerriam left a comment

Choose a reason for hiding this comment

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

I must be missing something. Why does NewBlockEvent not have the block and total_difficulty fields mirrored (same question for NewBlockHashesEvent.)

@cburgdorf
Copy link
Contributor Author

Because all of these derive from PeerPoolMessageEvent and leave it up to the consumer to unpack things.

@dataclass
class PeerPoolMessageEvent(BaseEvent):
"""
Base event for all peer messages that are relayed on the event bus. The events are mapped
to individual subclasses for every different ``cmd`` to allow efficient consumption through
the event bus.
"""
remote: Node
cmd: Command
msg: PayloadType

In the long run, I guess we'll get rid of this mapping anyway and have the peer pool be built natively on Lahja. In the meantime, this is just to keep things simple and don't map properties on lots of places.

@cburgdorf cburgdorf merged commit ec613cc into ethereum:master Jul 23, 2019
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.

2 participants