mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-13 05:51:02 +00:00
Migrate state-db, state-machine, telemetry, test-client and test-runtime to the 2018 edition (#1623)
This commit is contained in:
committed by
Bastian Köcher
parent
2037c52fbe
commit
f98f9ac58a
@@ -29,23 +29,18 @@
|
||||
//! See `RefWindow` for pruning algorithm details. `StateDb` prunes on each canonicalization until pruning
|
||||
//! constraints are satisfied.
|
||||
|
||||
#[macro_use] extern crate log;
|
||||
#[macro_use] extern crate parity_codec_derive;
|
||||
extern crate parking_lot;
|
||||
extern crate parity_codec as codec;
|
||||
#[cfg(test)]
|
||||
extern crate substrate_primitives as primitives;
|
||||
|
||||
mod noncanonical;
|
||||
mod pruning;
|
||||
#[cfg(test)] mod test;
|
||||
|
||||
use std::fmt;
|
||||
use parking_lot::RwLock;
|
||||
use parity_codec as codec;
|
||||
use codec::Codec;
|
||||
use std::collections::HashSet;
|
||||
use noncanonical::NonCanonicalOverlay;
|
||||
use pruning::RefWindow;
|
||||
use log::trace;
|
||||
|
||||
/// Database value type.
|
||||
pub type DBValue = Vec<u8>;
|
||||
@@ -62,7 +57,6 @@ pub trait MetaDb {
|
||||
fn get_meta(&self, key: &[u8]) -> Result<Option<DBValue>, Self::Error>;
|
||||
}
|
||||
|
||||
|
||||
/// Backend database trait. Read-only.
|
||||
pub trait HashDb {
|
||||
type Hash: Hash;
|
||||
@@ -353,8 +347,8 @@ impl<BlockHash: Hash, Key: Hash> StateDb<BlockHash, Key> {
|
||||
mod tests {
|
||||
use std::io;
|
||||
use primitives::H256;
|
||||
use {StateDb, PruningMode, Constraints};
|
||||
use test::{make_db, make_changeset, TestDb};
|
||||
use crate::{StateDb, PruningMode, Constraints};
|
||||
use crate::test::{make_db, make_changeset, TestDb};
|
||||
|
||||
fn make_test_db(settings: PruningMode) -> (TestDb, StateDb<H256, H256>) {
|
||||
let mut db = make_db(&[91, 921, 922, 93, 94]);
|
||||
|
||||
@@ -23,7 +23,9 @@
|
||||
use std::fmt;
|
||||
use std::collections::{HashMap, VecDeque};
|
||||
use super::{Error, DBValue, ChangeSet, CommitSet, MetaDb, Hash, to_meta_key};
|
||||
use codec::{Decode, Encode};
|
||||
use crate::codec::{Decode, Encode};
|
||||
use parity_codec_derive::{Decode, Encode};
|
||||
use log::trace;
|
||||
|
||||
const NON_CANONICAL_JOURNAL: &[u8] = b"noncanonical_journal";
|
||||
const LAST_CANONICAL: &[u8] = b"last_canonical";
|
||||
@@ -270,9 +272,9 @@ impl<BlockHash: Hash, Key: Hash> NonCanonicalOverlay<BlockHash, Key> {
|
||||
mod tests {
|
||||
use std::io;
|
||||
use super::NonCanonicalOverlay;
|
||||
use {ChangeSet};
|
||||
use crate::ChangeSet;
|
||||
use primitives::H256;
|
||||
use test::{make_db, make_changeset};
|
||||
use crate::test::{make_db, make_changeset};
|
||||
|
||||
fn contains(overlay: &NonCanonicalOverlay<H256, H256>, key: u64) -> bool {
|
||||
overlay.get(&H256::from_low_u64_be(key)) == Some(H256::from_low_u64_be(key).as_bytes().to_vec())
|
||||
|
||||
@@ -23,8 +23,10 @@
|
||||
//! The changes are journaled in the DB.
|
||||
|
||||
use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use codec::{Encode, Decode};
|
||||
use {CommitSet, Error, MetaDb, to_meta_key, Hash};
|
||||
use crate::codec::{Encode, Decode};
|
||||
use parity_codec_derive::{Encode, Decode};
|
||||
use crate::{CommitSet, Error, MetaDb, to_meta_key, Hash};
|
||||
use log::trace;
|
||||
|
||||
const LAST_PRUNED: &[u8] = b"last_pruned";
|
||||
const PRUNING_JOURNAL: &[u8] = b"pruning_journal";
|
||||
@@ -158,8 +160,8 @@ impl<BlockHash: Hash, Key: Hash> RefWindow<BlockHash, Key> {
|
||||
mod tests {
|
||||
use super::RefWindow;
|
||||
use primitives::H256;
|
||||
use {CommitSet};
|
||||
use test::{make_db, make_commit, TestDb};
|
||||
use crate::CommitSet;
|
||||
use crate::test::{make_db, make_commit, TestDb};
|
||||
|
||||
fn check_journal(pruning: &RefWindow<H256, H256>, db: &TestDb) {
|
||||
let restored: RefWindow<H256, H256> = RefWindow::new(db).unwrap();
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use std::collections::HashMap;
|
||||
use primitives::H256;
|
||||
use {DBValue, ChangeSet, CommitSet, MetaDb, HashDb};
|
||||
use crate::{DBValue, ChangeSet, CommitSet, MetaDb, HashDb};
|
||||
|
||||
#[derive(Default, Debug, Clone, PartialEq, Eq)]
|
||||
pub struct TestDb {
|
||||
|
||||
Reference in New Issue
Block a user