Add Status to P2P Service interface

This commit is contained in:
aarshkshah1992
2026-01-05 14:40:08 +05:30
parent 59bb4a8301
commit 80641dc3ae
3 changed files with 10 additions and 2 deletions

View File

@@ -51,6 +51,10 @@ func (*FakeP2P) GossipDialer() gossipcrawler.GossipDialer {
return nil
}
func (*FakeP2P) Status() error {
return nil
}
// AddDisconnectionHandler -- fake.
func (*FakeP2P) AddDisconnectionHandler(_ func(ctx context.Context, id peer.ID) error) {
}

View File

@@ -111,6 +111,10 @@ func NewTestP2P(t *testing.T, userOptions ...config.Option) *TestP2P {
}
}
func (p TestP2P) Status() error {
return nil
}
// Connect two test peers together.
func (p *TestP2P) Connect(b *TestP2P) {
if err := connect(p.BHost, b.BHost); err != nil {

View File

@@ -417,11 +417,11 @@ func (s *Service) startDiscoveryAndSubscriptions() {
if s.cfg.p2p.Status() == nil {
break
}
log.Debug("p2p service not started yet; will retry in 100ms")
log.Debug("P2P service not started yet; will retry in 100ms")
select {
case <-s.ctx.Done():
log.WithError(s.ctx.Err()).Error("context closed while waiting for p2p service to start, exiting startDiscoveryAndSubscriptions routine")
log.WithError(s.ctx.Err()).Error("Context closed while waiting for P2P service to start, exiting startDiscoveryAndSubscriptions routine")
return
case <-time.After(100 * time.Millisecond):
}