mirror of
https://github.com/bitcoinresearchkit/brk.git
synced 2026-04-25 23:29:58 -07:00
general: snapshot
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
use allocative::Allocative;
|
||||
use bincode::{Decode, Encode};
|
||||
|
||||
use super::{Price, WAmount};
|
||||
use super::{Amount, Height, Price};
|
||||
|
||||
#[derive(Debug, Encode, Decode, Allocative)]
|
||||
pub struct BlockData {
|
||||
pub height: u32,
|
||||
pub height: Height,
|
||||
pub price: Price,
|
||||
pub timestamp: u32,
|
||||
pub amount: WAmount,
|
||||
pub amount: Amount,
|
||||
pub utxos: u32,
|
||||
}
|
||||
|
||||
impl BlockData {
|
||||
pub fn new(height: u32, price: Price, timestamp: u32) -> Self {
|
||||
pub fn new(height: Height, price: Price, timestamp: u32) -> Self {
|
||||
Self {
|
||||
height,
|
||||
price,
|
||||
timestamp,
|
||||
amount: WAmount::ZERO,
|
||||
amount: Amount::ZERO,
|
||||
utxos: 0,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send(&mut self, amount: WAmount) {
|
||||
pub fn send(&mut self, amount: Amount) {
|
||||
self.utxos -= 1;
|
||||
|
||||
if self.amount < amount {
|
||||
@@ -33,7 +33,7 @@ impl BlockData {
|
||||
self.amount -= amount;
|
||||
}
|
||||
|
||||
pub fn receive(&mut self, amount: WAmount) {
|
||||
pub fn receive(&mut self, amount: Amount) {
|
||||
self.utxos += 1;
|
||||
|
||||
self.amount += amount;
|
||||
|
||||
Reference in New Issue
Block a user