Skip to content

Commit 2f906c7

Browse files
committed
Restore: Detect duplicate key shares and allow retries.
1 parent 2923057 commit 2f906c7

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/main.rs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,20 @@ fn main() -> Result<()> {
904904
let mut shares: Zeroizing<Vec<Share>> =
905905
Zeroizing::new(Vec::new());
906906
for share in share_itr {
907-
shares.deref_mut().push(*share?.deref());
907+
// We can't use `?` in the closure below so we just
908+
// get it out of the way here.
909+
let share = share?;
910+
911+
if shares.iter_mut().any(|u| *u == *share.deref()) {
912+
println!(
913+
"This key share has already been entered. \
914+
Please enter a new one"
915+
);
916+
continue;
917+
} else {
918+
shares.deref_mut().push(*share.deref());
919+
}
920+
908921
if shares.len() >= THRESHOLD {
909922
break;
910923
}

0 commit comments

Comments
 (0)