mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Break coordinator main into multiple functions
Also moves from std::sync::RwLock to tokio::sync::RwLock to prevent wasting cycles on spinning.
This commit is contained in:
@@ -300,14 +300,14 @@ pub async fn handle_new_blocks<D: Db, Pro: Processor, P: P2p>(
|
||||
let last_block = db.last_block(tributary.genesis());
|
||||
|
||||
// Check if there's been a new Tributary block
|
||||
let latest = tributary.tip();
|
||||
let latest = tributary.tip().await;
|
||||
if latest == last_block {
|
||||
return;
|
||||
}
|
||||
|
||||
let mut blocks = VecDeque::new();
|
||||
// This is a new block, as per the prior if check
|
||||
blocks.push_back(tributary.block(&latest).unwrap());
|
||||
blocks.push_back(tributary.block(&latest).await.unwrap());
|
||||
|
||||
let mut block = None;
|
||||
while {
|
||||
@@ -317,7 +317,7 @@ pub async fn handle_new_blocks<D: Db, Pro: Processor, P: P2p>(
|
||||
false
|
||||
} else {
|
||||
// Get this block
|
||||
block = Some(tributary.block(&parent).unwrap());
|
||||
block = Some(tributary.block(&parent).await.unwrap());
|
||||
// If it's the last block we've scanned, it's the end. Else, push it
|
||||
block.as_ref().unwrap().hash() != last_block
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user