Repository: tikv/tikv
File: components/raftstore-v2/src/batch/store.rs (Rust)

Code before:
    pub coprocessor_host: CoprocessorHost<EK>,
    /// The transport for sending messages to peers on other stores.
    pub trans: T,
    pub has_ready: bool,
    pub raft_metrics: RaftMetrics,
    /// The latest configuration.
    pub cfg: Config,
    pub router: StoreRouter<EK, ER>,
    /// The tick batch for delay ticking. It will be flushed at the end of every
    /// round.
    pub tick_batch: Vec<PeerTickBatch>,
    /// The precise timer for scheduling tick.
    pub timer: SteadyTimer,
    pub schedulers: Schedulers<EK, ER>,
    pub store_meta: Arc<Mutex<StoreMeta<EK>>>,
    pub shutdown: Arc<AtomicBool>,
    pub engine: ER,
    pub tablet_registry: TabletRegistry<EK>,
    pub apply_pool: FuturePool,
    /// A background pool used for high-priority works.
    pub high_priority_pool: FuturePool,

    // current_time and node_start_time relate to leader lease,
    // must use monotonic_raw_now.
    pub current_time: Option<Timespec>,
    pub node_start_time: Option<Timespec>,

    /// Disk usage for the store itself.
    pub self_disk_usage: DiskUsage,

    pub snap_mgr: TabletSnapManager,
    pub global_stat: GlobalStoreStat,
    pub store_stat: LocalStoreStat,
    pub sst_importer: Arc<SstImporter>,
    pub key_manager: Option<Arc<DataKeyManager>>,

    /// Inspector for latency inspecting
    pub pending_latency_inspect: Vec<LatencyInspector>,
}

impl<EK: KvEngine, ER: RaftEngine, T> StoreContext<EK, ER, T> {
    pub fn update_ticks_timeout(&mut self) {
        self.tick_batch[PeerTick::Raft as usize].wait_duration = self.cfg.raft_base_tick_interval.0;
        self.tick_batch[PeerTick::CompactLog as usize].wait_duration =
            self.cfg.raft_log_gc_tick_interval.0;
        self.tick_batch[PeerTick::EntryCacheEvict as usize].wait_duration =
            ENTRY_CACHE_EVICT_TICK_DURATION;
        self.tick_batch[PeerTick::PdHeartbeat as usize].wait_duration =
            self.cfg.pd_heartbeat_tick_interval.0;
        self.tick_batch[PeerTick::SplitRegionCheck as usize].wait_duration =
            self.cfg.split_region_check_tick_interval.0;

Review comment (suggestion):
how about using `unsafe_vote_deadline` and calculate it by start time at start. A optional start time is confusing.

Code after:
    pub coprocessor_host: CoprocessorHost<EK>,
    /// The transport for sending messages to peers on other stores.
    pub trans: T,
    pub has_ready: bool,
    pub raft_metrics: RaftMetrics,
    /// The latest configuration.
    pub cfg: Config,
    pub router: StoreRouter<EK, ER>,
    /// The tick batch for delay ticking. It will be flushed at the end of every
    /// round.
    pub tick_batch: Vec<PeerTickBatch>,
    /// The precise timer for scheduling tick.
    pub timer: SteadyTimer,
    pub schedulers: Schedulers<EK, ER>,
    pub store_meta: Arc<Mutex<StoreMeta<EK>>>,
    pub shutdown: Arc<AtomicBool>,
    pub engine: ER,
    pub tablet_registry: TabletRegistry<EK>,
    pub apply_pool: FuturePool,
    /// A background pool used for high-priority works.
    pub high_priority_pool: FuturePool,

    /// current_time from monotonic_raw_now.
    pub current_time: Option<Timespec>,
    /// unsafe_vote_deadline from monotonic_raw_now.
    pub unsafe_vote_deadline: Option<Timespec>,

    /// Disk usage for the store itself.
    pub self_disk_usage: DiskUsage,

    pub snap_mgr: TabletSnapManager,
    pub global_stat: GlobalStoreStat,
    pub store_stat: LocalStoreStat,
    pub sst_importer: Arc<SstImporter>,
    pub key_manager: Option<Arc<DataKeyManager>>,

    /// Inspector for latency inspecting
    pub pending_latency_inspect: Vec<LatencyInspector>,
}

impl<EK: KvEngine, ER: RaftEngine, T> StoreContext<EK, ER, T> {
    pub fn update_ticks_timeout(&mut self) {
        self.tick_batch[PeerTick::Raft as usize].wait_duration = self.cfg.raft_base_tick_interval.0;
        self.tick_batch[PeerTick::CompactLog as usize].wait_duration =
            self.cfg.raft_log_gc_tick_interval.0;
        self.tick_batch[PeerTick::EntryCacheEvict as usize].wait_duration =
            ENTRY_CACHE_EVICT_TICK_DURATION;
        self.tick_batch[PeerTick::PdHeartbeat as usize].wait_duration =
            self.cfg.pd_heartbeat_tick_interval.0;
        self.tick_batch[PeerTick::SplitRegionCheck as usize].wait_duration =
            self.cfg.split_region_check_tick_interval.0;