chore_: small mailserver async fetching refactor
This commit is contained in:
parent
621b31a279
commit
67364dadc8
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue