Formatting and clippy changes
This commit is contained in:
parent
711a34cc2d
commit
c8b6bb9fdd
|
@ -66,7 +66,7 @@ impl DB {
|
|||
if lox_db.was_recovered() && !lox_db.is_empty() {
|
||||
context = match read_lox_context_from_db(lox_db.clone(), roll_back_date) {
|
||||
Ok(ctx) => ctx,
|
||||
Err(e) => panic!("Unable to read lox database {:?}", e)
|
||||
Err(e) => panic!("Unable to read lox database {:?}", e),
|
||||
};
|
||||
context.metrics = metrics;
|
||||
//Otherwise, create a new Lox context
|
||||
|
@ -133,9 +133,7 @@ fn read_lox_context_from_db(
|
|||
}
|
||||
}
|
||||
// Use the last entry to populate the Lox context if no rollback date is set (which should be most common)
|
||||
None => {
|
||||
context = use_last_context(lox_db)?
|
||||
}
|
||||
None => context = use_last_context(lox_db)?,
|
||||
}
|
||||
Ok(context)
|
||||
}
|
||||
|
@ -149,14 +147,14 @@ fn compute_startdate_string(date_range_end: String) -> Option<DateTime<Utc>> {
|
|||
|
||||
// Use the last context that was entered into the database
|
||||
fn use_last_context(lox_db: sled::Db) -> Result<lox_context::LoxServerContext, LoxDBError> {
|
||||
match lox_db.last()? {
|
||||
Some(ivec_context) => {
|
||||
let ivec_date: String = String::from_utf8(ivec_context.0.to_vec()).unwrap();
|
||||
println!("Using last context with date: {:?}", ivec_date);
|
||||
Ok(serde_json::from_slice(&ivec_context.1).unwrap())
|
||||
},
|
||||
None => Err(LoxDBError::DatabaseEmpty)
|
||||
match lox_db.last()? {
|
||||
Some(ivec_context) => {
|
||||
let ivec_date: String = String::from_utf8(ivec_context.0.to_vec()).unwrap();
|
||||
println!("Using last context with date: {:?}", ivec_date);
|
||||
Ok(serde_json::from_slice(&ivec_context.1).unwrap())
|
||||
}
|
||||
None => Err(LoxDBError::DatabaseEmpty),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
|
|
@ -11,12 +11,12 @@ use lox_library::{
|
|||
use rdsys_backend::proto::{Resource, ResourceState};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use lox_zkp::ProofError;
|
||||
use std::{
|
||||
cmp::Ordering,
|
||||
collections::HashMap,
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
use lox_zkp::ProofError;
|
||||
|
||||
use crate::metrics::Metrics;
|
||||
use crate::resource_parser::{parse_into_bridgelines, sort_for_parsing};
|
||||
|
|
|
@ -409,9 +409,11 @@ mod tests {
|
|||
&pubkeys_obj.lox_pub,
|
||||
)
|
||||
.unwrap();
|
||||
let mut bridge = Vec::new();
|
||||
bridge.push(lox_cred.1);
|
||||
let lox_cred: lox_utils::LoxCredential = lox_utils::LoxCredential {
|
||||
lox_credential: lox_cred.0,
|
||||
bridgeline: Some(lox_cred.1),
|
||||
bridgelines: Some(bridge),
|
||||
invitation: None,
|
||||
};
|
||||
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
use std::process::exit;
|
||||
|
||||
use chrono::{Duration, Utc};
|
||||
use lox_library::bridge_table::{BridgeLine, BRIDGE_BYTES, MAX_BRIDGES_PER_BUCKET};
|
||||
use rdsys_backend::proto::Resource;
|
||||
|
|
|
@ -266,11 +266,11 @@ impl BridgeDb {
|
|||
let bucket = u32::from_le_bytes(invitation[32..(32 + 4)].try_into().unwrap());
|
||||
let s = Scalar::from_canonical_bytes(invitation[0..32].try_into().unwrap());
|
||||
if s.is_some().into() {
|
||||
return Ok((s.unwrap(), bucket));
|
||||
Ok((s.unwrap(), bucket))
|
||||
} else {
|
||||
// It should never happen that there's a valid signature on
|
||||
// an invalid serialization of a Scalar, but check anyway.
|
||||
return Err(SignatureError::new());
|
||||
Err(SignatureError::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue