go-libp2p icon indicating copy to clipboard operation
go-libp2p copied to clipboard

RoutedHost: Embed the underlying host instead of hiding it

Open burdiyan opened this issue 1 year ago • 5 comments

When using a libp2p host with routing, the underlying concrete type is RoutedHost. This type wraps the original Host type and hides it into a private field, which makes it hard to make interface type assertions on the host.

E.g. sometimes it's useful to have access to the underlying instance of the IDService, which is exposed by BasicHost as a method IDService() identityIDService, but is inaccessible for type assertions because RoutedHost hides the BasicHost in its private field.

This commit uses type embedding, instead of a private field, to fix it.

burdiyan avatar Sep 19 '24 07:09 burdiyan