Skip to content

Commit

Permalink
attempted to do the rustfmt
Browse files Browse the repository at this point in the history
  • Loading branch information
econsta committed Oct 2, 2023
1 parent 884e462 commit 4c7aa27
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 24 deletions.
7 changes: 1 addition & 6 deletions processor/src/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ pub use serai_db::*;

use crate::networks::{Block, Network};

createDb!(
MainDb {
HandledMessageDb,
PendingActivationsDb
}
);
createDb!(MainDb { HandledMessageDb, PendingActivationsDb });

#[derive(Debug)]
pub struct MainDb<N: Network, D: Db>(D, PhantomData<N>);
Expand Down
30 changes: 12 additions & 18 deletions processor/src/key_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@ pub struct KeyConfirmed<C: Ciphersuite> {
pub network_keys: ThresholdKeys<C>,
}

createDb!(
KeyGenDb {
ParamsDb,
CommitmentsDb,
GeneratedKeysDb,
KeysDb
}
);
createDb!(KeyGenDb { ParamsDb, CommitmentsDb, GeneratedKeysDb, KeysDb });

#[allow(clippy::type_complexity)]
fn read_keys<N: Network>(
Expand All @@ -56,8 +49,7 @@ fn confirm_keys<N: Network>(
) -> (ThresholdKeys<Ristretto>, ThresholdKeys<N::Curve>) {
let val: &[u8] = key_pair.1.as_ref();
let (keys_vec, keys) =
read_keys::<N>(txn, &GeneratedKeysDb::key((set, (&key_pair.0 .0, val)).encode()))
.unwrap();
read_keys::<N>(txn, &GeneratedKeysDb::key((set, (&key_pair.0 .0, val)).encode())).unwrap();
assert_eq!(key_pair.0 .0, keys.0.group_key().to_bytes());
assert_eq!(
{
Expand Down Expand Up @@ -87,11 +79,12 @@ impl GeneratedKeysDb {
) {
let mut keys = substrate_keys.serialize();
keys.extend(network_keys.serialize().iter());
let key = (id.set, (&substrate_keys.group_key().to_bytes(), network_keys.group_key().to_bytes().as_ref())).encode();
txn.put(
Self::key(key),
keys,
);
let key = (
id.set,
(&substrate_keys.group_key().to_bytes(), network_keys.group_key().to_bytes().as_ref()),
)
.encode();
txn.put(Self::key(key), keys);
}
}

Expand Down Expand Up @@ -170,8 +163,8 @@ impl<N: Network, D: Db> KeyGen<N, D> {
info!("Generating new key. ID: {:?} Params: {:?}", id, params);

// Remove old attempts
if self.active_commit.remove(&id.set).is_none() &&
self.active_share.remove(&id.set).is_none()
if self.active_commit.remove(&id.set).is_none()
&& self.active_share.remove(&id.set).is_none()
{
// If we haven't handled this set before, save the params
ParamsDb::set(txn, &id.set.encode(), &params);
Expand Down Expand Up @@ -269,7 +262,8 @@ impl<N: Network, D: Db> KeyGen<N, D> {
let machines = self.active_share.remove(&id.set).unwrap_or_else(|| {
let machines = key_gen_machines(id, params).0;
let mut rng = secret_shares_rng(id);
let commitments = CommitmentsDb::get::<HashMap<Participant, Vec<u8>>>(txn, &id.encode()).unwrap();
let commitments =
CommitmentsDb::get::<HashMap<Participant, Vec<u8>>>(txn, &id.encode()).unwrap();

let mut commitments_ref: HashMap<Participant, &[u8]> =
commitments.iter().map(|(i, commitments)| (*i, commitments.as_ref())).collect();
Expand Down

0 comments on commit 4c7aa27

Please sign in to comment.