Closure On change of state

This commit is contained in:
mr
2026-02-05 16:17:14 +01:00
parent 2e31df89c2
commit ea14ad3933
3 changed files with 48 additions and 9 deletions

View File

@@ -41,7 +41,7 @@ type StreamService struct {
Node common.DiscoveryPeer
Streams common.ProtocolStream
maxNodesConn int
mu sync.Mutex
Mu sync.Mutex
// Stream map[protocol.ID]map[pp.ID]*daemons.Stream
}
@@ -67,8 +67,8 @@ func (s *StreamService) HandlePartnerHeartbeat(stream network.Stream) {
if err != nil {
return
}
s.mu.Lock()
defer s.mu.Unlock()
s.Mu.Lock()
defer s.Mu.Unlock()
if s.Streams[ProtocolHeartbeatPartner] == nil {
s.Streams[ProtocolHeartbeatPartner] = map[pp.ID]*common.Stream{}
@@ -197,8 +197,8 @@ func (s *StreamService) StartGC(interval time.Duration) {
}
func (s *StreamService) gc() {
s.mu.Lock()
defer s.mu.Unlock()
s.Mu.Lock()
defer s.Mu.Unlock()
now := time.Now().UTC()
if s.Streams[ProtocolHeartbeatPartner] == nil {