Skip to main content

TaskState

Struct TaskState 

Source
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: u64

Service ID

§call_id: u64

Call ID

§output: Vec<u8>

The output being signed

§operator_count: u32

Number of operators in the service

§threshold_type: ThresholdType

Threshold type and value

§signer_bitmap: U256

Bitmap 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: u64

Total stake of all operators

§submitted: bool

Whether this task has been submitted to chain

§created_at: Instant

When this task was created

§expires_at: Option<Instant>

When this task expires (None = never)

Implementations§

Source§

impl TaskState

Source

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

Source

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

Source

pub fn is_expired(&self) -> bool

Check if this task has expired

Source

pub fn time_remaining(&self) -> Option<Duration>

Get remaining time until expiry

Source

pub fn add_signature( &mut self, operator_index: u32, signature: ArkBlsBn254Signature, public_key: ArkBlsBn254Public, ) -> Result<(), &'static str>

Add a signature from an operator

Source

pub fn has_signed(&self, operator_index: u32) -> bool

Check if an operator has already signed

Source

pub fn signature_count(&self) -> usize

Get the number of signatures collected

Source

pub fn signed_stake(&self) -> u64

Get the total stake that has signed

Source

pub fn signed_stake_bps(&self) -> u32

Get the signed stake as basis points (0-10000) of total stake

Source

pub fn threshold_met(&self) -> bool

Check if threshold is met

Source

pub fn threshold_value(&self) -> usize

Get the threshold value (for API responses)

Source

pub fn get_non_signers(&self) -> Vec<u32>

Get list of operators who haven’t signed (non-signers)

Source

pub fn get_signers(&self) -> Vec<u32>

Get list of operators who have signed

Source

pub fn get_signatures_for_aggregation( &self, ) -> (Vec<ArkBlsBn254Signature>, Vec<ArkBlsBn254Public>)

Get all signatures and public keys in order for aggregation

Trait Implementations§

Source§

impl Debug for TaskState

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more