pub enum Threshold {
AbsoluteCount {
weight: u64,
},
AbsolutePercentage {
percentage: Decimal,
},
ThresholdQuorum {
threshold: Decimal,
quorum: Decimal,
},
}
Expand description
This defines the different ways tallies can happen.
The total_weight used for calculating success as well as the weights of each
individual voter used in tallying should be snapshotted at the beginning of
the block at which the proposal starts (this is likely the responsibility of a
correct cw4 implementation).
See also ThresholdResponse
in the cw3 spec.
Variants
AbsoluteCount
Fields
weight: u64
Declares that a fixed weight of Yes votes is needed to pass.
See ThresholdResponse.AbsoluteCount
in the cw3 spec for details.
AbsolutePercentage
Fields
percentage: Decimal
Declares a percentage of the total weight that must cast Yes votes in order for
a proposal to pass.
See ThresholdResponse.AbsolutePercentage
in the cw3 spec for details.
ThresholdQuorum
Declares a quorum
of the total votes that must participate in the election in order
for the vote to be considered at all.
See ThresholdResponse.ThresholdQuorum
in the cw3 spec for details.
Implementations
sourceimpl Threshold
impl Threshold
sourcepub fn validate(&self, total_weight: u64) -> Result<(), ThresholdError>
pub fn validate(&self, total_weight: u64) -> Result<(), ThresholdError>
returns error if this is an unreachable value, given a total weight of all members in the group
sourcepub fn to_response(&self, total_weight: u64) -> ThresholdResponse
pub fn to_response(&self, total_weight: u64) -> ThresholdResponse
Creates a response from the saved data, just missing the total_weight info
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Threshold
impl<'de> Deserialize<'de> for Threshold
sourcefn 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
sourceimpl JsonSchema for Threshold
impl JsonSchema for Threshold
sourcefn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
sourcefn json_schema(gen: &mut SchemaGenerator) -> Schema
fn json_schema(gen: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
sourcefn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the $ref
keyword. Read more
impl StructuralPartialEq for Threshold
Auto Trait Implementations
impl RefUnwindSafe for Threshold
impl Send for Threshold
impl Sync for Threshold
impl Unpin for Threshold
impl UnwindSafe for Threshold
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more