Run cargo fmt on the whole code base (#9394)

* Run cargo fmt on the whole code base

* Second run

* Add CI check

* Fix compilation

* More unnecessary braces

* Handle weights

* Use --all

* Use correct attributes...

* Fix UI tests

* AHHHHHHHHH

* 🤦

* Docs

* Fix compilation

* 🤷

* Please stop

* 🤦 x 2

* More

* make rustfmt.toml consistent with polkadot

Co-authored-by: André Silva <andrerfosilva@gmail.com>
This commit is contained in:
Bastian Köcher
2021-07-21 16:32:32 +02:00
committed by GitHub
parent d451c38c1c
commit 7b56ab15b4
1010 changed files with 53339 additions and 51208 deletions
+23 -29
View File
@@ -16,9 +16,9 @@
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.
use kvdb::{DBTransaction, KeyValueDB};
use kvdb_rocksdb::{Database, DatabaseConfig};
use std::{io, path::PathBuf, sync::Arc};
use kvdb::{KeyValueDB, DBTransaction};
use kvdb_rocksdb::{DatabaseConfig, Database};
#[derive(Debug, Clone, Copy, derive_more::Display)]
pub enum DatabaseType {
@@ -44,13 +44,14 @@ impl KeyValueDB for ParityDbWrapper {
/// Write a transaction of changes to the buffer.
fn write(&self, transaction: DBTransaction) -> io::Result<()> {
self.0.commit(
transaction.ops.iter().map(|op| match op {
kvdb::DBOp::Insert { col, key, value } => (*col as u8, &key[key.len() - 32..], Some(value.to_vec())),
self.0
.commit(transaction.ops.iter().map(|op| match op {
kvdb::DBOp::Insert { col, key, value } =>
(*col as u8, &key[key.len() - 32..], Some(value.to_vec())),
kvdb::DBOp::Delete { col, key } => (*col as u8, &key[key.len() - 32..], None),
kvdb::DBOp::DeletePrefix { col: _, prefix: _ } => unimplemented!()
})
).expect("db error");
kvdb::DBOp::DeletePrefix { col: _, prefix: _ } => unimplemented!(),
}))
.expect("db error");
Ok(())
}
@@ -90,21 +91,19 @@ impl TempDatabase {
match db_type {
DatabaseType::RocksDb => {
let db_cfg = DatabaseConfig::with_columns(1);
let db = Database::open(&db_cfg, &self.0.path().to_string_lossy()).expect("Database backend error");
let db = Database::open(&db_cfg, &self.0.path().to_string_lossy())
.expect("Database backend error");
Arc::new(db)
},
DatabaseType::ParityDb => {
Arc::new(ParityDbWrapper({
let mut options = parity_db::Options::with_columns(self.0.path(), 1);
let mut column_options = &mut options.columns[0];
column_options.ref_counted = true;
column_options.preimage = true;
column_options.uniform = true;
parity_db::Db::open(&options).expect("db open error")
}))
}
DatabaseType::ParityDb => Arc::new(ParityDbWrapper({
let mut options = parity_db::Options::with_columns(self.0.path(), 1);
let mut column_options = &mut options.columns[0];
column_options.ref_counted = true;
column_options.preimage = true;
column_options.uniform = true;
parity_db::Db::open(&options).expect("db open error")
})),
}
}
}
@@ -121,15 +120,10 @@ impl Clone for TempDatabase {
);
let self_db_files = std::fs::read_dir(self_dir)
.expect("failed to list file in seed dir")
.map(|f_result|
f_result.expect("failed to read file in seed db")
.path()
).collect::<Vec<PathBuf>>();
fs_extra::copy_items(
&self_db_files,
new_dir.path(),
&fs_extra::dir::CopyOptions::new(),
).expect("Copy of seed database is ok");
.map(|f_result| f_result.expect("failed to read file in seed db").path())
.collect::<Vec<PathBuf>>();
fs_extra::copy_items(&self_db_files, new_dir.path(), &fs_extra::dir::CopyOptions::new())
.expect("Copy of seed database is ok");
TempDatabase(new_dir)
}