Remove IncrementalInput and fix wasm storage_into* (#3224)

This commit is contained in:
Bastian Köcher
2019-07-29 10:44:40 +02:00
committed by thiolliere
parent 852ed92861
commit 9303b9b7df
4 changed files with 20 additions and 56 deletions
+3 -3
View File
@@ -411,7 +411,7 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
let written = std::cmp::min(value_len as usize, value.len());
this.memory.set(value_data, &value[..written])
.map_err(|_| "Invalid attempt to set value in ext_get_storage_into")?;
Ok(written as u32)
Ok(value.len() as u32)
} else {
Ok(u32::max_value())
}
@@ -458,10 +458,10 @@ impl_function_executor!(this: FunctionExecutor<'e, E>,
if let Some(value) = maybe_value {
let value = &value[value_offset as usize..];
let written = ::std::cmp::min(value_len as usize, value.len());
let written = std::cmp::min(value_len as usize, value.len());
this.memory.set(value_data, &value[..written])
.map_err(|_| "Invalid attempt to set value in ext_get_child_storage_into")?;
Ok(written as u32)
Ok(value.len() as u32)
} else {
Ok(u32::max_value())
}
+10 -8
View File
@@ -104,16 +104,18 @@ export_api! {
/// Get `key` from child storage and return a `Vec`, empty if there's a problem.
fn child_storage(storage_key: &[u8], key: &[u8]) -> Option<Vec<u8>>;
/// Get `key` from storage, placing the value into `value_out` (as much of it as possible) and return
/// the number of bytes that the entry in storage had beyond the offset or None if the storage entry
/// doesn't exist at all. Note that if the buffer is smaller than the storage entry length, the returned
/// number of bytes is not equal to the number of bytes written to the `value_out`.
/// Get `key` from storage, placing the value into `value_out` and return the number of
/// bytes that the entry in storage has beyond the offset or `None` if the storage entry
/// doesn't exist at all.
/// If `value_out` length is smaller than the returned length, only `value_out` length bytes
/// are copied into `value_out`.
fn read_storage(key: &[u8], value_out: &mut [u8], value_offset: usize) -> Option<usize>;
/// Get `key` from child storage, placing the value into `value_out` (as much of it as possible) and return
/// the number of bytes that the entry in storage had beyond the offset or None if the storage entry
/// doesn't exist at all. Note that if the buffer is smaller than the storage entry length, the returned
/// number of bytes is not equal to the number of bytes written to the `value_out`.
/// Get `key` from child storage, placing the value into `value_out` and return the number
/// of bytes that the entry in storage has beyond the offset or `None` if the storage entry
/// doesn't exist at all.
/// If `value_out` length is smaller than the returned length, only `value_out` length bytes
/// are copied into `value_out`.
fn read_child_storage(storage_key: &[u8], key: &[u8], value_out: &mut [u8], value_offset: usize) -> Option<usize>;
/// Set the storage of some particular key to Some value.