Skip to content

refactor(peer-store): single behavior Event#6011

Merged
mergify[bot] merged 9 commits intolibp2p:masterfrom
elenaf9:refactor/peer-store-event
Apr 30, 2025
Merged

refactor(peer-store): single behavior Event#6011
mergify[bot] merged 9 commits intolibp2p:masterfrom
elenaf9:refactor/peer-store-event

Conversation

@elenaf9
Copy link
Member

@elenaf9 elenaf9 commented Apr 28, 2025

Description

Refactor the events emitted by the peer_store::Behavior:

  1. Merge the current 3 event types (behavior::Event, store::Event, memory_store::Event) into a single type that is emitted by the Store implementation.
  2. Use more descriptive event variants AddressAdded, AddressRemoved that also expose the specific Multiaddr.
  3. Remove Event::CustomDataUpdate variant.

Discussed in #5926 (comment) and #5926 (comment).

Notes & open questions

I've removed the Event::CustomDataUpdate because I don't think it makes sense to emit an event for a synchronous, user-triggered operation. It doesn't give any information that the user doesn't already know.
For the user-triggered adding and removal of addresses, however, I am still emitting events so that it is consistent with the swarm-triggered change of addresses. @dknopik @drHuangMHT do you agree with this?

Change checklist

  • I have performed a self-review of my own code
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • A changelog entry has been made in the appropriate crates

@dknopik
Copy link
Collaborator

dknopik commented Apr 29, 2025

I feel like these changes make sense. 👍

@drHuangMHT
Copy link
Contributor

LGTM! This significantly improves ergonomics!

Copy link
Member

@jxs jxs left a comment

Choose a reason for hiding this comment

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

Thanks for this Elena! And Daniel and DrHuang for the review!

@jxs jxs added the send-it label Apr 30, 2025
@mergify mergify bot merged commit 2dc453b into libp2p:master Apr 30, 2025
71 checks passed
@elenaf9 elenaf9 deleted the refactor/peer-store-event branch April 30, 2025 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants