pub trait CellDataProvider {
    // Required methods
    fn get_cell_data(&self, out_point: &OutPoint) -> Option<Bytes>;
    fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32>;

    // Provided methods
    fn load_cell_data(&self, cell: &CellMeta) -> Option<Bytes> { ... }
    fn load_cell_data_hash(&self, cell: &CellMeta) -> Option<Byte32> { ... }
}
Expand description

Trait for cell_data storage

Required Methods§

source

fn get_cell_data(&self, out_point: &OutPoint) -> Option<Bytes>

Fetch cell_data from storage

source

fn get_cell_data_hash(&self, out_point: &OutPoint) -> Option<Byte32>

Fetch cell_data_hash from storage, please note that loading a large amount of cell data and calculating hash may be a performance bottleneck, so here is a separate fn designed to facilitate caching.

In unit test or other scenarios that are not performance bottlenecks, you may use the results of get_cell_data to calculate hash as a default implementation: self.get_cell_data(out_point).map(|data| CellOutput::calc_data_hash(&data))

Provided Methods§

source

fn load_cell_data(&self, cell: &CellMeta) -> Option<Bytes>

Load cell_data from memory, fallback to storage access

source

fn load_cell_data_hash(&self, cell: &CellMeta) -> Option<Byte32>

Load cell_data_hash from memory, fallback to storage access

Implementors§