Trait forest_filecoin::shim::fvm_latest::kernel::IpldBlockOps
source · pub trait IpldBlockOps {
// Required methods
fn block_open(
&mut self,
cid: &Cid<64>,
) -> Result<(u32, BlockStat), ExecutionError>;
fn block_create(
&mut self,
codec: u64,
data: &[u8],
) -> Result<u32, ExecutionError>;
fn block_link(
&mut self,
id: u32,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid<64>, ExecutionError>;
fn block_read(
&self,
id: u32,
offset: u32,
buf: &mut [u8],
) -> Result<i32, ExecutionError>;
fn block_stat(&self, id: u32) -> Result<BlockStat, ExecutionError>;
}
Expand description
The IPLD subset of the kernel.
Required Methods§
sourcefn block_open(
&mut self,
cid: &Cid<64>,
) -> Result<(u32, BlockStat), ExecutionError>
fn block_open( &mut self, cid: &Cid<64>, ) -> Result<(u32, BlockStat), ExecutionError>
Open a block.
This method will fail if the requested block isn’t reachable.
sourcefn block_create(
&mut self,
codec: u64,
data: &[u8],
) -> Result<u32, ExecutionError>
fn block_create( &mut self, codec: u64, data: &[u8], ) -> Result<u32, ExecutionError>
Create a new block.
This method will fail if the block is too large (SPEC_AUDIT), the codec is not allowed (SPEC_AUDIT), the block references unreachable blocks, or the block contains too many links (SPEC_AUDIT).
sourcefn block_link(
&mut self,
id: u32,
hash_fun: u64,
hash_len: u32,
) -> Result<Cid<64>, ExecutionError>
fn block_link( &mut self, id: u32, hash_fun: u64, hash_len: u32, ) -> Result<Cid<64>, ExecutionError>
Computes a CID for a block.
This is the only way to add a new block to the “reachable” set.
This method will fail if the block handle is invalid.
sourcefn block_read(
&self,
id: u32,
offset: u32,
buf: &mut [u8],
) -> Result<i32, ExecutionError>
fn block_read( &self, id: u32, offset: u32, buf: &mut [u8], ) -> Result<i32, ExecutionError>
Read data from a block.
This method will fail if the block handle is invalid.
sourcefn block_stat(&self, id: u32) -> Result<BlockStat, ExecutionError>
fn block_stat(&self, id: u32) -> Result<BlockStat, ExecutionError>
Returns the blocks codec & size.
This method will fail if the block handle is invalid.