pub struct WasmParallelPowGenerator { /* private fields */ }Expand description
A ParallelPowGenerator that distributes PoW work across pre-created Web Workers.
The TypeScript side is responsible for spawning and initializing the workers;
this struct simply receives the ready Worker handles.
Implementations§
Source§impl WasmParallelPowGenerator
impl WasmParallelPowGenerator
Sourcepub fn from_workers(workers: Vec<Worker>) -> Self
pub fn from_workers(workers: Vec<Worker>) -> Self
Create a new generator from pre-initialized Worker handles.
Trait Implementations§
Source§impl ParallelPowGenerator for WasmParallelPowGenerator
impl ParallelPowGenerator for WasmParallelPowGenerator
Source§fn generate_best_effort<'life0, 'life1, 'async_trait>(
&'life0 self,
_label: &'life1 str,
iteration_limit: usize,
pow_min: Pow,
data_hash: Hash,
) -> Pin<Box<dyn Future<Output = Result<(Salt, Pow, Hash)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate_best_effort<'life0, 'life1, 'async_trait>(
&'life0 self,
_label: &'life1 str,
iteration_limit: usize,
pow_min: Pow,
data_hash: Hash,
) -> Pin<Box<dyn Future<Output = Result<(Salt, Pow, Hash)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Run up to
iteration_limit hash attempts and return the best (Salt, Pow, Hash) found.
Exits early if pow >= pow_min is achieved. Read moreSource§fn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
label: &'life1 str,
pow_min: Pow,
data_hash: Hash,
) -> Pin<Box<dyn Future<Output = Result<(Salt, Pow, Hash)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn generate<'life0, 'life1, 'async_trait>(
&'life0 self,
label: &'life1 str,
pow_min: Pow,
data_hash: Hash,
) -> Pin<Box<dyn Future<Output = Result<(Salt, Pow, Hash)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Loop
generate_best_effort in batches until pow >= pow_min is achieved.Source§fn active_jobs(&self) -> Vec<PowJobStatus>
fn active_jobs(&self) -> Vec<PowJobStatus>
Snapshot of all concurrently in-flight tracked jobs.
Source§fn tracker(&self) -> &Arc<Mutex<JobTracker>>
fn tracker(&self) -> &Arc<Mutex<JobTracker>>
Accessor for the impl’s
JobTracker. Exists so the default generate_best_effort_tracked
implementation can register the job without each impl having to duplicate the wrapping.Source§fn generate_best_effort_tracked<'life0, 'life1, 'async_trait>(
&'life0 self,
label: &'life1 str,
iteration_limit: usize,
pow_min: Pow,
data_hash: Hash,
) -> Pin<Box<dyn Future<Output = Result<(Salt, Pow, Hash), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
fn generate_best_effort_tracked<'life0, 'life1, 'async_trait>(
&'life0 self,
label: &'life1 str,
iteration_limit: usize,
pow_min: Pow,
data_hash: Hash,
) -> Pin<Box<dyn Future<Output = Result<(Salt, Pow, Hash), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
generate_best_effort plus tracker registration for the duration of the call.
Use this when a single-batch PoW is run directly (i.e. not inside generate_loop),
otherwise the job is invisible to active_jobs().impl Send for WasmParallelPowGenerator
impl Sync for WasmParallelPowGenerator
Auto Trait Implementations§
impl Freeze for WasmParallelPowGenerator
impl RefUnwindSafe for WasmParallelPowGenerator
impl Unpin for WasmParallelPowGenerator
impl UnsafeUnpin for WasmParallelPowGenerator
impl UnwindSafe for WasmParallelPowGenerator
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more