Skip to content

Commit 9c8517a

Browse files
committed
minor optimization by observing that partition faulty_power should be zero when faults is empty
1 parent f3ddb23 commit 9c8517a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

actors/miner/src/deadline_state.rs

+7-2
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,13 @@ impl Deadlines {
124124
if !moving_partition.faults.is_empty() || !moving_partition.unproven.is_empty() {
125125
return Err(actor_error!(forbidden, "partition with faults or unproven sectors are not allowed to move, partition_idx {}", orig_partition_idx))?;
126126
}
127+
if !moving_partition.faulty_power.is_zero() {
128+
return Err(actor_error!(
129+
illegal_state,
130+
"partition faulty_power should be zero when faults is empty, partition_idx {}",
131+
orig_partition_idx
132+
))?;
133+
}
127134

128135
let dest_partition_idx = first_dest_partition_idx + i as u64;
129136

@@ -137,11 +144,9 @@ impl Deadlines {
137144

138145
orig_deadline.total_sectors -= all_sectors;
139146
orig_deadline.live_sectors -= live_sectors;
140-
orig_deadline.faulty_power -= &moving_partition.faulty_power;
141147

142148
dest_deadline.total_sectors += all_sectors;
143149
dest_deadline.live_sectors += live_sectors;
144-
dest_deadline.faulty_power += &moving_partition.faulty_power;
145150

146151
orig_partitions.set(orig_partition_idx, Partition::new(store)?)?;
147152
dest_partitions.set(dest_partition_idx, moving_partition)?;

0 commit comments

Comments
 (0)