mirror of
https://github.com/logos-messaging/logos-messaging-go.git
synced 2026-01-10 01:43:08 +00:00
fix: peer lock
This commit is contained in:
parent
d8a85b5aa7
commit
bfaacfbe62
@ -307,11 +307,10 @@ func (w *WakuNode) ID() string {
|
||||
return w.host.ID().Pretty()
|
||||
}
|
||||
|
||||
func (w *WakuNode) GetPeerStats() PeerStats {
|
||||
return w.peers
|
||||
}
|
||||
|
||||
func (w *WakuNode) IsOnline() bool {
|
||||
w.peersMutex.Lock()
|
||||
defer w.peersMutex.Unlock()
|
||||
|
||||
hasRelay := false
|
||||
hasLightPush := false
|
||||
hasStore := false
|
||||
@ -340,6 +339,9 @@ func (w *WakuNode) IsOnline() bool {
|
||||
}
|
||||
|
||||
func (w *WakuNode) HasHistory() bool {
|
||||
w.peersMutex.Lock()
|
||||
defer w.peersMutex.Unlock()
|
||||
|
||||
for _, v := range w.peers {
|
||||
for _, protocol := range v {
|
||||
if protocol == string(store.WakuStoreProtocolId) {
|
||||
@ -751,6 +753,8 @@ func (w *WakuNode) ClosePeerById(id peer.ID) error {
|
||||
}
|
||||
|
||||
func (w *WakuNode) PeerCount() int {
|
||||
w.peersMutex.Lock()
|
||||
defer w.peersMutex.Unlock()
|
||||
return len(w.peers)
|
||||
}
|
||||
|
||||
@ -800,15 +804,16 @@ func (w *WakuNode) startKeepAlive(t time.Duration) {
|
||||
|
||||
go func(peer peer.ID) {
|
||||
peerFound := false
|
||||
w.peersMutex.Lock()
|
||||
for p := range w.peers {
|
||||
if p == peer {
|
||||
peerFound = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
//log.Info("###PING " + s + " before fetching result")
|
||||
//logwriter.Write([]byte("###PING " + s + " before fetching result"))
|
||||
defer w.peersMutex.Unlock()
|
||||
log.Debug("###PING before fetching result")
|
||||
|
||||
pingTicker := time.NewTicker(time.Duration(1) * time.Second)
|
||||
isError := false
|
||||
select {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user