pub struct TaskState {Show 13 fields
pub service_id: u64,
pub call_id: u64,
pub output: Vec<u8>,
pub operator_count: u32,
pub threshold_type: ThresholdType,
pub signer_bitmap: U256,
pub signatures: HashMap<u32, ArkBlsBn254Signature>,
pub public_keys: HashMap<u32, ArkBlsBn254Public>,
pub operator_stakes: HashMap<u32, u64>,
pub total_stake: u64,
pub submitted: bool,
pub created_at: Instant,
pub expires_at: Option<Instant>,
}Expand description
State for a single aggregation task
Fields§
§service_id: u64Service ID
call_id: u64Call ID
output: Vec<u8>The output being signed
operator_count: u32Number of operators in the service
threshold_type: ThresholdTypeThreshold type and value
signer_bitmap: U256Bitmap of which operators have signed (bit i = operator i signed)
signatures: HashMap<u32, ArkBlsBn254Signature>Collected signatures indexed by operator index
public_keys: HashMap<u32, ArkBlsBn254Public>Collected public keys indexed by operator index
operator_stakes: HashMap<u32, u64>Operator stakes for stake-weighted thresholds
total_stake: u64Total stake of all operators
submitted: boolWhether this task has been submitted to chain
created_at: InstantWhen this task was created
expires_at: Option<Instant>When this task expires (None = never)
Implementations§
Source§impl TaskState
impl TaskState
Sourcepub fn new(
service_id: u64,
call_id: u64,
output: Vec<u8>,
operator_count: u32,
threshold: u32,
) -> Self
pub fn new( service_id: u64, call_id: u64, output: Vec<u8>, operator_count: u32, threshold: u32, ) -> Self
Create a new task state with count-based threshold
Sourcepub fn with_config(
service_id: u64,
call_id: u64,
output: Vec<u8>,
operator_count: u32,
threshold_type: ThresholdType,
operator_stakes: Option<HashMap<u32, u64>>,
ttl: Option<Duration>,
) -> Self
pub fn with_config( service_id: u64, call_id: u64, output: Vec<u8>, operator_count: u32, threshold_type: ThresholdType, operator_stakes: Option<HashMap<u32, u64>>, ttl: Option<Duration>, ) -> Self
Create a new task state with full configuration
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if this task has expired
Sourcepub fn time_remaining(&self) -> Option<Duration>
pub fn time_remaining(&self) -> Option<Duration>
Get remaining time until expiry
Sourcepub fn add_signature(
&mut self,
operator_index: u32,
signature: ArkBlsBn254Signature,
public_key: ArkBlsBn254Public,
) -> Result<(), &'static str>
pub fn add_signature( &mut self, operator_index: u32, signature: ArkBlsBn254Signature, public_key: ArkBlsBn254Public, ) -> Result<(), &'static str>
Add a signature from an operator
Sourcepub fn has_signed(&self, operator_index: u32) -> bool
pub fn has_signed(&self, operator_index: u32) -> bool
Check if an operator has already signed
Sourcepub fn signature_count(&self) -> usize
pub fn signature_count(&self) -> usize
Get the number of signatures collected
Sourcepub fn signed_stake(&self) -> u64
pub fn signed_stake(&self) -> u64
Get the total stake that has signed
Sourcepub fn signed_stake_bps(&self) -> u32
pub fn signed_stake_bps(&self) -> u32
Get the signed stake as basis points (0-10000) of total stake
Sourcepub fn threshold_met(&self) -> bool
pub fn threshold_met(&self) -> bool
Check if threshold is met
Sourcepub fn threshold_value(&self) -> usize
pub fn threshold_value(&self) -> usize
Get the threshold value (for API responses)
Sourcepub fn get_non_signers(&self) -> Vec<u32>
pub fn get_non_signers(&self) -> Vec<u32>
Get list of operators who haven’t signed (non-signers)
Sourcepub fn get_signers(&self) -> Vec<u32>
pub fn get_signers(&self) -> Vec<u32>
Get list of operators who have signed
Sourcepub fn get_signatures_for_aggregation(
&self,
) -> (Vec<ArkBlsBn254Signature>, Vec<ArkBlsBn254Public>)
pub fn get_signatures_for_aggregation( &self, ) -> (Vec<ArkBlsBn254Signature>, Vec<ArkBlsBn254Public>)
Get all signatures and public keys in order for aggregation
Trait Implementations§
Auto Trait Implementations§
impl Freeze for TaskState
impl RefUnwindSafe for TaskState
impl Send for TaskState
impl Sync for TaskState
impl Unpin for TaskState
impl UnsafeUnpin for TaskState
impl UnwindSafe for TaskState
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
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>
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>
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