|
14 | 14 | // You should have received a copy of the GNU General Public License
|
15 | 15 | // along with this program. If not, see <http://www.gnu.org/licenses/>.
|
16 | 16 |
|
| 17 | +use stacks_common::define_named_enum; |
| 18 | + |
17 | 19 | #[cfg(feature = "monitoring_prom")]
|
18 | 20 | mod prometheus;
|
19 | 21 |
|
20 | 22 | #[cfg(feature = "monitoring_prom")]
|
21 | 23 | mod server;
|
22 | 24 |
|
| 25 | +define_named_enum!( |
23 | 26 | /// Represent different state change reason on signer agreement protocol
|
24 |
| -pub enum SignerAgreementStateChangeReason { |
| 27 | +SignerAgreementStateChangeReason { |
25 | 28 | /// A new burn block has arrived
|
26 |
| - BurnBlockArrival, |
| 29 | + BurnBlockArrival("burn_block_arrival"), |
27 | 30 | /// A new stacks block has arrived
|
28 |
| - StacksBlockArrival, |
| 31 | + StacksBlockArrival("stacks_block_arrival"), |
29 | 32 | /// A miner is inactive when it should be starting its tenure
|
30 |
| - InactiveMiner, |
| 33 | + InactiveMiner("inactive_miner"), |
31 | 34 | /// Signer agreement protocol version has been upgraded
|
32 |
| - ProtocalUpgrade, |
33 |
| -} |
34 |
| - |
35 |
| -impl std::fmt::Display for SignerAgreementStateChangeReason { |
36 |
| - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { |
37 |
| - write!( |
38 |
| - f, |
39 |
| - "{}", |
40 |
| - match self { |
41 |
| - SignerAgreementStateChangeReason::BurnBlockArrival => "burn_block_arrival", |
42 |
| - SignerAgreementStateChangeReason::StacksBlockArrival => "stacks_block_arrival", |
43 |
| - SignerAgreementStateChangeReason::InactiveMiner => "inactive_miner", |
44 |
| - SignerAgreementStateChangeReason::ProtocalUpgrade => "protocol_upgrade", |
45 |
| - } |
46 |
| - ) |
47 |
| - } |
48 |
| -} |
| 35 | + ProtocalUpgrade("protocol_upgrade"), |
| 36 | +}); |
49 | 37 |
|
50 | 38 | /// Actions for updating metrics
|
51 | 39 | #[cfg(feature = "monitoring_prom")]
|
@@ -140,7 +128,7 @@ pub mod actions {
|
140 | 128 | pub fn increment_signer_agreement_state_change_reason(
|
141 | 129 | reason: SignerAgreementStateChangeReason,
|
142 | 130 | ) {
|
143 |
| - let label_value = reason.to_string(); |
| 131 | + let label_value = reason.get_name(); |
144 | 132 | SIGNER_AGREEMENT_STATE_CHANGE_REASONS
|
145 | 133 | .with_label_values(&[&label_value])
|
146 | 134 | .inc();
|
|
0 commit comments