Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Scaffolding for event handling in future protocols #7

Merged
merged 1 commit into from
Jul 4, 2023

Conversation

johncantrell97
Copy link
Contributor

@johncantrell97 johncantrell97 commented Jun 15, 2023

Adds the concept of events to the library. Future protocols should:

  • add Event enum variants
  • give protocol message handler a reference to the pending_events EventQueue.
  • push any relevant events as they are generated inside their protocol

End user is currently expected to poll for events using either:

  • get_and_clear_pending_events in order to retrieve all currently queued events without blocking (returns empty vec if nothing present)

or

  • get_next_event blocks until next event is ready and returns it

Perhaps we want an async version that returns a Future as well?

@johncantrell97 johncantrell97 force-pushed the events branch 2 times, most recently from 208d1e2 to 6a2c4aa Compare June 19, 2023 17:19
Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

I also wonder if we need to persist this event queue? What happens when the node is shutdown and the users hasn't handled all events. Is the state of all protocols really so stateless that everything will start over? If not and we don't persist it, we need to make sure in each LSPS that every necessary event is re-generated on startup.

Copy link
Collaborator

@tnull tnull left a comment

Choose a reason for hiding this comment

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

LGTM.

@tnull tnull merged commit 58fbce0 into lightningdevkit:main Jul 4, 2023
This was referenced Jul 4, 2023
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