Add logic service NATS Peer x Cache + Retrieve a lost peer partner.
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user