diff --git a/src/serial_code/hail.rs b/src/serial_code/hail.rs index 6fcbb34..d349f78 100644 --- a/src/serial_code/hail.rs +++ b/src/serial_code/hail.rs @@ -69,13 +69,6 @@ impl HailSerialCodeAlgorithm { current_time - *HAIL_PERIOD_START } - /// 判断指定时间戳是否比已经存储的最后一次使用的时间戳要大。否则时间发生了回拨。 - fn validate_timestamp(&self, timestamp: i64) -> bool { - let last_timestamp = self.last_timestamp.clone(); - let last_timestamp = last_timestamp.lock().unwrap(); - timestamp >= *last_timestamp - } - /// 生成一个64位长整型序列ID。 pub fn generate_serial(&self) -> i64 { let last_timestamp = self.last_timestamp.clone(); @@ -93,7 +86,7 @@ impl HailSerialCodeAlgorithm { std::thread::sleep(time::Duration::from_secs(1)); continue; } - } else if !self.validate_timestamp(timestamp) { + } else if timestamp < *last_timestamp { std::thread::sleep(time::Duration::from_secs(1)); continue; }