public NodeCheckingPredecessor(IDhtActions dhtActions, INetworkAdapter networkAdapter,
                                       IOptions <DhtSettings> options, ITimeOutScheduler timeOutScheduler, ISchedule scheduler)
        {
            _dhtActions       = dhtActions;
            _timeOutScheduler = timeOutScheduler;
            _scheduler        = scheduler;
            networkAdapter.CheckPredecessorHandler         += CheckPredecessorHandler;
            networkAdapter.CheckPredecessorResponseHandler += CheckPredecessorResponseHandler;
            var dhtSettings = options.Value;

            double timeOut = TimeSpan.FromSeconds(dhtSettings.TimeToLiveInSeconds).TotalMilliseconds;

            _timeOutScheduler.AddTimeOutTimer(OriginPredecessor, dhtSettings.MaxRetryAttempts, timeOut,
                                              CheckPredecessor, TimeOutCheckPredecessorHandler);

            scheduler.Enqueue(
                new Timer(TimeSpan.FromSeconds(dhtSettings.CheckPredecessorCallInSeconds).TotalMilliseconds),
                CheckPredecessor);
        }
        public NodeStabilizing(INetworkAdapter networkAdapter,
                               IOptions <DhtSettings> options, IDhtActions dhtActions, ITimeOutScheduler timeOutScheduler,
                               ISchedule scheduler)
        {
            _options          = options;
            _dhtActions       = dhtActions;
            _timeOutScheduler = timeOutScheduler;
            networkAdapter.StabilizeHandler         += StabilizeHandler;
            networkAdapter.StabilizeResponseHandler += StabilizeResponseHandler;

            var dhtSettings = _options.Value;

            double timeOut = TimeSpan.FromSeconds(dhtSettings.TimeToLiveInSeconds).TotalMilliseconds;

            _timeOutScheduler.AddTimeOutTimer(OriginSuccessor, dhtSettings.MaxRetryAttempts + 1, timeOut, Stabilize,
                                              OnTimeOutStabilizeHandler);

            scheduler.Enqueue(new Timer(TimeSpan.FromSeconds(dhtSettings.StabilizeCallInSeconds).TotalMilliseconds),
                              Stabilize);
        }