compacted_map_key.rs

Overview

This file defines the structure and associated data for the CompactedMapKey type, which is a key entity used to uniquely identify a mapping related to blocks and attestations within the system. It encapsulates three key pieces of information: a block sequence number, a block identifier, and an attestation target type. These components collectively represent the context needed to access or manage compacted data maps relevant to block attestations.

Struct: CompactedMapKey

Definition

pub struct CompactedMapKey {
    block_seq_no: BlockSeqNo,
    block_identifier: BlockIdentifier,
    attestation_target_type: AttestationTargetType,
}

Purpose

CompactedMapKey serves as a composite key that uniquely identifies a compacted map entry by combining:

Derivations and Traits

The struct derives the following traits and macros:

Fields

Field Name

Type

Description

block_seq_no

BlockSeqNo

Numeric sequence of the block.

block_identifier

BlockIdentifier

Unique identifier for the block.

attestation_target_type

AttestationTargetType

Enum/type describing the kind of attestation target.

Methods

The file uses the derive_getters::Getters macro, which generates the following getter methods automatically:

Method Name

Returns

Description

block_seq_no(&self)

BlockSeqNo

Returns the block sequence number.

block_identifier(&self)

BlockIdentifier

Returns the block identifier.

attestation_target_type(&self)

AttestationTargetType

Returns the attestation target type.

Usage Example

use crate::types::{BlockIdentifier, BlockSeqNo};
use crate::node::associated_types::AttestationTargetType;
use compacted_map_key::CompactedMapKey;

let key = CompactedMapKey::builder()
    .block_seq_no(BlockSeqNo::from(42))
    .block_identifier(BlockIdentifier::new(/* params */))
    .attestation_target_type(AttestationTargetType::SomeType)
    .build();

println!("Block seq no: {:?}", key.block_seq_no());

Note: Construction uses the builder pattern provided by TypedBuilder, ensuring that all fields are set explicitly.

Implementation Details

Interaction With Other Components

Diagram

classDiagram
class CompactedMapKey {
-block_seq_no: BlockSeqNo
-block_identifier: BlockIdentifier
-attestation_target_type: AttestationTargetType
+block_seq_no()
+block_identifier()
+attestation_target_type()
}

This diagram illustrates the encapsulated fields and the public getter methods of the CompactedMapKey struct, emphasizing its role as a data holder with controlled access.