1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! # Vote Weight Decay Models
//!
//! Implements different models for how vote weights decrease over time,
//! encouraging early participation in the voting process.
use ;
/// Models for how vote weights decay over time.
///
/// Each model provides a different curve for weight reduction:
/// - Linear: Steady decline from 1.0 to 0.1
/// - Exponential: Rapid early decline, slower later
/// - Stepped: Discrete weight levels based on voting phases
/// Calculates the weight multiplier for a vote based on the decay model and timing.
///
/// All models enforce a minimum weight of 0.1 to ensure every vote has some influence.
///
/// # Arguments
/// * `model` - The decay model to use
/// * `t` - Time elapsed since voting started (seconds)
/// * `total` - Total voting period duration (seconds)
///
/// # Returns
/// Weight multiplier between 0.1 and 1.0
///
/// # Examples
/// ```
/// use verdyce_core::decay::{DecayModel, weight_calc};
///
/// // Linear decay at halfway point
/// let weight = weight_calc(&DecayModel::Linear, 1800, 3600);
/// assert!((weight - 0.5).abs() < 0.01);
///
/// // Exponential decay
/// let weight = weight_calc(&DecayModel::Exponential(0.001), 0, 3600);
/// assert!((weight - 1.0).abs() < 0.01);
/// ```