Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/mock: mimic Swarm's event and notification behavior in MockNet #2287

Merged
merged 2 commits into from
May 16, 2023

Conversation

Wondertan
Copy link
Contributor

Fixes #2267 + synchronously notifies as Swarm after #1562

Comment on lines +226 to +227
// notify asynchronously to mimic Swarm
// FIXME: IIRC, we wanted to make notify for Close synchronous
Copy link
Contributor Author

Choose a reason for hiding this comment

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

and yes, this means that ideally, we'd also get rid of the Go routine for the Disconnected notification.

#2027 (comment)

Comment on lines -95 to -102
go func() {
c.notifLk.Lock()
defer c.notifLk.Unlock()
c.net.notifyAll(func(n network.Notifiee) {
n.Disconnected(c.net, c)
})
}()
return nil
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Moved for nicer logic grouping.

Comment on lines 121 to 124
EventBus: bus,
}

h, err := bhost.NewHost(n, opts)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Any reason not to use lightweight blankhost here isntead?
Doesn't seem like basichost gives anything here

Copy link
Collaborator

Choose a reason for hiding this comment

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

Generally I'd prefer this to behave as similar to a normal node as possible. So I'd lean towards keeping this as the basic host. Is there something in basichost that's too heavy for you? I wonder if it would make more sense to make that lighter instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nothing specific, just wonderting. BasicHost also works

@marten-seemann marten-seemann changed the title net/mock: mimic Swarm's event and notificaion behavior in MockNet net/mock: mimic Swarm's event and notification behavior in MockNet May 15, 2023
@MarcoPolo MarcoPolo self-requested a review May 15, 2023 17:36
@MarcoPolo
Copy link
Collaborator

Thank you @Wondertan 🙏

@MarcoPolo MarcoPolo merged commit 8719fc4 into libp2p:master May 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Connectedness events are not submitted by mocknet
2 participants