Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.

Commit 4e154f0

Browse files
committed
remove bincode
1 parent d06d069 commit 4e154f0

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

primitives/storage/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ use codec::{Encode, Decode};
2929

3030
/// Storage key.
3131
#[derive(PartialEq, Eq, RuntimeDebug)]
32-
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone))]
32+
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone, Encode, Decode))]
3333
pub struct StorageKey(
3434
#[cfg_attr(feature = "std", serde(with = "impl_serde::serialize"))] pub Vec<u8>,
3535
);
@@ -107,7 +107,7 @@ impl PrefixedStorageKey {
107107

108108
/// Storage data associated to a [`StorageKey`].
109109
#[derive(PartialEq, Eq, RuntimeDebug)]
110-
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone))]
110+
#[cfg_attr(feature = "std", derive(Serialize, Deserialize, Hash, PartialOrd, Ord, Clone, Encode, Decode))]
111111
pub struct StorageData(
112112
#[cfg_attr(feature = "std", serde(with="impl_serde::serialize"))]
113113
pub Vec<u8>,

utils/frame/remote-externalities/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ futures = "0.3"
2121
hex-literal = "0.3.1"
2222
env_logger = "0.8.2"
2323
log = "0.4.11"
24-
bincode = "1.3.1"
24+
codec = { package = "parity-scale-codec", version = "2.0.0" }
2525
tokio = "0.1.22"
2626

2727
sp-io = { version = "3.0.0", path = "../../../primitives/io" }
-25.9 KB
Binary file not shown.

utils/frame/remote-externalities/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ use futures::{
116116
compat::Future01CompatExt,
117117
TryFutureExt,
118118
};
119+
use codec::{Encode, Decode};
119120

120121
type KeyPair = (StorageKey, StorageData);
121122
type Number = u32;
@@ -268,17 +269,16 @@ impl Builder {
268269
impl Builder {
269270
/// Save the given data as cache.
270271
fn save_cache(&self, data: &[KeyPair], path: &Path) -> Result<(), &'static str> {
271-
let bdata = bincode::serialize(data).map_err(|_| "bincode::serialize failed.")?;
272272
info!(target: LOG_TARGET, "writing to cache file {:?}", path);
273-
fs::write(path, bdata).map_err(|_| "fs::write failed.")?;
273+
fs::write(path, data.encode()).map_err(|_| "fs::write failed.")?;
274274
Ok(())
275275
}
276276

277277
/// initialize `Self` from cache. Panics if the file does not exist.
278278
fn load_cache(&self, path: &Path) -> Result<Vec<KeyPair>, &'static str> {
279279
info!(target: LOG_TARGET, "scraping keypairs from cache {:?}", path,);
280280
let bytes = fs::read(path).map_err(|_| "fs::read failed.")?;
281-
bincode::deserialize(&bytes[..]).map_err(|_| "bincode::deserialize failed")
281+
Decode::decode(&mut &*bytes).map_err(|_| "decode failed")
282282
}
283283

284284
/// Build `Self` from a network node denoted by `uri`.
@@ -405,6 +405,7 @@ mod tests {
405405
}
406406

407407
#[async_std::test]
408+
#[cfg(feature = "remote-test")]
408409
async fn can_load_cache() {
409410
init_logger();
410411
Builder::new()

0 commit comments

Comments
 (0)