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
+2 -2
View File
@@ -11,7 +11,7 @@ primitives = { package = "sp-core", path = "../core", default-features = false
app-crypto = { package = "sc-application-crypto", path = "../application-crypto", default-features = false }
arithmetic = { package = "sp-arithmetic", path = "../sr-arithmetic", default-features = false }
sp-std = { path = "../std", default-features = false }
runtime_io = { package = "sp-io", path = "../sr-io", default-features = false }
sp-io = { path = "../io", default-features = false }
log = { version = "0.4.8", optional = true }
paste = "0.1.6"
rand = { version = "0.7.2", optional = true }
@@ -33,7 +33,7 @@ std = [
"primitives/std",
"rand",
"sp-std/std",
"runtime_io/std",
"sp-io/std",
"serde",
"inherents/std",
]
@@ -17,7 +17,7 @@
//! Generic implementation of an unchecked (pre-verification) extrinsic.
use sp_std::{fmt, prelude::*};
use runtime_io::hashing::blake2_256;
use sp_io::hashing::blake2_256;
use codec::{Decode, Encode, EncodeLike, Input, Error};
use crate::{
traits::{self, Member, MaybeDisplay, SignedExtension, Checkable, Extrinsic, IdentifyAccount},
@@ -282,7 +282,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use runtime_io::hashing::blake2_256;
use sp_io::hashing::blake2_256;
use crate::codec::{Encode, Decode};
use crate::traits::{SignedExtension, IdentifyAccount, IdentityLookup};
use serde::{Serialize, Deserialize};
+4 -4
View File
@@ -243,7 +243,7 @@ impl traits::IdentifyAccount for MultiSigner {
match self {
MultiSigner::Ed25519(who) => <[u8; 32]>::from(who).into(),
MultiSigner::Sr25519(who) => <[u8; 32]>::from(who).into(),
MultiSigner::Ecdsa(who) => runtime_io::hashing::blake2_256(who.as_ref()).into(),
MultiSigner::Ecdsa(who) => sp_io::hashing::blake2_256(who.as_ref()).into(),
}
}
}
@@ -306,10 +306,10 @@ impl Verify for MultiSignature {
(MultiSignature::Ed25519(ref sig), who) => sig.verify(msg, &ed25519::Public::from_slice(who.as_ref())),
(MultiSignature::Sr25519(ref sig), who) => sig.verify(msg, &sr25519::Public::from_slice(who.as_ref())),
(MultiSignature::Ecdsa(ref sig), who) => {
let m = runtime_io::hashing::blake2_256(msg.get());
match runtime_io::crypto::secp256k1_ecdsa_recover_compressed(sig.as_ref(), &m) {
let m = sp_io::hashing::blake2_256(msg.get());
match sp_io::crypto::secp256k1_ecdsa_recover_compressed(sig.as_ref(), &m) {
Ok(pubkey) =>
&runtime_io::hashing::blake2_256(pubkey.as_ref())
&sp_io::hashing::blake2_256(pubkey.as_ref())
== <dyn AsRef<[u8; 32]>>::as_ref(who),
_ => false,
}
@@ -221,7 +221,7 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator<Item=I>> Request<'a, T> {
let meta = &[];
// start an http request.
let id = runtime_io::offchain::http_request_start(
let id = sp_io::offchain::http_request_start(
self.method.as_ref(),
self.url,
meta,
@@ -229,7 +229,7 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator<Item=I>> Request<'a, T> {
// add custom headers
for header in &self.headers {
runtime_io::offchain::http_request_add_header(
sp_io::offchain::http_request_add_header(
id,
header.name(),
header.value(),
@@ -238,11 +238,11 @@ impl<'a, I: AsRef<[u8]>, T: IntoIterator<Item=I>> Request<'a, T> {
// write body
for chunk in self.body {
runtime_io::offchain::http_request_write_body(id, chunk.as_ref(), self.deadline)?;
sp_io::offchain::http_request_write_body(id, chunk.as_ref(), self.deadline)?;
}
// finalise the request
runtime_io::offchain::http_request_write_body(id, &[], self.deadline)?;
sp_io::offchain::http_request_write_body(id, &[], self.deadline)?;
Ok(PendingRequest {
id,
@@ -307,7 +307,7 @@ impl PendingRequest {
deadline: impl Into<Option<Timestamp>>
) -> Vec<Result<HttpResult, PendingRequest>> {
let ids = requests.iter().map(|r| r.id).collect::<Vec<_>>();
let statuses = runtime_io::offchain::http_response_wait(&ids, deadline.into());
let statuses = sp_io::offchain::http_response_wait(&ids, deadline.into());
statuses
.into_iter()
@@ -346,7 +346,7 @@ impl Response {
pub fn headers(&mut self) -> &Headers {
if self.headers.is_none() {
self.headers = Some(
Headers { raw: runtime_io::offchain::http_response_headers(self.id) },
Headers { raw: sp_io::offchain::http_response_headers(self.id) },
);
}
self.headers.as_ref().expect("Headers were just set; qed")
@@ -426,7 +426,7 @@ impl Iterator for ResponseBody {
}
if self.filled_up_to.is_none() {
let result = runtime_io::offchain::http_response_read_body(
let result = sp_io::offchain::http_response_read_body(
self.id,
&mut self.buffer,
self.deadline);
@@ -515,7 +515,7 @@ impl<'a> HeadersIterator<'a> {
#[cfg(test)]
mod tests {
use super::*;
use runtime_io::TestExternalities;
use sp_io::TestExternalities;
use primitives::offchain::{
OffchainExt,
testing,
+11 -11
View File
@@ -18,7 +18,7 @@
use sp_std::prelude::*;
use sp_std::{self, result, marker::PhantomData, convert::{TryFrom, TryInto}, fmt::Debug};
use runtime_io;
use sp_io;
#[cfg(feature = "std")]
use std::fmt::Display;
#[cfg(feature = "std")]
@@ -84,23 +84,23 @@ pub trait Verify {
impl Verify for primitives::ed25519::Signature {
type Signer = primitives::ed25519::Public;
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &primitives::ed25519::Public) -> bool {
runtime_io::crypto::ed25519_verify(self, msg.get(), signer)
sp_io::crypto::ed25519_verify(self, msg.get(), signer)
}
}
impl Verify for primitives::sr25519::Signature {
type Signer = primitives::sr25519::Public;
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &primitives::sr25519::Public) -> bool {
runtime_io::crypto::sr25519_verify(self, msg.get(), signer)
sp_io::crypto::sr25519_verify(self, msg.get(), signer)
}
}
impl Verify for primitives::ecdsa::Signature {
type Signer = primitives::ecdsa::Public;
fn verify<L: Lazy<[u8]>>(&self, mut msg: L, signer: &primitives::ecdsa::Public) -> bool {
match runtime_io::crypto::secp256k1_ecdsa_recover_compressed(
match sp_io::crypto::secp256k1_ecdsa_recover_compressed(
self.as_ref(),
&runtime_io::hashing::blake2_256(msg.get()),
&sp_io::hashing::blake2_256(msg.get()),
) {
Ok(pubkey) => <dyn AsRef<[u8]>>::as_ref(signer) == &pubkey[..],
_ => false,
@@ -399,15 +399,15 @@ impl Hash for BlakeTwo256 {
type Output = primitives::H256;
type Hasher = Blake2Hasher;
fn hash(s: &[u8]) -> Self::Output {
runtime_io::hashing::blake2_256(s).into()
sp_io::hashing::blake2_256(s).into()
}
fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> Self::Output {
runtime_io::trie::blake2_256_root(input)
sp_io::trie::blake2_256_root(input)
}
fn ordered_trie_root(input: Vec<Vec<u8>>) -> Self::Output {
runtime_io::trie::blake2_256_ordered_root(input)
sp_io::trie::blake2_256_ordered_root(input)
}
}
@@ -1233,19 +1233,19 @@ impl Printable for usize {
impl Printable for u64 {
fn print(&self) {
runtime_io::misc::print_num(*self);
sp_io::misc::print_num(*self);
}
}
impl Printable for &[u8] {
fn print(&self) {
runtime_io::misc::print_hex(self);
sp_io::misc::print_hex(self);
}
}
impl Printable for &str {
fn print(&self) {
runtime_io::misc::print_utf8(self.as_bytes());
sp_io::misc::print_utf8(self.as_bytes());
}
}