mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-08 20:29:23 +00:00
Have Coordinator MainDb take a mutable borrow
This commit is contained in:
@@ -41,12 +41,12 @@ async fn in_set(
|
||||
async fn handle_new_set<
|
||||
D: Db,
|
||||
Fut: Future<Output = ()>,
|
||||
ANT: Clone + Fn(D, TributarySpec) -> Fut,
|
||||
CNT: Clone + Fn(&mut D, TributarySpec) -> Fut,
|
||||
Pro: Processor,
|
||||
>(
|
||||
db: &D,
|
||||
db: &mut D,
|
||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
||||
add_new_tributary: ANT,
|
||||
create_new_tributary: CNT,
|
||||
processor: &Pro,
|
||||
serai: &Serai,
|
||||
block: &Block,
|
||||
@@ -56,7 +56,7 @@ async fn handle_new_set<
|
||||
let set_data = serai.get_validator_set(set).await?.expect("NewSet for set which doesn't exist");
|
||||
|
||||
let spec = TributarySpec::new(block.hash(), block.time().unwrap(), set, set_data);
|
||||
add_new_tributary(db.clone(), spec.clone());
|
||||
create_new_tributary(db, spec.clone());
|
||||
|
||||
// Trigger a DKG
|
||||
// TODO: Check how the processor handles this being fired multiple times
|
||||
@@ -210,12 +210,12 @@ async fn handle_batch_and_burns<Pro: Processor>(
|
||||
async fn handle_block<
|
||||
D: Db,
|
||||
Fut: Future<Output = ()>,
|
||||
ANT: Clone + Fn(D, TributarySpec) -> Fut,
|
||||
CNT: Clone + Fn(&mut D, TributarySpec) -> Fut,
|
||||
Pro: Processor,
|
||||
>(
|
||||
db: &mut SubstrateDb<D>,
|
||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
||||
add_new_tributary: ANT,
|
||||
create_new_tributary: CNT,
|
||||
processor: &Pro,
|
||||
serai: &Serai,
|
||||
block: Block,
|
||||
@@ -233,7 +233,7 @@ async fn handle_block<
|
||||
// stable)
|
||||
if !SubstrateDb::<D>::handled_event(&db.0, hash, event_id) {
|
||||
if let ValidatorSetsEvent::NewSet { set } = new_set {
|
||||
handle_new_set(&db.0, key, add_new_tributary.clone(), processor, serai, &block, set)
|
||||
handle_new_set(&mut db.0, key, create_new_tributary.clone(), processor, serai, &block, set)
|
||||
.await?;
|
||||
} else {
|
||||
panic!("NewSet event wasn't NewSet: {new_set:?}");
|
||||
@@ -278,12 +278,12 @@ async fn handle_block<
|
||||
pub async fn handle_new_blocks<
|
||||
D: Db,
|
||||
Fut: Future<Output = ()>,
|
||||
ANT: Clone + Fn(D, TributarySpec) -> Fut,
|
||||
CNT: Clone + Fn(&mut D, TributarySpec) -> Fut,
|
||||
Pro: Processor,
|
||||
>(
|
||||
db: &mut SubstrateDb<D>,
|
||||
key: &Zeroizing<<Ristretto as Ciphersuite>::F>,
|
||||
add_new_tributary: ANT,
|
||||
create_new_tributary: CNT,
|
||||
processor: &Pro,
|
||||
serai: &Serai,
|
||||
last_block: &mut u64,
|
||||
@@ -300,7 +300,7 @@ pub async fn handle_new_blocks<
|
||||
handle_block(
|
||||
db,
|
||||
key,
|
||||
add_new_tributary.clone(),
|
||||
create_new_tributary.clone(),
|
||||
processor,
|
||||
serai,
|
||||
if b == latest_number {
|
||||
|
||||
Reference in New Issue
Block a user