start method

Future<void> start()

Starts the PeerstoreManager.

Implementation

Future<void> start() async {
  if (_closed) {
    throw StateError('PeerstoreManager is closed');
  }

  try {
    final sub = await _eventBus.subscribe(EvtPeerConnectednessChanged);
    _subscription = sub.stream.listen(_handleConnectChangeEvent);
    _timer = Timer.periodic(_cleanupInterval ?? Duration(minutes: 5), _cleanup);
  } catch (e) {
    _log.warning('Subscription failed. Peerstore manager not activated. Error: $e');
  }
}