Skip to content

Commit 562344a

Browse files
committed
fix: use define_named_enum!
1 parent 0e6e85a commit 562344a

File tree

1 file changed

+7
-18
lines changed
  • stackslib/src/monitoring

1 file changed

+7
-18
lines changed

stackslib/src/monitoring/mod.rs

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -462,30 +462,19 @@ pub fn get_burnchain_signer() -> Option<BurnchainSigner> {
462462
None
463463
}
464464

465-
pub enum MinerStopReason {
466-
NoTransactions,
467-
Preempted,
468-
LimitReached,
469-
DeadlineReached,
470-
}
471-
472-
impl MinerStopReason {
473-
pub fn as_str(&self) -> &'static str {
474-
match self {
475-
MinerStopReason::NoTransactions => "no_transactions",
476-
MinerStopReason::Preempted => "preempted",
477-
MinerStopReason::LimitReached => "limit_reached",
478-
MinerStopReason::DeadlineReached => "deadline_reached",
479-
}
480-
}
481-
}
465+
define_named_enum!(MinerStopReason {
466+
NoTransactions("no_transactions"),
467+
Preempted("preempted"),
468+
LimitReached("limit_reached"),
469+
DeadlineReached("deadline_reached"),
470+
});
482471

483472
// Increment the counter for the given miner stop reason.
484473
#[allow(unused_variables)]
485474
pub fn increment_miner_stop_reason(reason: MinerStopReason) {
486475
#[cfg(feature = "monitoring_prom")]
487476
prometheus::MINER_STOP_REASON_TOTAL
488-
.with_label_values(&[reason.as_str()])
477+
.with_label_values(&[reason.get_name_str()])
489478
.inc();
490479
}
491480

0 commit comments

Comments
 (0)