Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@techvoyagerX
Copy link

Refactor log.rs for Enhanced Logging and Usability

Changes Made

  1. Refactored LogType conversion methods for better extensibility and clarity.
  2. Enhanced error handling in decode_ray_log to improve resilience against corrupted log data.
  3. Standardized documentation comments for all public structs and methods to align with codebase guidelines.
  4. Optimized serialization/deserialization processes to enhance performance.
  5. Added unit tests for encoding and decoding of logs to ensure functionality across all LogType variants.

Copy link
Contributor

@RainRaydium RainRaydium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. I thank the into_u8 function no need to change.Because this change will affect other files.
  2. Update pub fn encode_ray_log<T: Serialize>(log: &T) -> Result<String, &'static str> { as fn serialize_ray_log<T: Serialize>(log: &T) -> Result<String, &'static str> {
  3. Update pub fn log_ray_log<T: Serialize>(log: &T) { as pub fn encode_ray_log<T: Serialize>(log: &T) { to ensure the interface used externally remains unchanged.

}

pub fn into_u8(&self) -> u8 {
pub fn to_u8(&self) -> u8 {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function no need to change.Because this change will affect other files

LogType::Deposit => {
let log: DepositLog = bincode::deserialize(&bytes).unwrap();
println!("{:?}", log);
pub fn log_ray_log<T: Serialize>(log: &T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about use encode_ray_log for not affect other files.
And change pub fn encode_ray_log<T: Serialize>(log: &T) -> Result<String, &'static str> {
as serialize_ray_log?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants