pub(crate) fn unpack_interlinks(extension: &ExtensionCandidate) -> Vec<BlockId> {
    let mut res = vec![];
    let entries = extension
        .fields
        .iter()
        .filter(|&(key, _)| key[0] == INTERLINK_VECTOR_PREFIX);
    for (_, bytes) in entries {
        // Each interlink is packed as [qty | blockId], which qty is a single-byte value
        // representing the number of duplicates of `blockId`. Every `BlockId` is 32 bytes which
        // implies that `bytes` is 33 bytes.
        assert_eq!(bytes.len(), 33);
        let qty = bytes[0];
        let block_id_bytes: [u8; 32] = bytes[1..].try_into().unwrap();
        let block_id = BlockId(Digest32::from(block_id_bytes));
        res.extend(std::iter::repeat(block_id).take(qty as usize));
    }
    res
}
/// Unpacks interlinks from key-value format of block extension.
Unpacks interlinks from key-value format of block extension.
Unpacks interlinks from key - value format of block extension .
pub(crate) fn unpack_interlinks(extension: &ExtensionCandidate) -> Vec<BlockId> {
    let mut res = vec![];
    let entries = extension
        .fields
        .iter()
        .filter(|&(key, _)| key[0] == INTERLINK_VECTOR_PREFIX);
    for (_, bytes) in entries {
        // Each interlink is packed as [qty | blockId], which qty is a single-byte value
        // representing the number of duplicates of `blockId`. Every `BlockId` is 32 bytes which
        // implies that `bytes` is 33 bytes.
        assert_eq!(bytes.len(), 33);
        let qty = bytes[0];
        let block_id_bytes: [u8; 32] = bytes[1..].try_into().unwrap();
        let block_id = BlockId(Digest32::from(block_id_bytes));
        res.extend(std::iter::repeat(block_id).take(qty as usize));
    }
    res
}
pub ( crate ) fn unpack_interlinks ( extension : & ExtensionCandidate ) -> Vec < BlockId > { let mut res = vec ! [ ] ; let entries = extension . fields . iter ( ) . filter ( | & ( key , _ ) | key [ 0 ] == INTERLINK_VECTOR_PREFIX ) ; for ( _ , bytes ) in entries { // Each interlink is packed as [qty | blockId], which qty is a single-byte value // representing the number of duplicates of `blockId`. Every `BlockId` is 32 bytes which // implies that `bytes` is 33 bytes. assert_eq ! ( bytes len ( ) 33 ) ; let qty = bytes [ 0 ] ; let block_id_bytes : [ u8 ; 32 ] = bytes [ 1 .. ] . try_into ( ) . unwrap ( ) ; let block_id = BlockId ( Digest32 :: from ( block_id_bytes ) ) ; res . extend ( std :: iter :: repeat ( block_id ) . take ( qty as usize ) ) ; } res }
Unpacks interlinks from key-value format of block extension.
Unpacks interlinks from key - value format of block extension .
extension
&ExtensionCandidate
extension
&ExtensionCandidate