mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-19 22:08:30 +00:00
Update SSZ
- Implement generic list decoding> - Expose `encode` mod. - Add convenience encoding function.
This commit is contained in:
@@ -11,8 +11,8 @@ extern crate bytes;
|
||||
extern crate ethereum_types;
|
||||
|
||||
pub mod decode;
|
||||
pub mod encode;
|
||||
|
||||
mod encode;
|
||||
mod impl_encode;
|
||||
mod impl_decode;
|
||||
|
||||
@@ -29,3 +29,13 @@ pub use encode::{
|
||||
|
||||
pub const LENGTH_BYTES: usize = 4;
|
||||
pub const MAX_LIST_SIZE : usize = 1 << (4 * 8);
|
||||
|
||||
|
||||
/// Convenience function to SSZ encode an object supporting ssz::Encode.
|
||||
pub fn ssz_encode<T>(val: &T) -> Vec<u8>
|
||||
where T: Encodable
|
||||
{
|
||||
let mut ssz_stream = SszStream::new();
|
||||
ssz_stream.append(val);
|
||||
ssz_stream.drain()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user