Trait ProtocolUpdateBatchGroupGenerator

Source
pub trait ProtocolUpdateBatchGroupGenerator<'a> {
    // Required methods
    fn batch_group_name(&self) -> &'static str;
    fn generate_batches(
        self: Box<Self>,
        store: &dyn SubstateDatabase,
    ) -> Vec<Box<dyn ProtocolUpdateBatchGenerator + 'a>>;
}
Expand description

Each batch group is a logical grouping of batches.

For example, at genesis, there are three batch groups:

  • "bootstrap" (flash + bootstrap transaction)
  • "chunks"
  • "wrap-up"
  • The node also adds a "scenarios" batch group.

Required Methods§

Source

fn batch_group_name(&self) -> &'static str

This is &'static because batch groups are intended to be fixed conceptual steps in the protocol update.

The batch-group name should be kebab-case for consistency.

Source

fn generate_batches( self: Box<Self>, store: &dyn SubstateDatabase, ) -> Vec<Box<dyn ProtocolUpdateBatchGenerator + 'a>>

The content of these batches must be fully reproducible from the state of the store before any updates were committed. This is why we return an array of batch generators.

If a protocol update needs to do some complicated/inline batch updates to substates, you may need to:

  • Have a first batch group where the planned work is saved batch-by-batch to some special partition
  • Have a second batch group where the planned work is performed, by reading from this special partition
  • Have a third batch group where the planned work is deleted

Implementors§