Add logic service NATS Peer x Cache + Retrieve a lost peer partner.

This commit is contained in:
mr
2026-02-02 12:43:43 +01:00
parent 0ffe98045e
commit 6ca762abbf
3 changed files with 37 additions and 10 deletions

View File

@@ -79,7 +79,7 @@ func (s *StreamService) HandlePartnerHeartbeat(stream network.Stream) {
pid := stream.Conn().RemotePeer()
ai, err := pp.AddrInfoFromP2pAddr(stream.Conn().RemoteMultiaddr())
if err == nil {
s.connectToPartner(pid, ai)
s.ConnectToPartner(pid, ai)
}
}
go s.StartGC(30 * time.Second)
@@ -99,14 +99,14 @@ func (s *StreamService) connectToPartners() error {
if err != nil {
continue
}
s.connectToPartner(pid, ad)
s.ConnectToPartner(pid, ad)
// heartbeat your partner.
}
// TODO if handle... from partner then HeartBeat back
return nil
}
func (s *StreamService) connectToPartner(pid pp.ID, ad *pp.AddrInfo) {
func (s *StreamService) ConnectToPartner(pid pp.ID, ad *pp.AddrInfo) {
for _, proto := range protocols {
f := func(ss network.Stream) {
if s.Streams[proto] == nil {