pnet: add warning when we are in PNet and have no peers

License: MIT
Signed-off-by: Jakub Sztandera <kubuxu@protonmail.ch>
This commit is contained in:
Jakub Sztandera 2017-02-17 13:58:30 +01:00
parent faca4518b3
commit 4ce6358bd7
No known key found for this signature in database
GPG Key ID: 9A9AF56F8B3879BA

View File

@ -190,6 +190,24 @@ func (n *IpfsNode) startOnlineServices(ctx context.Context, routingOption Routin
return err
}
n.PNetFingerpint = protec.Fingerprint()
go func() {
t := time.NewTicker(30 * time.Second)
<-t.C // swallow one tick
for {
select {
case <-t.C:
if ph := n.PeerHost; ph != nil {
if len(ph.Network().Peers()) == 0 {
log.Warning("We are in private network and have no peers.")
log.Warning("This might be configuration mistake.")
}
}
case <-n.Process().Closing():
t.Stop()
return
}
}
}()
}
peerhost, err := hostOption(ctx, n.Identity, n.Peerstore, n.Reporter,