uses enum for shred type
Current code is using u8 which does not have any type-safety and can contain invalid values: https://github.com/solana-labs/solana/blob/66fa062f1/ledger/src/shred.rs#L167 Checks for invalid shred-types are scattered through the code: https://github.com/solana-labs/solana/blob/66fa062f1/ledger/src/blockstore.rs#L849-L851 https://github.com/solana-labs/solana/blob/66fa062f1/ledger/src/shred.rs#L346-L348 The commit uses enum for shred type with #[repr(u8)]. Backward compatibility is maintained by implementing Serialize and Deserialize compatible with u8, and adding a test to assert that.
This commit is contained in:
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -5084,6 +5084,8 @@ dependencies = [
|
||||
"libc",
|
||||
"log 0.4.14",
|
||||
"matches",
|
||||
"num-derive",
|
||||
"num-traits",
|
||||
"num_cpus",
|
||||
"prost 0.9.0",
|
||||
"rand 0.7.3",
|
||||
|
Reference in New Issue
Block a user