Changed and refactored block and transaction structures. Moved signature from transaction scope to block.

This commit is contained in:
Revertron
2021-03-02 18:11:17 +01:00
parent d5a19c92c3
commit 92ebefce91
11 changed files with 206 additions and 215 deletions
-13
View File
@@ -74,19 +74,6 @@ pub fn hash_is_good(hash: &[u8], difficulty: usize) -> bool {
return hash_int < target;
}
/// Generates random string of given length
pub fn random_string(length: usize) -> String {
let chars: Vec<char> = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!?".chars().collect();
let mut rng = rand::thread_rng();
let mut result = String::with_capacity(length);
for _ in 0..length {
let position: usize = rng.gen::<usize>() % chars.len();
let c: char = *chars.get(position).unwrap();
result.push(c);
}
result
}
#[cfg(test)]
mod test {
use crate::check_domain;