self.epoch_position() % self.epoch().subsidy()
}
pub(crate) fn epoch_position(self) -> u64 {
self.0 - self.epoch().starting_sat().0
}
pub(crate) fn decimal(self) -> Decimal {
self.into()
}
pub(crate) fn rarity(self) -> Rarity {
self.into()
}
/// `Sat::rarity` is expensive and is called frequently when indexing.
/// Sat::is_common only checks if self is `Rarity::Common` but is
/// much faster.
pub(crate) fn is_common(self) -> bool {
let epoch = self.epoch();
(self.0 - epoch.starting_sat().0) % epoch.subsidy() != 0
}
pub(crate) fn name(self) -> String {
let mut x = Self::SUPPLY - self.0;
let mut name = String::new();
while x > 0 {
name.push(
"abcdefghijklmnopqrstuvwxyz"
.chars()
.nth(((x - 1) % 26) as usize)
.unwrap(),
);
x = (x - 1) / 26;
}
name.chars().rev().collect()
}
fn from_name(s: &str) -> Result<Self> {
let mut x = 0;
for c in s.chars() {
match c {
'a'..='z' => {