Skip to content

Commit

Permalink
Revert to raw encoding for non-list entries
Browse files Browse the repository at this point in the history
  • Loading branch information
AgeManning committed May 31, 2024
1 parent 12b3bc7 commit f1edf47
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1041,12 +1041,19 @@ impl<K: EnrKey> Decodable for Enr<K> {
_ => {
let other_header = Header::decode(payload)?;
let value = &payload[..other_header.payload_length];
// Preserve the valid encoding
payload.advance(other_header.payload_length);
let mut out = Vec::<u8>::new();
other_header.encode(&mut out);
out.extend_from_slice(value);
out

// Encode the header for list values, for non-list objects, we remove the
// header for compatibility with commonly used key entries (i.e its the
// current convention).
if other_header.list {
let mut out = Vec::<u8>::new();
other_header.encode(&mut out);
out.extend_from_slice(value);
out
} else {
alloy_rlp::encode(value)
}
}
};
content.insert(key.to_vec(), Bytes::from(value));
Expand Down

0 comments on commit f1edf47

Please sign in to comment.