aleph-bft 0.45.4

AlephBFT is an asynchronous and Byzantine fault tolerant consensus protocol aimed at ordering arbitrary messages (transactions). It has been designed to continuously operate even in the harshest conditions: with no bounds on message-delivery delays and in the presence of malicious actors. This makes it an excellent fit for blockchain-related applications.
Documentation
use crate::{
    units::{FullUnit, PreUnit, SignedUnit},
    Data, Hasher, MultiKeychain, SessionId, Signed,
};

/// The component responsible for packing Data into PreUnits,
/// and signing the outcome, thus creating SignedUnits that are sent back to consensus.
pub struct Packer<MK: MultiKeychain> {
    keychain: MK,
    session_id: SessionId,
}

impl<MK: MultiKeychain> Packer<MK> {
    pub fn new(keychain: MK, session_id: SessionId) -> Self {
        Packer {
            keychain,
            session_id,
        }
    }

    pub fn pack<H: Hasher, D: Data>(
        &self,
        preunit: PreUnit<H>,
        data: Option<D>,
    ) -> SignedUnit<H, D, MK> {
        Signed::sign(
            FullUnit::new(preunit, data, self.session_id),
            &self.keychain,
        )
    }
}