-
Notifications
You must be signed in to change notification settings - Fork 134
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
247 additions
and
281 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,23 @@ | ||
use ssz_types::{typenum, VariableList}; | ||
use ssz_types::{ | ||
typenum::{self, UInt, UTerm, B0, B1}, | ||
VariableList, | ||
}; | ||
|
||
// 1100 in binary is 10001001100 | ||
pub type U1100 = UInt< | ||
UInt< | ||
UInt< | ||
UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B1>, B0>, B0>, B1>, | ||
B1, | ||
>, | ||
B0, | ||
>, | ||
B0, | ||
>; | ||
|
||
pub type ByteList32 = VariableList<u8, typenum::U32>; | ||
pub type ByteList1024 = VariableList<u8, typenum::U1024>; | ||
pub type ByteList1100 = VariableList<u8, U1100>; | ||
pub type ByteList2048 = VariableList<u8, typenum::U2048>; | ||
pub type ByteList32K = VariableList<u8, typenum::U32768>; | ||
pub type ByteList1G = VariableList<u8, typenum::U1073741824>; |
77 changes: 0 additions & 77 deletions
77
crates/ethportal-api/src/types/ping_extensions/custom_payload_format.rs
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
crates/ethportal-api/src/types/ping_extensions/extension_types.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#[derive(PartialEq, Debug, Clone, Copy, Eq)] | ||
pub enum Extensions { | ||
Capabilities, | ||
BasicRadius, | ||
HistoryRadius, | ||
Error, | ||
} | ||
|
||
impl TryFrom<u16> for Extensions { | ||
type Error = ExtensionError; | ||
|
||
fn try_from(value: u16) -> Result<Self, ExtensionError> { | ||
match value { | ||
0 => Ok(Extensions::Capabilities), | ||
1 => Ok(Extensions::BasicRadius), | ||
2 => Ok(Extensions::HistoryRadius), | ||
65535 => Ok(Extensions::Error), | ||
_ => Err(ExtensionError::NonSupportedExtension(value)), | ||
} | ||
} | ||
} | ||
|
||
impl From<Extensions> for u16 { | ||
fn from(value: Extensions) -> u16 { | ||
match value { | ||
Extensions::Capabilities => 0, | ||
Extensions::BasicRadius => 1, | ||
Extensions::HistoryRadius => 2, | ||
Extensions::Error => 65535, | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub enum ExtensionError { | ||
NonSupportedExtension(u16), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.