Rename: primitives/sr-io -> primitives/sp-io (#4328)

* primitives/sr-io -> primitives/io

* fix

* rename

* runtime-io -> sp-io

* git mv

* fix ci

* remove package name

* fix

* fix

* try minimizing diff

* try minimizing diff again

* try minimizing diff again
This commit is contained in:
Weiliang Li
2019-12-11 00:08:35 +09:00
committed by Bastian Köcher
parent 1f84d6d41d
commit 4f2cdb20c1
134 changed files with 312 additions and 315 deletions
+7 -7
View File
@@ -26,7 +26,7 @@ use codec::{Codec, Encode, Decode};
/// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
pub fn get<T: Decode + Sized>(storage_key: &[u8], key: &[u8]) -> Option<T> {
runtime_io::storage::child_get(storage_key, key).and_then(|v| {
sp_io::storage::child_get(storage_key, key).and_then(|v| {
Decode::decode(&mut &v[..]).map(Some).unwrap_or_else(|_| {
// TODO #3700: error should be handleable.
runtime_print!("ERROR: Corrupted state in child trie at {:?}/{:?}", storage_key, key);
@@ -59,7 +59,7 @@ pub fn get_or_else<T: Decode + Sized, F: FnOnce() -> T>(
/// Put `value` in storage under `key`.
pub fn put<T: Encode>(storage_key: &[u8], key: &[u8], value: &T) {
value.using_encoded(|slice| runtime_io::storage::child_set(storage_key, key, slice));
value.using_encoded(|slice| sp_io::storage::child_set(storage_key, key, slice));
}
/// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise.
@@ -95,25 +95,25 @@ pub fn take_or_else<T: Codec + Sized, F: FnOnce() -> T>(
/// Check to see if `key` has an explicit entry in storage.
pub fn exists(storage_key: &[u8], key: &[u8]) -> bool {
runtime_io::storage::child_read(storage_key, key, &mut [0;0][..], 0).is_some()
sp_io::storage::child_read(storage_key, key, &mut [0;0][..], 0).is_some()
}
/// Remove all `storage_key` key/values
pub fn kill_storage(storage_key: &[u8]) {
runtime_io::storage::child_storage_kill(storage_key)
sp_io::storage::child_storage_kill(storage_key)
}
/// Ensure `key` has no explicit entry in storage.
pub fn kill(storage_key: &[u8], key: &[u8]) {
runtime_io::storage::child_clear(storage_key, key);
sp_io::storage::child_clear(storage_key, key);
}
/// Get a Vec of bytes from storage.
pub fn get_raw(storage_key: &[u8], key: &[u8]) -> Option<Vec<u8>> {
runtime_io::storage::child_get(storage_key, key)
sp_io::storage::child_get(storage_key, key)
}
/// Put a raw byte slice into storage.
pub fn put_raw(storage_key: &[u8], key: &[u8], value: &[u8]) {
runtime_io::storage::child_set(storage_key, key, value)
sp_io::storage::child_set(storage_key, key, value)
}
@@ -35,7 +35,7 @@ pub use value::StorageValue;
#[cfg(test)]
#[allow(dead_code)]
mod tests {
use runtime_io::TestExternalities;
use sp_io::TestExternalities;
use codec::{Encode, Decode};
use crate::storage::{unhashed, generator::{StorageValue, StorageLinkedMap}};
+3 -3
View File
@@ -364,7 +364,7 @@ impl<Value: Decode> Iterator for PrefixIterator<Value> {
type Item = Value;
fn next(&mut self) -> Option<Self::Item> {
match runtime_io::storage::next_key(&self.previous_key) {
match sp_io::storage::next_key(&self.previous_key) {
Some(next_key) if next_key.starts_with(&self.prefix[..]) => {
let value = unhashed::get(&next_key);
@@ -406,7 +406,7 @@ pub trait StoragePrefixedMap<Value: FullCodec> {
}
fn remove_all() {
runtime_io::storage::clear_prefix(&Self::final_prefix())
sp_io::storage::clear_prefix(&Self::final_prefix())
}
fn iter() -> PrefixIterator<Value> {
@@ -422,7 +422,7 @@ pub trait StoragePrefixedMap<Value: FullCodec> {
#[cfg(test)]
mod test {
use primitives::hashing::twox_128;
use runtime_io::TestExternalities;
use sp_io::TestExternalities;
use crate::storage::{unhashed, StoragePrefixedMap};
#[test]
@@ -21,7 +21,7 @@ use codec::{Encode, Decode};
/// Return the value of the item in storage under `key`, or `None` if there is no explicit entry.
pub fn get<T: Decode + Sized>(key: &[u8]) -> Option<T> {
runtime_io::storage::get(key).and_then(|val| {
sp_io::storage::get(key).and_then(|val| {
Decode::decode(&mut &val[..]).map(Some).unwrap_or_else(|_| {
// TODO #3700: error should be handleable.
runtime_print!("ERROR: Corrupted state at {:?}", key);
@@ -50,7 +50,7 @@ pub fn get_or_else<T: Decode + Sized, F: FnOnce() -> T>(key: &[u8], default_valu
/// Put `value` in storage under `key`.
pub fn put<T: Encode + ?Sized>(key: &[u8], value: &T) {
value.using_encoded(|slice| runtime_io::storage::set(key, slice));
value.using_encoded(|slice| sp_io::storage::set(key, slice));
}
/// Remove `key` from storage, returning its value if it had an explicit entry or `None` otherwise.
@@ -82,25 +82,25 @@ pub fn take_or_else<T: Decode + Sized, F: FnOnce() -> T>(key: &[u8], default_val
/// Check to see if `key` has an explicit entry in storage.
pub fn exists(key: &[u8]) -> bool {
runtime_io::storage::read(key, &mut [0;0][..], 0).is_some()
sp_io::storage::read(key, &mut [0;0][..], 0).is_some()
}
/// Ensure `key` has no explicit entry in storage.
pub fn kill(key: &[u8]) {
runtime_io::storage::clear(key);
sp_io::storage::clear(key);
}
/// Ensure keys with the given `prefix` have no entries in storage.
pub fn kill_prefix(prefix: &[u8]) {
runtime_io::storage::clear_prefix(prefix);
sp_io::storage::clear_prefix(prefix);
}
/// Get a Vec of bytes from storage.
pub fn get_raw(key: &[u8]) -> Option<Vec<u8>> {
runtime_io::storage::get(key)
sp_io::storage::get(key)
}
/// Put a raw byte slice into storage.
pub fn put_raw(key: &[u8], value: &[u8]) {
runtime_io::storage::set(key, value)
sp_io::storage::set(key, value)
}