Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit d5dd915

Browse files
committed
implemented pow multithreaded worker
1 parent e6787ae commit d5dd915

File tree

1 file changed

+20
-20
lines changed
  • client/consensus/pow/src

1 file changed

+20
-20
lines changed

client/consensus/pow/src/lib.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ where
277277
execution_context: ExecutionContext,
278278
) -> Result<(), Error<B>> {
279279
if *block.header().number() < self.check_inherents_after {
280-
return Ok(());
280+
return Ok(())
281281
}
282282

283283
if let Err(e) = self.can_author_with.can_author_with(&block_id) {
@@ -287,7 +287,7 @@ where
287287
e,
288288
);
289289

290-
return Ok(());
290+
return Ok(())
291291
}
292292

293293
let inherent_data = inherent_data_providers
@@ -389,7 +389,7 @@ where
389389
&inner_seal,
390390
difficulty,
391391
)? {
392-
return Err(Error::<B>::InvalidSeal.into());
392+
return Err(Error::<B>::InvalidSeal.into())
393393
}
394394

395395
aux.difficulty = difficulty;
@@ -407,7 +407,7 @@ where
407407
fetch_seal::<B>(best_header.digest().logs.last(), best_hash)?;
408408

409409
self.algorithm.break_tie(&best_inner_seal, &inner_seal)
410-
}
410+
},
411411
},
412412
));
413413
}
@@ -437,20 +437,20 @@ impl<B: BlockT, Algorithm> PowVerifier<B, Algorithm> {
437437
let hash = header.hash();
438438

439439
let (seal, inner_seal) = match header.digest_mut().pop() {
440-
Some(DigestItem::Seal(id, seal)) => {
440+
Some(DigestItem::Seal(id, seal)) =>
441441
if id == POW_ENGINE_ID {
442442
(DigestItem::Seal(id, seal.clone()), seal)
443443
} else {
444444
return Err(Error::WrongEngine(id));
445445
}
446-
}
446+
447447
_ => return Err(Error::HeaderUnsealed(hash)),
448448
};
449449

450450
let pre_hash = header.hash();
451451

452452
if !self.algorithm.preliminary_verify(&pre_hash, &inner_seal)?.unwrap_or(true) {
453-
return Err(Error::FailedPreliminaryVerify);
453+
return Err(Error::FailedPreliminaryVerify)
454454
}
455455

456456
Ok((header, seal))
@@ -579,7 +579,7 @@ where
579579

580580
if sync_oracle.is_major_syncing() {
581581
debug!(target: "pow", "Skipping proposal due to sync.");
582-
continue;
582+
continue
583583
}
584584

585585
let best_header = match select_chain.best_chain().await {
@@ -591,7 +591,7 @@ where
591591
Select best chain error: {:?}",
592592
err
593593
);
594-
continue;
594+
continue
595595
}
596596
};
597597
let best_hash = best_header.hash();
@@ -603,7 +603,7 @@ where
603603
Probably a node update is required!",
604604
err,
605605
);
606-
continue;
606+
continue
607607
}
608608

609609
// The worker is locked for the duration of the whole proposing period. Within this
@@ -618,7 +618,7 @@ where
618618
Fetch difficulty failed: {:?}",
619619
err,
620620
);
621-
continue;
621+
continue
622622
}
623623
};
624624

@@ -634,7 +634,7 @@ where
634634
Creating inherent data providers failed: {:?}",
635635
err,
636636
);
637-
continue;
637+
continue
638638
}
639639
};
640640

@@ -647,7 +647,7 @@ where
647647
Creating inherent data failed: {:?}",
648648
e,
649649
);
650-
continue;
650+
continue
651651
}
652652
};
653653

@@ -667,7 +667,7 @@ where
667667
Creating proposer failed: {:?}",
668668
err,
669669
);
670-
continue;
670+
continue
671671
}
672672
};
673673

@@ -683,7 +683,7 @@ where
683683
Creating proposal failed: {:?}",
684684
err,
685685
);
686-
continue;
686+
continue
687687
}
688688
};
689689

@@ -719,12 +719,12 @@ fn find_pre_digest<B: BlockT>(header: &B::Header) -> Result<Option<Vec<u8>>, Err
719719
for log in header.digest().logs() {
720720
trace!(target: "pow", "Checking log {:?}, looking for pre runtime digest", log);
721721
match (log, pre_digest.is_some()) {
722-
(DigestItem::PreRuntime(POW_ENGINE_ID, _), true) => {
723-
return Err(Error::MultiplePreRuntimeDigests)
724-
}
722+
(DigestItem::PreRuntime(POW_ENGINE_ID, _), true) =>
723+
return Err(Error::MultiplePreRuntimeDigests),
724+
725725
(DigestItem::PreRuntime(POW_ENGINE_ID, v), false) => {
726726
pre_digest = Some(v.clone());
727-
}
727+
},
728728
(_, _) => trace!(target: "pow", "Ignoring digest not meant for us"),
729729
}
730730
}
@@ -742,7 +742,7 @@ fn fetch_seal<B: BlockT>(
742742
if id == &POW_ENGINE_ID {
743743
Ok(seal.clone())
744744
} else {
745-
return Err(Error::<B>::WrongEngine(*id).into());
745+
return Err(Error::<B>::WrongEngine(*id).into())
746746
}
747747
}
748748
_ => return Err(Error::<B>::HeaderUnsealed(hash).into()),

0 commit comments

Comments
 (0)