-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: draft changes for optimizing filter ping
- Loading branch information
1 parent
6e47bd1
commit c636567
Showing
5 changed files
with
99 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package filter | ||
|
||
import ( | ||
"context" | ||
"time" | ||
) | ||
|
||
func (wf *WakuFilterLightNode) PingPeers() { | ||
//Send a ping to all the peers and report their status to corresponding subscriptions | ||
// Alive or not or set state of subcription?? | ||
for _, peer := range wf.subscriptions.GetSubscribedPeers() { | ||
err := wf.Ping(context.TODO(), peer) | ||
if err != nil { | ||
subscriptions := wf.subscriptions.GetAllSubscriptionsForPeer(peer) | ||
for _, subscription := range subscriptions { | ||
//Indicating that subscription is closing | ||
//This feels like a hack, but taking this approach for now so as to avoid refactoring. | ||
subscription.Closing <- true | ||
} | ||
} | ||
} | ||
} | ||
|
||
func (wf *WakuFilterLightNode) FilterHealthCheckLoop() { | ||
wf.CommonService.WaitGroup().Add(1) | ||
defer wf.WaitGroup().Done() | ||
for { | ||
//TODO: Do we have to wait for wf.ctx context completion and exit as well? | ||
time.Sleep(wf.peerPingInterval) | ||
wf.PingPeers() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters