From f62dedd01ae6edecfd5d23f32dcb141ca7281a3d Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Thu, 7 Dec 2023 05:07:00 -0500 Subject: [PATCH] Misc tweaks --- coordinator/src/db.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/coordinator/src/db.rs b/coordinator/src/db.rs index 217b28aeb..c6308bfaa 100644 --- a/coordinator/src/db.rs +++ b/coordinator/src/db.rs @@ -25,7 +25,7 @@ create_db!( FirstPreprocessDb: ( network: NetworkId, id_type: RecognizedIdType, - id: &[u8], + id: &[u8] ) -> Vec>, LastRecievedBatchDb: (network: NetworkId) -> u32, ExpectedBatchDb: (network: NetworkId, id: u32) -> [u8; 32], @@ -39,7 +39,7 @@ create_db!( impl ActiveTributaryDb { pub fn active_tributaries(getter: &G) -> (Vec, Vec) { - let bytes =Self::get(getter).unwrap_or_default(); + let bytes = Self::get(getter).unwrap_or_default(); let mut bytes_ref: &[u8] = bytes.as_ref(); let mut tributaries = vec![]; @@ -69,7 +69,7 @@ impl ActiveTributaryDb { } pub fn add_participating_in_tributary(txn: &mut impl DbTxn, spec: &TributarySpec) { - InTributaryDb::set(txn, spec.set(), &vec![] as &Vec); + InTributaryDb::set(txn, spec.set(), &vec![] as &Vec); let (mut existing_bytes, existing) = ActiveTributaryDb::active_tributaries(txn); for tributary in &existing { @@ -84,7 +84,8 @@ pub fn add_participating_in_tributary(txn: &mut impl DbTxn, spec: &TributarySpec impl SignedTransactionDb { pub fn take_signed_transaction(txn: &mut impl DbTxn, nonce: u32) -> Option { - let res = SignedTransactionDb::get(txn, nonce).map(|bytes| Transaction::read(&mut bytes.as_slice()).unwrap()); + let res = SignedTransactionDb::get(txn, nonce) + .map(|bytes| Transaction::read(&mut bytes.as_slice()).unwrap()); if res.is_some() { txn.del(Self::key(nonce)); } @@ -100,11 +101,11 @@ impl FirstPreprocessDb { id: &[u8], preprocess: Vec>, ) { - if let Some(existing) = FirstPreprocessDb::get(txn, network, id_type, &id.to_vec()) { + if let Some(existing) = FirstPreprocessDb::get(txn, network, id_type, id) { assert_eq!(existing, preprocess, "saved a distinct first preprocess"); return; } - FirstPreprocessDb::set(txn, network, id_type, &id.to_vec(), &preprocess); + FirstPreprocessDb::set(txn, network, id_type, id, &preprocess); } }