pub struct MiningTask {
pub id: String,
pub operation_type: String,
pub input_tensors: Vec<Tensor>,
pub difficulty: u64,
pub reward: u64,
pub max_computation_time: u64,
pub requester: String,
pub created_at: DateTime<Utc>,
pub expires_at: DateTime<Utc>,
}Expand description
A single mining task (operation, input tensors, difficulty, expiry).
Fields§
§id: StringUnique task id.
operation_type: StringOperation type (e.g. matrix_multiply, relu).
input_tensors: Vec<Tensor>Input tensors for the operation.
difficulty: u64Difficulty (leading zeros required in hash).
reward: u64Reward amount.
max_computation_time: u64Max computation time in seconds.
requester: StringRequester/miner id.
created_at: DateTime<Utc>Creation timestamp.
expires_at: DateTime<Utc>Expiry timestamp.
Implementations§
Source§impl MiningTask
impl MiningTask
Sourcepub fn new(
operation_type: String,
input_tensors: Vec<Tensor>,
difficulty: u64,
reward: u64,
max_computation_time: u64,
requester: String,
) -> MiningTask
pub fn new( operation_type: String, input_tensors: Vec<Tensor>, difficulty: u64, reward: u64, max_computation_time: u64, requester: String, ) -> MiningTask
Creates a new mining task with generated id and expiry.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Returns true if the task has passed its expiry time.
Sourcepub fn meets_difficulty(&self, hash: &str) -> bool
pub fn meets_difficulty(&self, hash: &str) -> bool
Returns true if the given hash has at least difficulty leading zeros.
Trait Implementations§
Source§impl Clone for MiningTask
impl Clone for MiningTask
Source§fn clone(&self) -> MiningTask
fn clone(&self) -> MiningTask
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MiningTask
impl Debug for MiningTask
Source§impl<'de> Deserialize<'de> for MiningTask
impl<'de> Deserialize<'de> for MiningTask
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<MiningTask, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<MiningTask, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for MiningTask
impl Serialize for MiningTask
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for MiningTask
impl RefUnwindSafe for MiningTask
impl Send for MiningTask
impl Sync for MiningTask
impl Unpin for MiningTask
impl UnsafeUnpin for MiningTask
impl UnwindSafe for MiningTask
Blanket Implementations§
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, _digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<T> AbiEnumVisitor for T
impl<T> AbiEnumVisitor for T
default fn visit_for_abi( &self, digester: &mut AbiDigester, ) -> Result<AbiDigester, DigestError>
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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