[INFO] cloning repository https://github.com/anatolii10k/custom-substrate-node [INFO] running `Command { std: "git" "-c" "credential.helper=" "-c" "credential.helper=/workspace/cargo-home/bin/git-credential-null" "clone" "--bare" "https://github.com/anatolii10k/custom-substrate-node" "/workspace/cache/git-repos/https%3A%2F%2Fgithub.com%2Fanatolii10k%2Fcustom-substrate-node", kill_on_drop: false }` [INFO] [stderr] Cloning into bare repository '/workspace/cache/git-repos/https%3A%2F%2Fgithub.com%2Fanatolii10k%2Fcustom-substrate-node'... [INFO] running `Command { std: "git" "rev-parse" "HEAD", kill_on_drop: false }` [INFO] [stdout] 331bd02f3c00402c08a8e6374859cb6284895a25 [INFO] linting anatolii10k/custom-substrate-node against nightly for clippy-nonminimal_bool-denied [INFO] running `Command { std: "git" "clone" "/workspace/cache/git-repos/https%3A%2F%2Fgithub.com%2Fanatolii10k%2Fcustom-substrate-node" "/workspace/builds/worker-5-tc1/source", kill_on_drop: false }` [INFO] [stderr] Cloning into '/workspace/builds/worker-5-tc1/source'... [INFO] [stderr] done. [INFO] started tweaking git repo https://github.com/anatolii10k/custom-substrate-node [INFO] finished tweaking git repo https://github.com/anatolii10k/custom-substrate-node [INFO] tweaked toml for git repo https://github.com/anatolii10k/custom-substrate-node written to /workspace/builds/worker-5-tc1/source/Cargo.toml [INFO] validating manifest of git repo https://github.com/anatolii10k/custom-substrate-node on toolchain nightly [INFO] running `Command { std: CARGO_HOME="/workspace/cargo-home" RUSTUP_HOME="/workspace/rustup-home" "/workspace/cargo-home/bin/cargo" "+nightly" "metadata" "--manifest-path" "Cargo.toml" "--no-deps", kill_on_drop: false }` [INFO] crate git repo https://github.com/anatolii10k/custom-substrate-node already has a lockfile, it will not be regenerated [INFO] running `Command { std: CARGO_HOME="/workspace/cargo-home" RUSTUP_HOME="/workspace/rustup-home" "/workspace/cargo-home/bin/cargo" "+nightly" "fetch" "--manifest-path" "Cargo.toml", kill_on_drop: false }` [INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-5-tc1/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-5-tc1/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:d429b63d4308055ea97f60fb1d3dfca48854a00942f1bd2ad806beaf015945ec" "/opt/rustwide/cargo-home/bin/cargo" "+nightly" "metadata" "--no-deps" "--format-version=1", kill_on_drop: false }` [INFO] [stdout] aac2510d173f7c146a0d9aa88465ad770216c8242d0d1ffdc201d3118a8d3a06 [INFO] running `Command { std: "docker" "start" "-a" "aac2510d173f7c146a0d9aa88465ad770216c8242d0d1ffdc201d3118a8d3a06", kill_on_drop: false }` [INFO] running `Command { std: "docker" "inspect" "aac2510d173f7c146a0d9aa88465ad770216c8242d0d1ffdc201d3118a8d3a06", kill_on_drop: false }` [INFO] running `Command { std: "docker" "rm" "-f" "aac2510d173f7c146a0d9aa88465ad770216c8242d0d1ffdc201d3118a8d3a06", kill_on_drop: false }` [INFO] [stdout] aac2510d173f7c146a0d9aa88465ad770216c8242d0d1ffdc201d3118a8d3a06 [INFO] running `Command { std: "docker" "create" "-v" "/var/lib/crater-agent-workspace/builds/worker-5-tc1/target:/opt/rustwide/target:rw,Z" "-v" "/var/lib/crater-agent-workspace/builds/worker-5-tc1/source:/opt/rustwide/workdir:ro,Z" "-v" "/var/lib/crater-agent-workspace/cargo-home:/opt/rustwide/cargo-home:ro,Z" "-v" "/var/lib/crater-agent-workspace/rustup-home:/opt/rustwide/rustup-home:ro,Z" "-e" "SOURCE_DIR=/opt/rustwide/workdir" "-e" "CARGO_TARGET_DIR=/opt/rustwide/target" "-e" "CARGO_INCREMENTAL=0" "-e" "RUST_BACKTRACE=full" "-e" "RUSTFLAGS=--cap-lints=forbid" "-e" "RUSTDOCFLAGS=--cap-lints=forbid" "-e" "CARGO_HOME=/opt/rustwide/cargo-home" "-e" "RUSTUP_HOME=/opt/rustwide/rustup-home" "-w" "/opt/rustwide/workdir" "-m" "1610612736" "--user" "0:0" "--network" "none" "ghcr.io/rust-lang/crates-build-env/linux@sha256:d429b63d4308055ea97f60fb1d3dfca48854a00942f1bd2ad806beaf015945ec" "/opt/rustwide/cargo-home/bin/cargo" "+nightly" "clippy" "--frozen" "--all" "--all-targets" "--message-format=json", kill_on_drop: false }` [INFO] [stdout] 24d122f3270fe07edc336028136d5ddecb7ef72ee28882eb3af8b3ae5e81fcf2 [INFO] running `Command { std: "docker" "start" "-a" "24d122f3270fe07edc336028136d5ddecb7ef72ee28882eb3af8b3ae5e81fcf2", kill_on_drop: false }` [INFO] [stderr] Compiling typenum v1.13.0 [INFO] [stderr] Compiling generic-array v0.14.4 [INFO] [stderr] Checking subtle v2.4.1 [INFO] [stderr] Checking digest v0.9.0 [INFO] [stderr] Checking crypto-mac v0.8.0 [INFO] [stderr] Checking blake2 v0.9.2 [INFO] [stderr] Checking Rust_Sandbox v0.1.0 (/opt/rustwide/workdir) [INFO] [stdout] warning: empty line after doc comment [INFO] [stdout] --> src/rchain/mod.rs:477:1 [INFO] [stdout] | [INFO] [stdout] 477 | / /// (trait and parameters are not within the local crate) [INFO] [stdout] 478 | | /*impl From<&std::vec::Vec> for std::string::String { [INFO] [stdout] 479 | | fn from(item: &Vec) -> Self { [INFO] [stdout] 480 | | item.iter().map(|&c| c as char).collect() [INFO] [stdout] 481 | | } [INFO] [stdout] 482 | | }*/ [INFO] [stdout] 483 | | [INFO] [stdout] | |_^ [INFO] [stdout] ... [INFO] [stdout] 486 | fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] | ------------------------ the comment documents this function [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments [INFO] [stdout] = note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default [INFO] [stdout] = help: if the empty line is unintentional, remove it [INFO] [stdout] help: if the doc comment should not document function `byte_vector_to_string` then comment it out [INFO] [stdout] | [INFO] [stdout] 474 ~ // /// Will take an array of bytes and transform it into a string by interpreting every byte [INFO] [stdout] 475 ~ // /// as an character due to RFC 1023 that's not possible [INFO] [stdout] 476 ~ // /// @Link https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md [INFO] [stdout] 477 ~ // /// (trait and parameters are not within the local crate) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: field `pending_transactions` is never read [INFO] [stdout] --> src/rchain/mod.rs:24:5 [INFO] [stdout] | [INFO] [stdout] 14 | pub struct Blockchain { [INFO] [stdout] | ---------- field in this struct [INFO] [stdout] ... [INFO] [stdout] 24 | pending_transactions: Vec, [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `Blockchain` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis [INFO] [stdout] = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: variant `ChangeStoreValue` is never constructed [INFO] [stdout] --> src/rchain/mod.rs:94:5 [INFO] [stdout] | [INFO] [stdout] 89 | pub enum TransactionData { [INFO] [stdout] | --------------- variant in this enum [INFO] [stdout] ... [INFO] [stdout] 94 | ChangeStoreValue { key: String, value: String }, [INFO] [stdout] | ^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `TransactionData` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: fields `store` and `acc_type` are never read [INFO] [stdout] --> src/rchain/mod.rs:111:5 [INFO] [stdout] | [INFO] [stdout] 109 | pub struct Account { [INFO] [stdout] | ------- fields in this struct [INFO] [stdout] 110 | /// We want the account to be able to store any information we want (Dictionary) [INFO] [stdout] 111 | store: HashMap, [INFO] [stdout] | ^^^^^ [INFO] [stdout] ... [INFO] [stdout] 114 | acc_type: AccountType, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `Account` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: variants `Contract` and `Validator` are never constructed [INFO] [stdout] --> src/rchain/mod.rs:132:5 [INFO] [stdout] | [INFO] [stdout] 124 | pub enum AccountType { [INFO] [stdout] | ----------- variants in this enum [INFO] [stdout] ... [INFO] [stdout] 132 | Contract, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] ... [INFO] [stdout] 136 | Validator { [INFO] [stdout] | ^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `AccountType` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: method `set_nonce` is never used [INFO] [stdout] --> src/rchain/mod.rs:309:12 [INFO] [stdout] | [INFO] [stdout] 298 | impl Block { [INFO] [stdout] | ---------- method in this implementation [INFO] [stdout] ... [INFO] [stdout] 309 | pub fn set_nonce(&mut self, nonce: u128) { [INFO] [stdout] | ^^^^^^^^^ [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&String` instead of `&str` involves a new object where a slice will do [INFO] [stdout] --> src/rchain/mod.rs:38:45 [INFO] [stdout] | [INFO] [stdout] 38 | fn get_account_by_id_mut(&mut self, id: &String) -> Option<&mut Account>; [INFO] [stdout] | ^^^^^^^ help: change this to: `&str` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg [INFO] [stdout] = note: `#[warn(clippy::ptr_arg)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&String` instead of `&str` involves a new object where a slice will do [INFO] [stdout] --> src/rchain/mod.rs:41:37 [INFO] [stdout] | [INFO] [stdout] 41 | fn get_account_by_id(&self, id: &String) -> Option<&Account>; [INFO] [stdout] | ^^^^^^^ help: change this to: `&str` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: this boolean expression can be simplified [INFO] [stdout] --> src/rchain/mod.rs:169:12 [INFO] [stdout] | [INFO] [stdout] 169 | if !(block.prev_hash == self.get_last_block_hash()) { [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(block.prev_hash != self.get_last_block_hash())` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool [INFO] [stdout] = note: `#[warn(clippy::nonminimal_bool)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: this boolean expression can be simplified [INFO] [stdout] --> src/rchain/mod.rs:251:20 [INFO] [stdout] | [INFO] [stdout] 251 | if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&block.prev_hash != &self.blocks[block_num - 1].hash)` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/rchain/mod.rs:230:28 [INFO] [stdout] | [INFO] [stdout] 230 | return Err(format!("Stored hash for Block #{} \ [INFO] [stdout] | ____________________________^ [INFO] [stdout] 231 | | does not match calculated hash (Code: 665234234)", block_num + 1).into()); [INFO] [stdout] | |____________________________________________________________________________________________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion [INFO] [stdout] = note: `#[warn(clippy::useless_conversion)]` on by default [INFO] [stdout] help: consider removing `.into()` [INFO] [stdout] | [INFO] [stdout] 230 ~ return Err(format!("Stored hash for Block #{} \ [INFO] [stdout] 231 ~ does not match calculated hash (Code: 665234234)", block_num + 1)); [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/rchain/mod.rs:244:32 [INFO] [stdout] | [INFO] [stdout] 244 | return Err(format!("Block #{} has no previous hash set", block_num + 1).into()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Block #{} has no previous hash set", block_num + 1)` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: needlessly taken reference of both operands [INFO] [stdout] --> src/rchain/mod.rs:251:21 [INFO] [stdout] | [INFO] [stdout] 251 | if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref [INFO] [stdout] = note: `#[warn(clippy::op_ref)]` on by default [INFO] [stdout] help: use the values directly [INFO] [stdout] | [INFO] [stdout] 251 - if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] 251 + if !(block.prev_hash == self.blocks[block_num - 1].hash) { [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/rchain/mod.rs:252:32 [INFO] [stdout] | [INFO] [stdout] 252 | return Err(format!("Block #{} is not connected to previous block (Hashes do \ [INFO] [stdout] | ________________________________^ [INFO] [stdout] 253 | | not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, [INFO] [stdout] 254 | | prev_hash_actual).into()); [INFO] [stdout] | |_______________________________________________________________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion [INFO] [stdout] help: consider removing `.into()` [INFO] [stdout] | [INFO] [stdout] 252 ~ return Err(format!("Block #{} is not connected to previous block (Hashes do \ [INFO] [stdout] 253 + not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, [INFO] [stdout] 254 ~ prev_hash_actual)); [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: you are using an explicit closure for cloning elements [INFO] [stdout] --> src/rchain/mod.rs:275:9 [INFO] [stdout] | [INFO] [stdout] 275 | self.accounts.keys().map(|s| s.clone()).collect() [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `self.accounts.keys().cloned()` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone [INFO] [stdout] = note: `#[warn(clippy::map_clone)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:288:9 [INFO] [stdout] | [INFO] [stdout] 288 | / return if !self.get_user_ids().contains(&id) { [INFO] [stdout] 289 | | let acc = Account::new(account_type); [INFO] [stdout] 290 | | self.accounts.insert(id, acc); [INFO] [stdout] 291 | | Ok(()) [INFO] [stdout] 292 | | } else { [INFO] [stdout] 293 | | Err("User already exists! (Code: 934823094)") [INFO] [stdout] 294 | | }; [INFO] [stdout] | |_________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] = note: `#[warn(clippy::needless_return)]` on by default [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 288 ~ if !self.get_user_ids().contains(&id) { [INFO] [stdout] 289 + let acc = Account::new(account_type); [INFO] [stdout] 290 + self.accounts.insert(id, acc); [INFO] [stdout] 291 + Ok(()) [INFO] [stdout] 292 + } else { [INFO] [stdout] 293 + Err("User already exists! (Code: 934823094)") [INFO] [stdout] 294 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: empty line after doc comment [INFO] [stdout] --> src/rchain/mod.rs:477:1 [INFO] [stdout] | [INFO] [stdout] 477 | / /// (trait and parameters are not within the local crate) [INFO] [stdout] 478 | | /*impl From<&std::vec::Vec> for std::string::String { [INFO] [stdout] 479 | | fn from(item: &Vec) -> Self { [INFO] [stdout] 480 | | item.iter().map(|&c| c as char).collect() [INFO] [stdout] 481 | | } [INFO] [stdout] 482 | | }*/ [INFO] [stdout] 483 | | [INFO] [stdout] | |_^ [INFO] [stdout] ... [INFO] [stdout] 486 | fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] | ------------------------ the comment documents this function [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#empty_line_after_doc_comments [INFO] [stdout] = note: `#[warn(clippy::empty_line_after_doc_comments)]` on by default [INFO] [stdout] = help: if the empty line is unintentional, remove it [INFO] [stdout] help: if the doc comment should not document function `byte_vector_to_string` then comment it out [INFO] [stdout] | [INFO] [stdout] 474 ~ // /// Will take an array of bytes and transform it into a string by interpreting every byte [INFO] [stdout] 475 ~ // /// as an character due to RFC 1023 that's not possible [INFO] [stdout] 476 ~ // /// @Link https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md [INFO] [stdout] 477 ~ // /// (trait and parameters are not within the local crate) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:325:9 [INFO] [stdout] | [INFO] [stdout] 325 | return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 325 - return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] 325 + Vec::from(hasher.finalize().as_ref()) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: called `unwrap` on `balance_sender_new` after checking its variant with `is_some` [INFO] [stdout] --> src/rchain/mod.rs:422:85 [INFO] [stdout] | [INFO] [stdout] 421 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | ---------------------------- the check is happening here [INFO] [stdout] 422 | world_state.get_account_by_id_mut(&self.from).unwrap().tokens = balance_sender_new.unwrap(); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: try using `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap [INFO] [stdout] = note: `#[warn(clippy::unnecessary_unwrap)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: called `unwrap` on `balance_recv_new` after checking its variant with `is_some` [INFO] [stdout] --> src/rchain/mod.rs:423:77 [INFO] [stdout] | [INFO] [stdout] 421 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | -------------------------- the check is happening here [INFO] [stdout] 422 | world_state.get_account_by_id_mut(&self.from).unwrap().tokens = balance_sender_new.unwrap(); [INFO] [stdout] 423 | world_state.get_account_by_id_mut(to).unwrap().tokens = balance_recv_new.unwrap(); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: try using `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:382:9 [INFO] [stdout] | [INFO] [stdout] 382 | / return match &self.record { [INFO] [stdout] 383 | | [INFO] [stdout] 384 | | TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 385 | | world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] ... | [INFO] [stdout] 433 | | }; [INFO] [stdout] | |_________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 382 ~ match &self.record { [INFO] [stdout] 383 + [INFO] [stdout] 384 + TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 385 + world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] 386 + } [INFO] [stdout] 387 + [INFO] [stdout] 388 + TransactionData::CreateTokens { receiver, amount } => { [INFO] [stdout] 389 + if !is_initial { [INFO] [stdout] 390 + return Err("Token creation is only available on initial creation (Code: 2394233)"); [INFO] [stdout] 391 + } [INFO] [stdout] 392 + // Get the receiving user (must exist) [INFO] [stdout] 393 + return if let Some(account) = world_state.get_account_by_id_mut(receiver) { [INFO] [stdout] 394 + account.tokens += *amount; [INFO] [stdout] 395 + Ok(()) [INFO] [stdout] 396 + } else { [INFO] [stdout] 397 + Err("Receiver Account does not exist (Code: 23482309)") [INFO] [stdout] 398 + }; [INFO] [stdout] 399 + } [INFO] [stdout] 400 + [INFO] [stdout] 401 + TransactionData::TransferTokens { to, amount } => { [INFO] [stdout] 402 + let recv_tokens: u128; [INFO] [stdout] 403 + let sender_tokens: u128; [INFO] [stdout] 404 + [INFO] [stdout] 405 + if let Some(recv) = world_state.get_account_by_id_mut(to) { [INFO] [stdout] 406 + // Be extra careful here, even in the genesis block the sender account has to exist [INFO] [stdout] 407 + recv_tokens = recv.tokens; [INFO] [stdout] 408 + } else { [INFO] [stdout] 409 + return Err("Receiver Account does not exist! (Code: 3242342380)"); [INFO] [stdout] 410 + } [INFO] [stdout] 411 + [INFO] [stdout] 412 + if let Some(sender) = world_state.get_account_by_id_mut(&self.from) { [INFO] [stdout] 413 + sender_tokens = sender.tokens; [INFO] [stdout] 414 + } else { [INFO] [stdout] 415 + return Err("That account does not exist! (Code: 23423923)"); [INFO] [stdout] 416 + } [INFO] [stdout] 417 + [INFO] [stdout] 418 + let balance_recv_new = recv_tokens.checked_add(*amount); [INFO] [stdout] 419 + let balance_sender_new = sender_tokens.checked_sub(*amount); [INFO] [stdout] 420 + [INFO] [stdout] 421 + if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] 422 + world_state.get_account_by_id_mut(&self.from).unwrap().tokens = balance_sender_new.unwrap(); [INFO] [stdout] 423 + world_state.get_account_by_id_mut(to).unwrap().tokens = balance_recv_new.unwrap(); [INFO] [stdout] 424 + return Ok(()); [INFO] [stdout] 425 + } else { [INFO] [stdout] 426 + return Err("Overspent or Arithmetic error (Code: 48239084203)"); [INFO] [stdout] 427 + } [INFO] [stdout] 428 + } [INFO] [stdout] 429 + [INFO] [stdout] 430 + _ => { // Not implemented transaction type [INFO] [stdout] 431 + Err("Unknown Transaction type (not implemented) (Code: 487289724389)") [INFO] [stdout] 432 + } [INFO] [stdout] 433 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:443:9 [INFO] [stdout] | [INFO] [stdout] 443 | return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 443 - return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] 443 + Vec::from(hasher.finalize().as_ref()) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:466:9 [INFO] [stdout] | [INFO] [stdout] 466 | / return Self { [INFO] [stdout] 467 | | tokens: 0, [INFO] [stdout] 468 | | acc_type: account_type, [INFO] [stdout] 469 | | store: HashMap::new(), [INFO] [stdout] 470 | | }; [INFO] [stdout] | |_________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 466 ~ Self { [INFO] [stdout] 467 + tokens: 0, [INFO] [stdout] 468 + acc_type: account_type, [INFO] [stdout] 469 + store: HashMap::new(), [INFO] [stdout] 470 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do [INFO] [stdout] --> src/rchain/mod.rs:486:31 [INFO] [stdout] | [INFO] [stdout] 486 | fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg [INFO] [stdout] help: change this to [INFO] [stdout] | [INFO] [stdout] 486 - fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] 486 + fn byte_vector_to_string(arr: &[u8]) -> String { [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` [INFO] [stdout] --> src/main.rs:59:5 [INFO] [stdout] | [INFO] [stdout] 59 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 60 | | &mut TransactionData::TransferTokens {to:_, ref mut amount} => { [INFO] [stdout] 61 | | *amount = 100; // Actually change the value in place [INFO] [stdout] 62 | | }, [INFO] [stdout] 63 | | [INFO] [stdout] 64 | | _ => {} // We know that that recors is a TransferToken Action so we ignore the rest [INFO] [stdout] 65 | | } [INFO] [stdout] | |_____^ [INFO] [stdout] | [INFO] [stdout] = note: you might want to preserve the comments from inside the `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match [INFO] [stdout] = note: `#[warn(clippy::single_match)]` on by default [INFO] [stdout] help: try [INFO] [stdout] | [INFO] [stdout] 59 ~ if let &mut TransactionData::TransferTokens {to:_, ref mut amount} = transaction_data.record.borrow_mut() { [INFO] [stdout] 60 + *amount = 100; // Actually change the value in place [INFO] [stdout] 61 + } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` [INFO] [stdout] --> src/main.rs:80:5 [INFO] [stdout] | [INFO] [stdout] 80 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 81 | | &mut TransactionData::CreateTokens {receiver: _, ref mut amount} => { [INFO] [stdout] 82 | | *amount = 100_000_000_000; // Let's dont be small on that [INFO] [stdout] 83 | | }, [INFO] [stdout] 84 | | _ => {} // We know that that record is a Token Create Action so we ignore the rest [INFO] [stdout] 85 | | } [INFO] [stdout] | |_____^ [INFO] [stdout] | [INFO] [stdout] = note: you might want to preserve the comments from inside the `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match [INFO] [stdout] help: try [INFO] [stdout] | [INFO] [stdout] 80 ~ if let &mut TransactionData::CreateTokens {receiver: _, ref mut amount} = transaction_data.record.borrow_mut() { [INFO] [stdout] 81 + *amount = 100_000_000_000; // Let's dont be small on that [INFO] [stdout] 82 + } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: field `pending_transactions` is never read [INFO] [stdout] --> src/rchain/mod.rs:24:5 [INFO] [stdout] | [INFO] [stdout] 14 | pub struct Blockchain { [INFO] [stdout] | ---------- field in this struct [INFO] [stdout] ... [INFO] [stdout] 24 | pending_transactions: Vec, [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `Blockchain` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis [INFO] [stdout] = note: `#[warn(dead_code)]` (part of `#[warn(unused)]`) on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: variant `ChangeStoreValue` is never constructed [INFO] [stdout] --> src/rchain/mod.rs:94:5 [INFO] [stdout] | [INFO] [stdout] 89 | pub enum TransactionData { [INFO] [stdout] | --------------- variant in this enum [INFO] [stdout] ... [INFO] [stdout] 94 | ChangeStoreValue { key: String, value: String }, [INFO] [stdout] | ^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `TransactionData` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: fields `store` and `acc_type` are never read [INFO] [stdout] --> src/rchain/mod.rs:111:5 [INFO] [stdout] | [INFO] [stdout] 109 | pub struct Account { [INFO] [stdout] | ------- fields in this struct [INFO] [stdout] 110 | /// We want the account to be able to store any information we want (Dictionary) [INFO] [stdout] 111 | store: HashMap, [INFO] [stdout] | ^^^^^ [INFO] [stdout] ... [INFO] [stdout] 114 | acc_type: AccountType, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `Account` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: variants `Contract` and `Validator` are never constructed [INFO] [stdout] --> src/rchain/mod.rs:132:5 [INFO] [stdout] | [INFO] [stdout] 124 | pub enum AccountType { [INFO] [stdout] | ----------- variants in this enum [INFO] [stdout] ... [INFO] [stdout] 132 | Contract, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] ... [INFO] [stdout] 136 | Validator { [INFO] [stdout] | ^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `AccountType` has derived impls for the traits `Debug` and `Clone`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: method `set_nonce` is never used [INFO] [stdout] --> src/rchain/mod.rs:309:12 [INFO] [stdout] | [INFO] [stdout] 298 | impl Block { [INFO] [stdout] | ---------- method in this implementation [INFO] [stdout] ... [INFO] [stdout] 309 | pub fn set_nonce(&mut self, nonce: u128) { [INFO] [stdout] | ^^^^^^^^^ [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&String` instead of `&str` involves a new object where a slice will do [INFO] [stdout] --> src/rchain/mod.rs:38:45 [INFO] [stdout] | [INFO] [stdout] 38 | fn get_account_by_id_mut(&mut self, id: &String) -> Option<&mut Account>; [INFO] [stdout] | ^^^^^^^ help: change this to: `&str` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg [INFO] [stdout] = note: `#[warn(clippy::ptr_arg)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&String` instead of `&str` involves a new object where a slice will do [INFO] [stdout] --> src/rchain/mod.rs:41:37 [INFO] [stdout] | [INFO] [stdout] 41 | fn get_account_by_id(&self, id: &String) -> Option<&Account>; [INFO] [stdout] | ^^^^^^^ help: change this to: `&str` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: this boolean expression can be simplified [INFO] [stdout] --> src/rchain/mod.rs:169:12 [INFO] [stdout] | [INFO] [stdout] 169 | if !(block.prev_hash == self.get_last_block_hash()) { [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(block.prev_hash != self.get_last_block_hash())` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool [INFO] [stdout] = note: `#[warn(clippy::nonminimal_bool)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: this boolean expression can be simplified [INFO] [stdout] --> src/rchain/mod.rs:251:20 [INFO] [stdout] | [INFO] [stdout] 251 | if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `(&block.prev_hash != &self.blocks[block_num - 1].hash)` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#nonminimal_bool [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/rchain/mod.rs:230:28 [INFO] [stdout] | [INFO] [stdout] 230 | return Err(format!("Stored hash for Block #{} \ [INFO] [stdout] | ____________________________^ [INFO] [stdout] 231 | | does not match calculated hash (Code: 665234234)", block_num + 1).into()); [INFO] [stdout] | |____________________________________________________________________________________________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion [INFO] [stdout] = note: `#[warn(clippy::useless_conversion)]` on by default [INFO] [stdout] help: consider removing `.into()` [INFO] [stdout] | [INFO] [stdout] 230 ~ return Err(format!("Stored hash for Block #{} \ [INFO] [stdout] 231 ~ does not match calculated hash (Code: 665234234)", block_num + 1)); [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/rchain/mod.rs:244:32 [INFO] [stdout] | [INFO] [stdout] 244 | return Err(format!("Block #{} has no previous hash set", block_num + 1).into()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Block #{} has no previous hash set", block_num + 1)` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: needlessly taken reference of both operands [INFO] [stdout] --> src/rchain/mod.rs:251:21 [INFO] [stdout] | [INFO] [stdout] 251 | if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#op_ref [INFO] [stdout] = note: `#[warn(clippy::op_ref)]` on by default [INFO] [stdout] help: use the values directly [INFO] [stdout] | [INFO] [stdout] 251 - if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] 251 + if !(block.prev_hash == self.blocks[block_num - 1].hash) { [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/rchain/mod.rs:252:32 [INFO] [stdout] | [INFO] [stdout] 252 | return Err(format!("Block #{} is not connected to previous block (Hashes do \ [INFO] [stdout] | ________________________________^ [INFO] [stdout] 253 | | not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, [INFO] [stdout] 254 | | prev_hash_actual).into()); [INFO] [stdout] | |_______________________________________________________________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion [INFO] [stdout] help: consider removing `.into()` [INFO] [stdout] | [INFO] [stdout] 252 ~ return Err(format!("Block #{} is not connected to previous block (Hashes do \ [INFO] [stdout] 253 + not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, [INFO] [stdout] 254 ~ prev_hash_actual)); [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: you are using an explicit closure for cloning elements [INFO] [stdout] --> src/rchain/mod.rs:275:9 [INFO] [stdout] | [INFO] [stdout] 275 | self.accounts.keys().map(|s| s.clone()).collect() [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider calling the dedicated `cloned` method: `self.accounts.keys().cloned()` [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#map_clone [INFO] [stdout] = note: `#[warn(clippy::map_clone)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:288:9 [INFO] [stdout] | [INFO] [stdout] 288 | / return if !self.get_user_ids().contains(&id) { [INFO] [stdout] 289 | | let acc = Account::new(account_type); [INFO] [stdout] 290 | | self.accounts.insert(id, acc); [INFO] [stdout] 291 | | Ok(()) [INFO] [stdout] 292 | | } else { [INFO] [stdout] 293 | | Err("User already exists! (Code: 934823094)") [INFO] [stdout] 294 | | }; [INFO] [stdout] | |_________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] = note: `#[warn(clippy::needless_return)]` on by default [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 288 ~ if !self.get_user_ids().contains(&id) { [INFO] [stdout] 289 + let acc = Account::new(account_type); [INFO] [stdout] 290 + self.accounts.insert(id, acc); [INFO] [stdout] 291 + Ok(()) [INFO] [stdout] 292 + } else { [INFO] [stdout] 293 + Err("User already exists! (Code: 934823094)") [INFO] [stdout] 294 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:325:9 [INFO] [stdout] | [INFO] [stdout] 325 | return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 325 - return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] 325 + Vec::from(hasher.finalize().as_ref()) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: called `unwrap` on `balance_sender_new` after checking its variant with `is_some` [INFO] [stdout] --> src/rchain/mod.rs:422:85 [INFO] [stdout] | [INFO] [stdout] 421 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | ---------------------------- the check is happening here [INFO] [stdout] 422 | world_state.get_account_by_id_mut(&self.from).unwrap().tokens = balance_sender_new.unwrap(); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: try using `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap [INFO] [stdout] = note: `#[warn(clippy::unnecessary_unwrap)]` on by default [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: called `unwrap` on `balance_recv_new` after checking its variant with `is_some` [INFO] [stdout] --> src/rchain/mod.rs:423:77 [INFO] [stdout] | [INFO] [stdout] 421 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | -------------------------- the check is happening here [INFO] [stdout] 422 | world_state.get_account_by_id_mut(&self.from).unwrap().tokens = balance_sender_new.unwrap(); [INFO] [stdout] 423 | world_state.get_account_by_id_mut(to).unwrap().tokens = balance_recv_new.unwrap(); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: try using `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unnecessary_unwrap [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:382:9 [INFO] [stdout] | [INFO] [stdout] 382 | / return match &self.record { [INFO] [stdout] 383 | | [INFO] [stdout] 384 | | TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 385 | | world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] ... | [INFO] [stdout] 433 | | }; [INFO] [stdout] | |_________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 382 ~ match &self.record { [INFO] [stdout] 383 + [INFO] [stdout] 384 + TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 385 + world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] 386 + } [INFO] [stdout] 387 + [INFO] [stdout] 388 + TransactionData::CreateTokens { receiver, amount } => { [INFO] [stdout] 389 + if !is_initial { [INFO] [stdout] 390 + return Err("Token creation is only available on initial creation (Code: 2394233)"); [INFO] [stdout] 391 + } [INFO] [stdout] 392 + // Get the receiving user (must exist) [INFO] [stdout] 393 + return if let Some(account) = world_state.get_account_by_id_mut(receiver) { [INFO] [stdout] 394 + account.tokens += *amount; [INFO] [stdout] 395 + Ok(()) [INFO] [stdout] 396 + } else { [INFO] [stdout] 397 + Err("Receiver Account does not exist (Code: 23482309)") [INFO] [stdout] 398 + }; [INFO] [stdout] 399 + } [INFO] [stdout] 400 + [INFO] [stdout] 401 + TransactionData::TransferTokens { to, amount } => { [INFO] [stdout] 402 + let recv_tokens: u128; [INFO] [stdout] 403 + let sender_tokens: u128; [INFO] [stdout] 404 + [INFO] [stdout] 405 + if let Some(recv) = world_state.get_account_by_id_mut(to) { [INFO] [stdout] 406 + // Be extra careful here, even in the genesis block the sender account has to exist [INFO] [stdout] 407 + recv_tokens = recv.tokens; [INFO] [stdout] 408 + } else { [INFO] [stdout] 409 + return Err("Receiver Account does not exist! (Code: 3242342380)"); [INFO] [stdout] 410 + } [INFO] [stdout] 411 + [INFO] [stdout] 412 + if let Some(sender) = world_state.get_account_by_id_mut(&self.from) { [INFO] [stdout] 413 + sender_tokens = sender.tokens; [INFO] [stdout] 414 + } else { [INFO] [stdout] 415 + return Err("That account does not exist! (Code: 23423923)"); [INFO] [stdout] 416 + } [INFO] [stdout] 417 + [INFO] [stdout] 418 + let balance_recv_new = recv_tokens.checked_add(*amount); [INFO] [stdout] 419 + let balance_sender_new = sender_tokens.checked_sub(*amount); [INFO] [stdout] 420 + [INFO] [stdout] 421 + if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] 422 + world_state.get_account_by_id_mut(&self.from).unwrap().tokens = balance_sender_new.unwrap(); [INFO] [stdout] 423 + world_state.get_account_by_id_mut(to).unwrap().tokens = balance_recv_new.unwrap(); [INFO] [stdout] 424 + return Ok(()); [INFO] [stdout] 425 + } else { [INFO] [stdout] 426 + return Err("Overspent or Arithmetic error (Code: 48239084203)"); [INFO] [stdout] 427 + } [INFO] [stdout] 428 + } [INFO] [stdout] 429 + [INFO] [stdout] 430 + _ => { // Not implemented transaction type [INFO] [stdout] 431 + Err("Unknown Transaction type (not implemented) (Code: 487289724389)") [INFO] [stdout] 432 + } [INFO] [stdout] 433 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:443:9 [INFO] [stdout] | [INFO] [stdout] 443 | return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 443 - return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] 443 + Vec::from(hasher.finalize().as_ref()) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/rchain/mod.rs:466:9 [INFO] [stdout] | [INFO] [stdout] 466 | / return Self { [INFO] [stdout] 467 | | tokens: 0, [INFO] [stdout] 468 | | acc_type: account_type, [INFO] [stdout] 469 | | store: HashMap::new(), [INFO] [stdout] 470 | | }; [INFO] [stdout] | |_________^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return [INFO] [stdout] help: remove `return` [INFO] [stdout] | [INFO] [stdout] 466 ~ Self { [INFO] [stdout] 467 + tokens: 0, [INFO] [stdout] 468 + acc_type: account_type, [INFO] [stdout] 469 + store: HashMap::new(), [INFO] [stdout] 470 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&Vec` instead of `&[_]` involves a new object where a slice will do [INFO] [stdout] --> src/rchain/mod.rs:486:31 [INFO] [stdout] | [INFO] [stdout] 486 | fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg [INFO] [stdout] help: change this to [INFO] [stdout] | [INFO] [stdout] 486 - fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] 486 + fn byte_vector_to_string(arr: &[u8]) -> String { [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` [INFO] [stdout] --> src/main.rs:59:5 [INFO] [stdout] | [INFO] [stdout] 59 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 60 | | &mut TransactionData::TransferTokens {to:_, ref mut amount} => { [INFO] [stdout] 61 | | *amount = 100; // Actually change the value in place [INFO] [stdout] 62 | | }, [INFO] [stdout] 63 | | [INFO] [stdout] 64 | | _ => {} // We know that that recors is a TransferToken Action so we ignore the rest [INFO] [stdout] 65 | | } [INFO] [stdout] | |_____^ [INFO] [stdout] | [INFO] [stdout] = note: you might want to preserve the comments from inside the `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match [INFO] [stdout] = note: `#[warn(clippy::single_match)]` on by default [INFO] [stdout] help: try [INFO] [stdout] | [INFO] [stdout] 59 ~ if let &mut TransactionData::TransferTokens {to:_, ref mut amount} = transaction_data.record.borrow_mut() { [INFO] [stdout] 60 + *amount = 100; // Actually change the value in place [INFO] [stdout] 61 + } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let` [INFO] [stdout] --> src/main.rs:80:5 [INFO] [stdout] | [INFO] [stdout] 80 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 81 | | &mut TransactionData::CreateTokens {receiver: _, ref mut amount} => { [INFO] [stdout] 82 | | *amount = 100_000_000_000; // Let's dont be small on that [INFO] [stdout] 83 | | }, [INFO] [stdout] 84 | | _ => {} // We know that that record is a Token Create Action so we ignore the rest [INFO] [stdout] 85 | | } [INFO] [stdout] | |_____^ [INFO] [stdout] | [INFO] [stdout] = note: you might want to preserve the comments from inside the `match` [INFO] [stdout] = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match [INFO] [stdout] help: try [INFO] [stdout] | [INFO] [stdout] 80 ~ if let &mut TransactionData::CreateTokens {receiver: _, ref mut amount} = transaction_data.record.borrow_mut() { [INFO] [stdout] 81 + *amount = 100_000_000_000; // Let's dont be small on that [INFO] [stdout] 82 + } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stderr] Finished `dev` profile [unoptimized + debuginfo] target(s) in 2.50s [INFO] running `Command { std: "docker" "inspect" "24d122f3270fe07edc336028136d5ddecb7ef72ee28882eb3af8b3ae5e81fcf2", kill_on_drop: false }` [INFO] running `Command { std: "docker" "rm" "-f" "24d122f3270fe07edc336028136d5ddecb7ef72ee28882eb3af8b3ae5e81fcf2", kill_on_drop: false }` [INFO] [stdout] 24d122f3270fe07edc336028136d5ddecb7ef72ee28882eb3af8b3ae5e81fcf2