feat_: wakuext_enr (#5367)

This commit is contained in:
richΛrd 2024-06-18 15:48:49 -04:00 committed by GitHub
parent b0d103d494
commit a300e12853
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 33 additions and 0 deletions

View File

@ -109,6 +109,11 @@ func (w *GethWakuWrapper) ListenAddresses() ([]string, error) {
return nil, errors.New("not available in WakuV1")
}
// ENR function only added for compatibility with waku V2
func (w *GethWakuWrapper) ENR() (string, error) {
return "", errors.New("not available in WakuV1")
}
// PeerCount function only added for compatibility with waku V2
func (w *GethWakuWrapper) DropPeer(peerID string) error {
return errors.New("not available in WakuV1")

View File

@ -283,6 +283,11 @@ func (w *gethWakuV2Wrapper) ListenAddresses() ([]string, error) {
return w.waku.ListenAddresses(), nil
}
// ENR function only added for compatibility with waku V2
func (w *gethWakuV2Wrapper) ENR() (string, error) {
return w.waku.ENR()
}
func (w *gethWakuV2Wrapper) DropPeer(peerID string) error {
return w.waku.DropPeer(peerID)
}

View File

@ -92,6 +92,8 @@ type Waku interface {
ListenAddresses() ([]string, error)
ENR() (string, error)
Peers() map[string]WakuV2Peer
StartDiscV5() error

View File

@ -36,6 +36,10 @@ func (m *Messenger) ListenAddresses() ([]string, error) {
return m.transport.ListenAddresses()
}
func (m *Messenger) ENR() (string, error) {
return m.transport.ENR()
}
// Subscribe to a pubsub topic, passing an optional public key if the pubsub topic is protected
func (m *Messenger) SubscribeToPubsubTopic(topic string, optPublicKey *ecdsa.PublicKey) error {
return m.transport.SubscribeToPubsubTopic(topic, optPublicKey)

View File

@ -651,6 +651,10 @@ func (t *Transport) ListenAddresses() ([]string, error) {
return t.waku.ListenAddresses()
}
func (t *Transport) ENR() (string, error) {
return t.waku.ENR()
}
func (t *Transport) AddStorePeer(address string) (peer.ID, error) {
return t.waku.AddStorePeer(address)
}

View File

@ -1484,6 +1484,10 @@ func (api *PublicAPI) ListenAddresses() ([]string, error) {
return api.service.messenger.ListenAddresses()
}
func (api *PublicAPI) Enr() (string, error) {
return api.service.messenger.ENR()
}
func (api *PublicAPI) ChangeIdentityImageShowTo(showTo settings.ProfilePicturesShowToType) error {
err := api.service.accountsDB.SaveSettingField(settings.ProfilePicturesShowTo, showTo)
if err != nil {

View File

@ -1692,6 +1692,15 @@ func (w *Waku) ListenAddresses() []string {
return result
}
func (w *Waku) ENR() (string, error) {
enr := w.node.ENR()
if enr == nil {
return "", errors.New("enr not available")
}
return enr.String(), nil
}
func (w *Waku) SubscribeToPubsubTopic(topic string, pubkey *ecdsa.PublicKey) error {
topic = w.GetPubsubTopic(topic)