mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-24 06:39:58 -07:00
35 lines
783 B
Rust
35 lines
783 B
Rust
use std::ops::{Add, AddAssign, SubAssign};
|
|
|
|
use brk_types::{CentsUnsigned, SupplyState, Timestamp};
|
|
use serde::Serialize;
|
|
|
|
#[derive(Debug, Clone, Serialize)]
|
|
pub struct BlockState {
|
|
#[serde(flatten)]
|
|
pub supply: SupplyState,
|
|
#[serde(skip)]
|
|
pub price: Option<CentsUnsigned>,
|
|
#[serde(skip)]
|
|
pub timestamp: Timestamp,
|
|
}
|
|
|
|
impl Add<BlockState> for BlockState {
|
|
type Output = Self;
|
|
fn add(mut self, rhs: BlockState) -> Self::Output {
|
|
self.supply += &rhs.supply;
|
|
self
|
|
}
|
|
}
|
|
|
|
impl AddAssign<&BlockState> for BlockState {
|
|
fn add_assign(&mut self, rhs: &Self) {
|
|
self.supply += &rhs.supply;
|
|
}
|
|
}
|
|
|
|
impl SubAssign<&BlockState> for BlockState {
|
|
fn sub_assign(&mut self, rhs: &Self) {
|
|
self.supply -= &rhs.supply;
|
|
}
|
|
}
|