chore_: small mailserver async fetching refactor

This commit is contained in:
Vitaly Vlasov 2024-06-25 12:22:42 +03:00 committed by Vit∀ly Vlasov
parent 621b31a279
commit 67364dadc8
3 changed files with 6 additions and 22 deletions

View File

@ -1568,13 +1568,9 @@ func (m *Messenger) watchConnectionChange() {
return
}
subscription, err := waku.SubscribeToConnStatusChanges()
if err != nil {
// Log error and fallback to polling
m.logger.Error("failed to subscribe to connection status changes", zap.Error(err))
go pollConnectionStatus()
return
}
// Wakuv2 is not going to return an error
// from SubscribeToConnStatusChanges
subscription, _ := waku.SubscribeToConnStatusChanges()
go subscribedConnectionStatus(subscription)
}

View File

@ -434,14 +434,7 @@ func (m *Messenger) connectToMailserver(ms mailservers.Mailserver) error {
// Query mailserver
if m.config.codeControlFlags.AutoRequestHistoricMessages {
go func() {
_, err := m.performMailserverRequest(&ms, func(_ mailservers.Mailserver) (*MessengerResponse, error) {
return m.RequestAllHistoricMessages(false, false)
})
if err != nil {
m.logger.Error("could not perform mailserver request", zap.Error(err))
}
}()
m.asyncRequestAllHistoricMessages()
}
}
}
@ -587,12 +580,7 @@ func (m *Messenger) handleMailserverCycleEvent(connectedPeers []ConnectedPeer) e
}
// Query mailserver
if m.config.codeControlFlags.AutoRequestHistoricMessages {
go func() {
_, err := m.RequestAllHistoricMessages(false, true)
if err != nil {
m.logger.Error("failed to request historic messages", zap.Error(err))
}
}()
m.asyncRequestAllHistoricMessages()
}
} else {
m.mailPeersMutex.Unlock()

View File

@ -70,7 +70,7 @@ func (n *testNode) GetWaku(_ interface{}) (types.Waku, error) {
}
func (n *testNode) GetWakuV2(_ interface{}) (types.Waku, error) {
return n.shh, nil
return nil, errors.New("No waku v2 support")
}
func (n *testNode) GetWhisper(_ interface{}) (types.Whisper, error) {