Skip to content

Commit

Permalink
chore_: add func isGoingOnline
Browse files Browse the repository at this point in the history
  • Loading branch information
qfrank authored and ilmotta committed Dec 6, 2024
1 parent afbe344 commit e623029
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions wakuv2/waku.go
Original file line number Diff line number Diff line change
Expand Up @@ -1705,12 +1705,16 @@ func (w *Waku) handleNetworkChangeFromApp(state connection.State) {
}
}

func (w *Waku) isGoingOnline(state connection.State) bool {
return !state.Offline && !w.onlineChecker.IsOnline()
}

func (w *Waku) ConnectionChanged(state connection.State) {
isOnline := !state.Offline
if isOnline && !w.onlineChecker.IsOnline() { // we are online and we were offline before
if w.isGoingOnline(state) {
//TODO: analyze if we need to discover and connect to peers for relay.
w.discoverAndConnectPeers()
}
isOnline := !state.Offline
if w.cfg.LightClient {
//TODO: Update this as per https://github.com/waku-org/go-waku/issues/1114
go func() {
Expand All @@ -1720,8 +1724,7 @@ func (w *Waku) ConnectionChanged(state connection.State) {
w.handleNetworkChangeFromApp(state)
} else {
// for lightClient state update and onlineChange is handled in filterManager.
// going online
if isOnline && !w.onlineChecker.IsOnline() {
if w.isGoingOnline(state) {
select {
case w.goingOnline <- struct{}{}:
default:
Expand Down

0 comments on commit e623029

Please sign in to comment.