Secure and Efficient Open-Source Blockchain Identity System in Rust

Subject: Feedback Request on Project Dependencies and Code Structure

Hi everyone,

I wanted to reach out to the community here for feedback on my project. If this isn't the right place for such a post, please let me know, and I'll remove my message immediately.

I'm currently working on optimizing my project for best practices as well as efficiency and stability. The goal is to make it completely industry standard. I've chosen certain dependencies and set them up with specific versions, and I'm looking for input on these choices. The structure of the code is also something I'd like to get feedback on.

You can find my project here: https://github.com/grasshaussoftware/cryptographic-data-registration/tree/main

Any positive feedback is greatly appreciated, and I'm open to constructive criticism as well. I'm looking to improve, so please keep any feedback productive.

Thank you!

deusopus

Here are a few quick observations:

  • Have you considered the console crate? It makes getting user input and setting up prompts a lot simpler than having to build a bunch of print statements and variables.

  • You should also look into the anyhow crate for binaries when handling errors and error conversions.

  • Why are you defining the get_chronos function within the loop within main?

  • It appears that you loop over the input, then break after one iteration, rendering the loop useless.

  • Using if let Some in the get_current_block_hash is a bit clunky since you need to still handle the error cases. Using something like a match here would be more clear. You could even do it functionally using ok_or_else and and_then.

For your hash_to_hex function, you can use a functional approach:

fn hash_to_hex(hash: [u8; 32]) -> String {
    hash.iter().map(|byte| format!("{:02x}", byte)).collect()
}

It may also be more clear to define a newtype for the hash here, or use a crate that defines proper has types.

  • All of this code should not be in a single main function.

Hope this is helpful.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.