Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update bitflags from 0.9 to 1.2 #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ version = "0.1.0"
authors = ["Parity Technologies <[email protected]>"]

[dependencies]
bitflags = "0.9"
bitflags = "1.2"
byteorder = "1.0.0"
ethereum-types = "0.6.0"
ethcore-network = { git = "https://github.com/paritytech/parity-ethereum.git" }
Expand Down
18 changes: 9 additions & 9 deletions src/rpc/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,10 @@ bitflags! {

// number of bytes of padding length (in the range 0..4)
fn padding_length_bytes(flags: Flags) -> usize {
match (flags & FLAG_PAD_LEN_HIGH, flags & FLAG_PAD_LEN_LOW) {
(FLAG_PAD_LEN_HIGH, FLAG_PAD_LEN_LOW) => 3,
(FLAG_PAD_LEN_HIGH, _) => 2,
(_, FLAG_PAD_LEN_LOW) => 1,
match (flags & Flags::FLAG_PAD_LEN_HIGH, flags & Flags::FLAG_PAD_LEN_LOW) {
(Flags::FLAG_PAD_LEN_HIGH, Flags::FLAG_PAD_LEN_LOW) => 3,
(Flags::FLAG_PAD_LEN_HIGH, _) => 2,
(_, Flags::FLAG_PAD_LEN_LOW) => 1,
(_, _) => 0,
}
}
Expand Down Expand Up @@ -136,7 +136,7 @@ pub fn encode(params: EncodeParams) -> Result<Vec<u8>, &'static str> {

if let Some(ref sig) = signature {
plaintext_size += sig.len();
flags |= FLAG_SIGNED;
flags |= Flags::FLAG_SIGNED;
}

(flags, plaintext_size)
Expand Down Expand Up @@ -202,7 +202,7 @@ pub fn decode(payload: &[u8]) -> Result<Decoded, &'static str> {
None
};

let signature = if flags & FLAG_SIGNED == FLAG_SIGNED {
let signature = if flags & Flags::FLAG_SIGNED == Flags::FLAG_SIGNED {
let slice = next_slice(SIGNATURE_LEN)?;
let mut arr = [0; SIGNATURE_LEN];

Expand Down Expand Up @@ -252,9 +252,9 @@ mod tests {
fn padding_len_bytes_sanity() {
const U24_MAX: usize = (1 << 24) - 1;

assert_eq!(padding_length_bytes(FLAG_PAD_LEN_HIGH | FLAG_PAD_LEN_LOW), 3);
assert_eq!(padding_length_bytes(FLAG_PAD_LEN_HIGH), 2);
assert_eq!(padding_length_bytes(FLAG_PAD_LEN_LOW), 1);
assert_eq!(padding_length_bytes(Flags::FLAG_PAD_LEN_HIGH | Flags::FLAG_PAD_LEN_LOW), 3);
assert_eq!(padding_length_bytes(Flags::FLAG_PAD_LEN_HIGH), 2);
assert_eq!(padding_length_bytes(Flags::FLAG_PAD_LEN_LOW), 1);
assert_eq!(padding_length_bytes(Flags::empty()), 0);

assert!(num_padding_length_bytes(u32::max_value() as _).is_none());
Expand Down