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,
) -> Self
pub fn new( operation_type: String, input_tensors: Vec<Tensor>, difficulty: u64, reward: u64, max_computation_time: u64, requester: String, ) -> Self
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. 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> 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