Skip to content

Commit

Permalink
Merge pull request #631 from SaitoTech/feature/613/atr
Browse files Browse the repository at this point in the history
ATR #613
  • Loading branch information
SankaD authored Jan 31, 2024
2 parents be939fc + 2b6f6fc commit de225ca
Show file tree
Hide file tree
Showing 31 changed files with 1,046 additions and 1,027 deletions.
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions saito-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ criterion = { version = "0.5.1", features = ["default", "html_reports"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[features]
default = []
locking-logs = []
with-stats = []
with-rayon = []
Expand Down
55 changes: 30 additions & 25 deletions saito-core/src/common/defs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ pub const NOLAN_PER_SAITO: Currency = 100_000_000;

pub const PROJECT_PUBLIC_KEY: &'static str = "q6TTBeSStCLXEPoS5TUVAxNiGGnRDZQenpvAXXAfTmtA";

#[cfg(test)]
// length of 1 genesis period
pub const GENESIS_PERIOD: u64 = 10;

#[cfg(not(test))]
pub const GENESIS_PERIOD: u64 = 100_000;

// prune blocks from index after N blocks
pub const PRUNE_AFTER_BLOCKS: u64 = 8;
// max recursion when paying stakers -- number of blocks including -- number of blocks including GTT
Expand Down Expand Up @@ -73,7 +78,7 @@ impl Drop for LockGuardWatcher {
LOCK_ORDER.with(|v| {
let mut v = v.borrow_mut();
let res = v.pop_back();
println!("releasing lock : {:?}", self.order);
// println!("releasing lock : {:?}", self.order);
assert!(
res.is_some(),
"no existing locks found for lock : {:?}",
Expand Down Expand Up @@ -111,22 +116,22 @@ pub fn push_lock(order: u8) -> LockGuardWatcher {
#[macro_export]
macro_rules! lock_for_write {
($lock:expr, $order:expr) => {{
#[cfg(feature = "locking-logs")]
println!(
"waiting for lock : {:?} for writing - {:?}",
$order,
module_path!()
);
// #[cfg(feature = "locking-logs")]
// println!(
// "waiting for lock : {:?} for writing - {:?}",
// $order,
// module_path!()
// );

let l = $lock.write().await;
let watcher = push_lock($order);

#[cfg(feature = "locking-logs")]
println!(
"acquired lock : {:?} for writing - {:?}",
$order,
module_path!()
);
// #[cfg(feature = "locking-logs")]
// println!(
// "acquired lock : {:?} for writing - {:?}",
// $order,
// module_path!()
// );

(l, watcher)
}};
Expand All @@ -135,22 +140,22 @@ macro_rules! lock_for_write {
#[macro_export]
macro_rules! lock_for_read {
($lock:expr, $order:expr) => {{
#[cfg(feature = "locking-logs")]
println!(
"waiting for lock : {:?} for reading - {:?}",
$order,
module_path!()
);
// #[cfg(feature = "locking-logs")]
// println!(
// "waiting for lock : {:?} for reading - {:?}",
// $order,
// module_path!()
// );

let l = $lock.read().await;
let watcher = push_lock($order);

#[cfg(feature = "locking-logs")]
println!(
"acquired lock : {:?} for reading - {:?}",
$order,
module_path!()
);
// #[cfg(feature = "locking-logs")]
// println!(
// "acquired lock : {:?} for reading - {:?}",
// $order,
// module_path!()
// );

(l, watcher)
}};
Expand Down
5 changes: 2 additions & 3 deletions saito-core/src/common/test_io_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ pub mod test {
key.to_string(),
result.err().unwrap()
);
todo!()
unreachable!()
}
let mut file = result.unwrap();
let mut encoded = Vec::<u8>::new();

let result = file.read_to_end(&mut encoded).await;
if result.is_err() {
todo!()
unreachable!()
}
Ok(encoded)
}
Expand Down 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
Loading

0 comments on commit de225ca

Please sign in to comment.