Skip to content

Commit 6128913

Browse files
committed
refactor(encode block): simpler api
1 parent 0f10aef commit 6128913

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

rust/immutable-ledger/src/serialize.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ pub struct BlockHeaderSize(usize);
6161
#[derive(Debug, Clone, PartialEq)]
6262
pub struct EncodedBlockHeader(pub Vec<u8>);
6363

64-
/// Decoded block data
64+
/// Block data
6565
#[derive(Debug, Clone, PartialEq)]
66-
pub struct DecodedBlockData(Vec<u8>);
66+
pub struct BlockData(Vec<u8>);
6767

6868
/// Encoded block data as cbor
6969
#[derive(Debug, Clone, PartialEq)]
@@ -82,7 +82,7 @@ pub struct Signatures(Vec<Signature>);
8282
pub struct ValidatorKeys(pub Vec<[u8; SECRET_KEY_LENGTH]>);
8383

8484
/// Decoded block
85-
pub type DecodedBlock = (DecodedBlockHeader, DecodedBlockData, Signatures);
85+
pub type DecodedBlock = (DecodedBlockHeader, BlockData, Signatures);
8686

8787
/// Block header
8888
pub struct BlockHeader(
@@ -228,11 +228,7 @@ pub fn decode_block(encoded_block: &[u8]) -> anyhow::Result<DecodedBlock> {
228228
sigs.push(Signature::from_bytes(&sig));
229229
}
230230

231-
Ok((
232-
block_hdr,
233-
DecodedBlockData(block_data.to_vec()),
234-
Signatures(sigs),
235-
))
231+
Ok((block_hdr, BlockData(block_data.to_vec()), Signatures(sigs)))
236232
}
237233

238234
/// Produce BLAKE3 hash

0 commit comments

Comments
 (0)