Skip to content

Commit

Permalink
Fix counting signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
kvinwang committed Jan 4, 2024
1 parent a7021da commit 545ad56
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion crates/phactory/src/prpc_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2044,6 +2044,7 @@ impl<Platform: pal::Platform + Serialize + DeserializeOwned> PhactoryApi for Rpc
let mr_from = hex::encode(my_measurement()?);
let signed_message = format!("Allow pRuntime to handover from 0x{mr_from} to 0x{mr_to} on chain of genesis 0x{genesis_hash}").into_bytes();
debug!("Signed message : {:?}", hex::encode(&signed_message));
let mut indivaduals = std::collections::BTreeSet::new();
for sig in &request.signatures {
let sig_type = pb::SignatureType::from_i32(sig.signature_type)
.ok_or_else(|| from_display("Invalid signature type"))?;
Expand All @@ -2058,8 +2059,9 @@ impl<Platform: pal::Platform + Serialize + DeserializeOwned> PhactoryApi for Rpc
if !council_members.contains(&signer) {
return Err(from_display("Not a council member"));
}
indivaduals.insert(signer);
}
let percent = request.signatures.len() * 100 / council_members.len();
let percent = indivaduals.len() * 100 / council_members.len();
if percent < 50 {
return Err(from_display("Not enough signatures"));
}
Expand Down

0 comments on commit 545ad56

Please sign in to comment.