pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult<H256> {
    let state_path = format!(
        "{}/{}/{}",
        SHARDS_PATH,
        shard.encode().to_base58(),
        ENCRYPTED_STATE_FILE
    );
    trace!("writing state to: {}", state_path);

    // only save the state, the state diff is pruned
    let cyphertext = encrypt(state.state.encode())?;

    let state_hash = match rsgx_sha256_slice(&cyphertext) {
        Ok(h) => h,
        Err(status) => return Err(status),
    };

    debug!(
        "new encrypted state with hash=0x{} written to {}",
        hex::encode_hex(&state_hash),
        state_path
    );

    io::write(&cyphertext, &state_path)?;
    Ok(state_hash.into())
}
/// Writes the state (without the state diff) encrypted into the enclave storage
// Returns the hash of the saved state (independent of the diff!)
Writes the state (without the state diff) encrypted into the enclave storage
Returns the hash of the saved state (independent of the diff!)
Writes the state ( without the state diff ) encrypted into the enclave storage Returns the hash of the saved state ( independent of the diff! )
pub fn write(state: StfState, shard: &ShardIdentifier) -> SgxResult<H256> {
    let state_path = format!(
        "{}/{}/{}",
        SHARDS_PATH,
        shard.encode().to_base58(),
        ENCRYPTED_STATE_FILE
    );
    trace!("writing state to: {}", state_path);
    // only save the state, the state diff is pruned
    let cyphertext = encrypt(state.state.encode())?;
    let state_hash = match rsgx_sha256_slice(&cyphertext) {
        Ok(h) => h,
        Err(status) => return Err(status),
    };
    debug!(
        "new encrypted state with hash=0x{} written to {}",
        hex::encode_hex(&state_hash),
        state_path
    );
    io::write(&cyphertext, &state_path)?;
    Ok(state_hash.into())
}
pub fn write ( state : StfState , shard : & ShardIdentifier ) -> SgxResult < H256 > { let state_path = format ! ( " " SHARDS_PATH shard encode ( ) to_base58 ( ) ENCRYPTED_STATE_FILE ) ; trace ! ( " " state_path ) ; // only save the state, the state diff is pruned let cyphertext = encrypt ( state . state . encode ( ) ) ? ; let state_hash = match rsgx_sha256_slice ( & cyphertext ) { Ok ( h ) => h , Err ( status ) => return Err ( status ) , } ; debug ! ( " " hex encode_hex ( state_hash ) state_path ) ; io :: write ( & cyphertext , & state_path ) ? ; Ok ( state_hash . into ( ) ) }
Writes the state (without the state diff) encrypted into the enclave storage
Returns the hash of the saved state (independent of the diff!)
Writes the state ( without the state diff ) encrypted into the enclave storage Returns the hash of the saved state ( independent of the diff! )
state
StfState
shard
&ShardIdentifier
state
StfState
shard
&ShardIdentifier