-
Notifications
You must be signed in to change notification settings - Fork 77
Description
Describe the feature
#679 introduced redundant code block in ValidatorService and LeanChainService.
ream/crates/common/chain/lean/src/service.rs
Lines 51 to 75 in b699064
| // TODO: Duplicate clock logic from ValidatorService. May need to refactor later. | |
| // Get the Lean network specification. | |
| let network_spec = lean_network_spec(); | |
| let seconds_per_slot = network_spec.seconds_per_slot; | |
| let genesis_time = network_spec.genesis_time; | |
| info!("LeanChainService started with genesis_time={genesis_time}"); | |
| // Calculate the genesis instant from the genesis time (in seconds). | |
| let genesis_instant = UNIX_EPOCH + Duration::from_secs(genesis_time); | |
| // Assume genesis time is "always" in the future, | |
| // as we don't support syncing features yet. | |
| let interval_start = Instant::now() | |
| + genesis_instant | |
| .duration_since(SystemTime::now()) | |
| .expect("Genesis time is in the past"); | |
| let mut tick_count = 0u64; | |
| let mut interval = interval_at( | |
| interval_start, | |
| Duration::from_secs(seconds_per_slot / INTERVALS_PER_SLOT), | |
| ); | |
| interval.set_missed_tick_behavior(MissedTickBehavior::Burst); |
ream/crates/common/validator/lean/src/service.rs
Lines 64 to 91 in b699064
| // TODO: Duplicate clock logic from LeanChainService. May need to refactor later. | |
| // Get the Lean network specification. | |
| let network_spec = lean_network_spec(); | |
| let seconds_per_slot = network_spec.seconds_per_slot; | |
| let genesis_time = network_spec.genesis_time; | |
| info!( | |
| "ValidatorService started with {} validator(s), genesis_time={genesis_time}", | |
| self.keystores.len() | |
| ); | |
| // Calculate the genesis instant from the genesis time (in seconds). | |
| let genesis_instant = UNIX_EPOCH + Duration::from_secs(genesis_time); | |
| // Assume genesis time is "always" in the future, | |
| // as we don't support syncing features yet. | |
| let interval_start = Instant::now() | |
| + genesis_instant | |
| .duration_since(SystemTime::now()) | |
| .expect("Genesis time is in the past"); | |
| let mut tick_count = 0u64; | |
| let mut interval = interval_at( | |
| interval_start, | |
| Duration::from_secs(seconds_per_slot / INTERVALS_PER_SLOT), | |
| ); | |
| interval.set_missed_tick_behavior(MissedTickBehavior::Burst); |
As I wrote in the comment, it'll be great to have common way to "tick" by a global clock.
Additional context
Shariq's comment: #679 (comment)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done