mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
ran fmt
This commit is contained in:
@@ -45,17 +45,12 @@ create_db!(
|
|||||||
);
|
);
|
||||||
|
|
||||||
impl BlockKeyDb {
|
impl BlockKeyDb {
|
||||||
|
|
||||||
fn save_block<N: Network>(txn: &mut impl DbTxn, number: usize, id: &<N::Block as Block<N>>::Id) {
|
fn save_block<N: Network>(txn: &mut impl DbTxn, number: usize, id: &<N::Block as Block<N>>::Id) {
|
||||||
Self::set(
|
Self::set(txn, u64::try_from(number).unwrap(), &BlockNumberKeyDb::to_block_number_key::<N>(id));
|
||||||
txn,
|
|
||||||
u64::try_from(number).unwrap(),
|
|
||||||
&BlockNumberKeyDb::to_block_number_key::<N>(id)
|
|
||||||
);
|
|
||||||
BlockNumberKeyDb::set(
|
BlockNumberKeyDb::set(
|
||||||
txn,
|
txn,
|
||||||
BlockNumberKeyDb::to_block_number_key::<N>(id),
|
BlockNumberKeyDb::to_block_number_key::<N>(id),
|
||||||
&u64::try_from(number).unwrap()
|
&u64::try_from(number).unwrap(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -75,7 +70,7 @@ impl BlockNumberKeyDb {
|
|||||||
|
|
||||||
fn block_number<N: Network>(getter: &impl Get, id: &<N::Block as Block<N>>::Id) -> Option<usize> {
|
fn block_number<N: Network>(getter: &impl Get, id: &<N::Block as Block<N>>::Id) -> Option<usize> {
|
||||||
let key = Self::to_block_number_key::<N>(id);
|
let key = Self::to_block_number_key::<N>(id);
|
||||||
Self::get(getter, key).map(|number| usize::try_from(number).unwrap())
|
Self::get(getter, key).map(|number| usize::try_from(number).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -116,7 +111,10 @@ impl KeysDb {
|
|||||||
while !bytes.is_empty() {
|
while !bytes.is_empty() {
|
||||||
let mut activation_number = [0; 8];
|
let mut activation_number = [0; 8];
|
||||||
bytes.read_exact(&mut activation_number).unwrap();
|
bytes.read_exact(&mut activation_number).unwrap();
|
||||||
res.push((u64::from_le_bytes(activation_number).try_into().unwrap(), N::Curve::read_G(&mut bytes).unwrap()));
|
res.push((
|
||||||
|
u64::from_le_bytes(activation_number).try_into().unwrap(),
|
||||||
|
N::Curve::read_G(&mut bytes).unwrap(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
@@ -175,7 +173,7 @@ impl ScannedBlocksDb {
|
|||||||
fn save_scanned_block<N: Network>(txn: &mut impl DbTxn, block: usize) -> Vec<N::Output> {
|
fn save_scanned_block<N: Network>(txn: &mut impl DbTxn, block: usize) -> Vec<N::Output> {
|
||||||
let id = BlockKeyDb::block::<N>(txn, block);
|
let id = BlockKeyDb::block::<N>(txn, block);
|
||||||
let outputs = id.as_ref().and_then(|id| OutputsDb::outputs::<N>(txn, id)).unwrap_or_default();
|
let outputs = id.as_ref().and_then(|id| OutputsDb::outputs::<N>(txn, id)).unwrap_or_default();
|
||||||
|
|
||||||
// Mark all the outputs from this block as seen
|
// Mark all the outputs from this block as seen
|
||||||
for output in &outputs {
|
for output in &outputs {
|
||||||
SeenDb::set(txn, SeenDb::to_seen_key::<N>(&output.id()), b"");
|
SeenDb::set(txn, SeenDb::to_seen_key::<N>(&output.id()), b"");
|
||||||
@@ -187,8 +185,7 @@ impl ScannedBlocksDb {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn latest_scanned_block(getter: &impl Get) -> Option<usize> {
|
fn latest_scanned_block(getter: &impl Get) -> Option<usize> {
|
||||||
Self::get(getter)
|
Self::get(getter).map(|number| usize::try_from(number).unwrap())
|
||||||
.map(|number| usize::try_from(number).unwrap())
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -205,8 +202,12 @@ impl RetirementBlocksDb {
|
|||||||
Self::set(txn, Self::to_retirement_block_key::<N>(key), &u64::try_from(block).unwrap());
|
Self::set(txn, Self::to_retirement_block_key::<N>(key), &u64::try_from(block).unwrap());
|
||||||
}
|
}
|
||||||
|
|
||||||
fn retirement_block<N: Network>(getter: &impl Get, key: &<N::Curve as Ciphersuite>::G) -> Option<usize> {
|
fn retirement_block<N: Network>(
|
||||||
Self::get(getter, Self::to_retirement_block_key::<N>(key)).map(|number| usize::try_from(number).unwrap())
|
getter: &impl Get,
|
||||||
|
key: &<N::Curve as Ciphersuite>::G,
|
||||||
|
) -> Option<usize> {
|
||||||
|
Self::get(getter, Self::to_retirement_block_key::<N>(key))
|
||||||
|
.map(|number| usize::try_from(number).unwrap())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -699,7 +700,8 @@ impl<N: Network, D: Db> Scanner<N, D> {
|
|||||||
// - There's outputs
|
// - There's outputs
|
||||||
// as only those blocks are meaningful and warrant obtaining synchrony over
|
// as only those blocks are meaningful and warrant obtaining synchrony over
|
||||||
let is_retirement_block =
|
let is_retirement_block =
|
||||||
RetirementBlocksDb::retirement_block::<N>(&db, &scanner.keys[0].1) == Some(block_being_scanned);
|
RetirementBlocksDb::retirement_block::<N>(&db, &scanner.keys[0].1) ==
|
||||||
|
Some(block_being_scanned);
|
||||||
let sent_block = if has_activation || is_retirement_block || (!outputs.is_empty()) {
|
let sent_block = if has_activation || is_retirement_block || (!outputs.is_empty()) {
|
||||||
// Save the outputs to disk
|
// Save the outputs to disk
|
||||||
let mut txn = db.txn();
|
let mut txn = db.txn();
|
||||||
|
|||||||
Reference in New Issue
Block a user