general: snapshot

This commit is contained in:
k
2024-07-20 23:13:41 +02:00
parent d8a5b4a2e6
commit a145b35ad1
100 changed files with 5402 additions and 2967 deletions

View File

@@ -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;