Skip to content

Commit

Permalink
ATR #613
Browse files Browse the repository at this point in the history
implemented calculation and validation of avg_fee_per_byte for blocks
  • Loading branch information
SankaD committed Jan 18, 2024
1 parent f487c35 commit bad8cdc
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 82 deletions.
1 change: 0 additions & 1 deletion saito-core/src/common/test_io_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,6 @@ pub mod test {
// async fn save_blockchain(&self) -> Result<(), Error> {
// todo!()
// }
//
// async fn load_blockchain(&self) -> Result<(), Error> {
// todo!()
// }
Expand Down
21 changes: 2 additions & 19 deletions saito-core/src/common/test_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,7 @@ pub mod test {
.expect("mining event receive failed");
}

//
// add block to blockchain
//
/// add block to blockchain
pub async fn add_block(&mut self, block: Block) {
debug!("adding block to test manager blockchain");

Expand All @@ -229,7 +227,6 @@ pub mod test {
}
}

//
// check that the blockchain connects properly
//
pub async fn check_blockchain(&self) {
Expand Down Expand Up @@ -263,7 +260,6 @@ pub mod test {
}
}

//
// check that everything spendable in the main UTXOSET is spendable on the longest
// chain and vice-versa.
//
Expand Down Expand Up @@ -497,9 +493,7 @@ pub mod test {
}
}

//
// create block
//
pub async fn create_block(
&mut self,
parent_hash: SaitoHash,
Expand Down Expand Up @@ -571,9 +565,8 @@ pub mod test {
let (configs, _configs_) = lock_for_read!(self.configs, LOCK_ORDER_CONFIGS);
let (mut blockchain, _blockchain_) =
lock_for_write!(self.blockchain_lock, LOCK_ORDER_BLOCKCHAIN);
//

// create block
//
let mut block = Block::create(
&mut transactions,
parent_hash,
Expand Down Expand Up @@ -664,7 +657,6 @@ pub mod test {
.await;
}

//
// initialize chain from slips and add some amount my public key
//
pub async fn initialize_from_slips_and_value(&mut self, slips: Vec<Slip>, amount: u64) {
Expand Down Expand Up @@ -721,7 +713,6 @@ pub mod test {
self.add_block(block).await;
}

//
// initialize chain from just slips properties
pub async fn initialize_from_slips(&mut self, slips: Vec<Slip>) {
//
Expand Down Expand Up @@ -789,17 +780,13 @@ pub mod test {
// initialize timestamp
//

//
// reset data dirs
//
let _ = tokio::fs::remove_dir_all("data/blocks").await;
tokio::fs::create_dir_all("data/blocks").await.unwrap();
let _ = tokio::fs::remove_dir_all("data/wallets").await;
tokio::fs::create_dir_all("data/wallets").await.unwrap();

//
// create initial transactions
//
let private_key: SaitoPrivateKey;
let public_key: SaitoPublicKey;
{
Expand All @@ -809,14 +796,10 @@ pub mod test {
private_key = wallet.private_key;
}

//
// create first block
//
let mut block = self.create_block([0; 32], timestamp, 0, 0, 0, false).await;

//
// generate UTXO-carrying VIP transactions
//
for _i in 0..vip_transactions {
let mut tx = Transaction::create_vip_transaction(public_key, vip_amount);
tx.generate(&public_key, 0, 0);
Expand Down
Loading

0 comments on commit bad8cdc

Please sign in to comment.