[INFO] cloning repository https://github.com/wizzywit/bchain [INFO] running `Command { std: "git" "-c" "credential.helper=" "-c" "credential.helper=/workspace/cargo-home/bin/git-credential-null" "clone" "--bare" "https://github.com/wizzywit/bchain" "/workspace/cache/git-repos/https%3A%2F%2Fgithub.com%2Fwizzywit%2Fbchain", kill_on_drop: false }` [INFO] [stderr] Cloning into bare repository '/workspace/cache/git-repos/https%3A%2F%2Fgithub.com%2Fwizzywit%2Fbchain'... [INFO] running `Command { std: "git" "rev-parse" "HEAD", kill_on_drop: false }` [INFO] [stdout] 52693faa7edf9fc7a6e7213cc628063d359e430e [INFO] linting wizzywit/bchain against nightly for clippy-nonminimal_bool-denied [INFO] running `Command { std: "git" "clone" "/workspace/cache/git-repos/https%3A%2F%2Fgithub.com%2Fwizzywit%2Fbchain" "/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/wizzywit/bchain [INFO] finished tweaking git repo https://github.com/wizzywit/bchain [INFO] tweaked toml for git repo https://github.com/wizzywit/bchain written to /workspace/builds/worker-5-tc1/source/Cargo.toml [INFO] validating manifest of git repo https://github.com/wizzywit/bchain 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/wizzywit/bchain 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] [stderr] Downloading crates ... [INFO] [stderr] Downloaded subtle v2.4.0 [INFO] [stderr] Downloaded blake2 v0.9.1 [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] 63522505db06a66468c704cfc57833953b23b70d7f9e5bdfbc3919e593cfe91f [INFO] running `Command { std: "docker" "start" "-a" "63522505db06a66468c704cfc57833953b23b70d7f9e5bdfbc3919e593cfe91f", kill_on_drop: false }` [INFO] running `Command { std: "docker" "inspect" "63522505db06a66468c704cfc57833953b23b70d7f9e5bdfbc3919e593cfe91f", kill_on_drop: false }` [INFO] running `Command { std: "docker" "rm" "-f" "63522505db06a66468c704cfc57833953b23b70d7f9e5bdfbc3919e593cfe91f", kill_on_drop: false }` [INFO] [stdout] 63522505db06a66468c704cfc57833953b23b70d7f9e5bdfbc3919e593cfe91f [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] e7cb29886fe1b730ba19f7d7e6939d001e863996bc35a5286838c0ef5a84adc0 [INFO] running `Command { std: "docker" "start" "-a" "e7cb29886fe1b730ba19f7d7e6939d001e863996bc35a5286838c0ef5a84adc0", kill_on_drop: false }` [INFO] [stderr] Compiling typenum v1.13.0 [INFO] [stderr] Compiling version_check v0.9.3 [INFO] [stderr] Checking subtle v2.4.0 [INFO] [stderr] Compiling generic-array v0.14.4 [INFO] [stderr] Checking crypto-mac v0.8.0 [INFO] [stderr] Checking digest v0.9.0 [INFO] [stderr] Checking blake2 v0.9.1 [INFO] [stderr] Checking bchain_v1 v0.1.0 (/opt/rustwide/workdir) [INFO] [stdout] warning: empty line after doc comment [INFO] [stdout] --> src/bchain/mod.rs:376:1 [INFO] [stdout] | [INFO] [stdout] 376 | / /// (trait and parameters are not within the local crate) [INFO] [stdout] 377 | | /*impl From<&std::vec::Vec> for std::string::String { [INFO] [stdout] 378 | | fn from(item: &Vec) -> Self { [INFO] [stdout] 379 | | item.iter().map(|&c| c as char).collect() [INFO] [stdout] 380 | | } [INFO] [stdout] 381 | | }*/ [INFO] [stdout] 382 | | [INFO] [stdout] | |_^ [INFO] [stdout] ... [INFO] [stdout] 385 | 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] 373 ~ // /// Will take an array of bytes and transform it into a string by interpreting every byte [INFO] [stdout] 374 ~ // /// as an character due to RFC 1023 that's not possible [INFO] [stdout] 375 ~ // /// @Link https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md [INFO] [stdout] 376 ~ // /// (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/bchain/mod.rs:13:5 [INFO] [stdout] | [INFO] [stdout] 10 | pub struct Blockchain { [INFO] [stdout] | ---------- field in this struct [INFO] [stdout] ... [INFO] [stdout] 13 | 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/bchain/mod.rs:44:5 [INFO] [stdout] | [INFO] [stdout] 42 | pub enum TransactionData { [INFO] [stdout] | --------------- variant in this enum [INFO] [stdout] 43 | CreateUserAccount(String), [INFO] [stdout] 44 | ChangeStoreValue { key: String, value: String }, [INFO] [stdout] | ^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `TransactionData` has derived impls for the traits `Clone` and `Debug`, 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/bchain/mod.rs:51:5 [INFO] [stdout] | [INFO] [stdout] 50 | pub struct Account { [INFO] [stdout] | ------- fields in this struct [INFO] [stdout] 51 | store: HashMap, [INFO] [stdout] | ^^^^^ [INFO] [stdout] 52 | acc_type: AccountType, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `Account` has derived impls for the traits `Clone` and `Debug`, 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/bchain/mod.rs:59:5 [INFO] [stdout] | [INFO] [stdout] 57 | pub enum AccountType { [INFO] [stdout] | ----------- variants in this enum [INFO] [stdout] 58 | User, [INFO] [stdout] 59 | Contract, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] 60 | Validator { [INFO] [stdout] | ^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `AccountType` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&String` instead of `&str` involves a new object where a slice will do [INFO] [stdout] --> src/bchain/mod.rs:18:45 [INFO] [stdout] | [INFO] [stdout] 18 | 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/bchain/mod.rs:19:37 [INFO] [stdout] | [INFO] [stdout] 19 | 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: unneeded `return` statement [INFO] [stdout] --> src/bchain/mod.rs:69:9 [INFO] [stdout] | [INFO] [stdout] 69 | / return Self { [INFO] [stdout] 70 | | tokens: 0, [INFO] [stdout] 71 | | acc_type: account_type, [INFO] [stdout] 72 | | store: HashMap::new(), [INFO] [stdout] 73 | | }; [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] 69 ~ Self { [INFO] [stdout] 70 + tokens: 0, [INFO] [stdout] 71 + acc_type: account_type, [INFO] [stdout] 72 + store: HashMap::new(), [INFO] [stdout] 73 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: this boolean expression can be simplified [INFO] [stdout] --> src/bchain/mod.rs:96:12 [INFO] [stdout] | [INFO] [stdout] 96 | 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/bchain/mod.rs:154:20 [INFO] [stdout] | [INFO] [stdout] 154 | 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: empty line after doc comment [INFO] [stdout] --> src/bchain/mod.rs:376:1 [INFO] [stdout] | [INFO] [stdout] 376 | / /// (trait and parameters are not within the local crate) [INFO] [stdout] 377 | | /*impl From<&std::vec::Vec> for std::string::String { [INFO] [stdout] 378 | | fn from(item: &Vec) -> Self { [INFO] [stdout] 379 | | item.iter().map(|&c| c as char).collect() [INFO] [stdout] 380 | | } [INFO] [stdout] 381 | | }*/ [INFO] [stdout] 382 | | [INFO] [stdout] | |_^ [INFO] [stdout] ... [INFO] [stdout] 385 | 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] 373 ~ // /// Will take an array of bytes and transform it into a string by interpreting every byte [INFO] [stdout] 374 ~ // /// as an character due to RFC 1023 that's not possible [INFO] [stdout] 375 ~ // /// @Link https://github.com/rust-lang/rfcs/blob/master/text/1023-rebalancing-coherence.md [INFO] [stdout] 376 ~ // /// (trait and parameters are not within the local crate) [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/bchain/mod.rs:131:28 [INFO] [stdout] | [INFO] [stdout] 131 | return Err(format!( [INFO] [stdout] | ____________________________^ [INFO] [stdout] 132 | | "Stored hash for Block #{} does not match calculated hash (Code: 665234234)", [INFO] [stdout] 133 | | block_num + 1 [INFO] [stdout] 134 | | ) [INFO] [stdout] 135 | | .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] 131 ~ return Err(format!( [INFO] [stdout] 132 + "Stored hash for Block #{} does not match calculated hash (Code: 665234234)", [INFO] [stdout] 133 + block_num + 1 [INFO] [stdout] 134 ~ )); [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/bchain/mod.rs:147:32 [INFO] [stdout] | [INFO] [stdout] 147 | 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/bchain/mod.rs:154:21 [INFO] [stdout] | [INFO] [stdout] 154 | 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] 154 - if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] 154 + 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/bchain/mod.rs:155:32 [INFO] [stdout] | [INFO] [stdout] 155 | ...rr(format!("Block #{} is not connected to previous block (Hashes do not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, prev_hash_actual).into()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Block #{} is not connected to previous block (Hashes do not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, prev_hash_actual)` [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: you are using an explicit closure for cloning elements [INFO] [stdout] --> src/bchain/mod.rs:231:9 [INFO] [stdout] | [INFO] [stdout] 231 | 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/bchain/mod.rs:247:9 [INFO] [stdout] | [INFO] [stdout] 247 | / return if !self.get_user_ids().contains(&id) { [INFO] [stdout] 248 | | let acc = Account::new(account_type); [INFO] [stdout] 249 | | self.accounts.insert(id, acc); [INFO] [stdout] 250 | | Ok(()) [INFO] [stdout] 251 | | } else { [INFO] [stdout] 252 | | Err("User already exists! (Code: 934823094)") [INFO] [stdout] 253 | | }; [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] 247 ~ if !self.get_user_ids().contains(&id) { [INFO] [stdout] 248 + let acc = Account::new(account_type); [INFO] [stdout] 249 + self.accounts.insert(id, acc); [INFO] [stdout] 250 + Ok(()) [INFO] [stdout] 251 + } else { [INFO] [stdout] 252 + Err("User already exists! (Code: 934823094)") [INFO] [stdout] 253 ~ } [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/bchain/mod.rs:328:35 [INFO] [stdout] | [INFO] [stdout] 324 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | ---------------------------- the check is happening here [INFO] [stdout] ... [INFO] [stdout] 328 | .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/bchain/mod.rs:330:25 [INFO] [stdout] | [INFO] [stdout] 324 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | -------------------------- the check is happening here [INFO] [stdout] ... [INFO] [stdout] 330 | 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/bchain/mod.rs:284:9 [INFO] [stdout] | [INFO] [stdout] 284 | / return match &self.record { [INFO] [stdout] 285 | | TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 286 | | world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] ... | [INFO] [stdout] 341 | | }; [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] 284 ~ match &self.record { [INFO] [stdout] 285 + TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 286 + world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] 287 + } [INFO] [stdout] 288 + [INFO] [stdout] 289 + TransactionData::CreateTokens { receiver, amount } => { [INFO] [stdout] 290 + if !is_initial { [INFO] [stdout] 291 + return Err( [INFO] [stdout] 292 + "Token creation is only available on initial creation (Code: 2394233)", [INFO] [stdout] 293 + ); [INFO] [stdout] 294 + } [INFO] [stdout] 295 + // Get the receiving user (must exist) [INFO] [stdout] 296 + return if let Some(account) = world_state.get_account_by_id_mut(receiver) { [INFO] [stdout] 297 + account.tokens += *amount; [INFO] [stdout] 298 + Ok(()) [INFO] [stdout] 299 + } else { [INFO] [stdout] 300 + Err("Receiver Account does not exist (Code: 23482309)") [INFO] [stdout] 301 + }; [INFO] [stdout] 302 + } [INFO] [stdout] 303 + [INFO] [stdout] 304 + TransactionData::TransferTokens { to, amount } => { [INFO] [stdout] 305 + let recv_tokens: u128; [INFO] [stdout] 306 + let sender_tokens: u128; [INFO] [stdout] 307 + [INFO] [stdout] 308 + if let Some(recv) = world_state.get_account_by_id_mut(to) { [INFO] [stdout] 309 + // Be extra careful here, even in the genesis block the sender account has to exist [INFO] [stdout] 310 + recv_tokens = recv.tokens; [INFO] [stdout] 311 + } else { [INFO] [stdout] 312 + return Err("Receiver Account does not exist! (Code: 3242342380)"); [INFO] [stdout] 313 + } [INFO] [stdout] 314 + [INFO] [stdout] 315 + if let Some(sender) = world_state.get_account_by_id_mut(&self.from) { [INFO] [stdout] 316 + sender_tokens = sender.tokens; [INFO] [stdout] 317 + } else { [INFO] [stdout] 318 + return Err("That account does not exist! (Code: 23423923)"); [INFO] [stdout] 319 + } [INFO] [stdout] 320 + [INFO] [stdout] 321 + let balance_recv_new = recv_tokens.checked_add(*amount); [INFO] [stdout] 322 + let balance_sender_new = sender_tokens.checked_sub(*amount); [INFO] [stdout] 323 + [INFO] [stdout] 324 + if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] 325 + world_state [INFO] [stdout] 326 + .get_account_by_id_mut(&self.from) [INFO] [stdout] 327 + .unwrap() [INFO] [stdout] 328 + .tokens = balance_sender_new.unwrap(); [INFO] [stdout] 329 + world_state.get_account_by_id_mut(to).unwrap().tokens = [INFO] [stdout] 330 + balance_recv_new.unwrap(); [INFO] [stdout] 331 + return Ok(()); [INFO] [stdout] 332 + } else { [INFO] [stdout] 333 + return Err("Overspent or Arithmetic error (Code: 48239084203)"); [INFO] [stdout] 334 + } [INFO] [stdout] 335 + } [INFO] [stdout] 336 + [INFO] [stdout] 337 + _ => { [INFO] [stdout] 338 + // Not implemented transaction type [INFO] [stdout] 339 + Err("Unknown Transaction type (not implemented) (Code: 487289724389)") [INFO] [stdout] 340 + } [INFO] [stdout] 341 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/bchain/mod.rs:353:9 [INFO] [stdout] | [INFO] [stdout] 353 | 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] 353 - return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] 353 + Vec::from(hasher.finalize().as_ref()) [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/bchain/mod.rs:385:31 [INFO] [stdout] | [INFO] [stdout] 385 | 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] 385 - fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] 385 + 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:71:5 [INFO] [stdout] | [INFO] [stdout] 71 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 72 | | &mut TransactionData::TransferTokens { [INFO] [stdout] 73 | | to: _, [INFO] [stdout] 74 | | ref mut amount, [INFO] [stdout] ... | [INFO] [stdout] 79 | | _ => {} // We know that that recors is a TransferToken Action so we ignore the rest [INFO] [stdout] 80 | | } [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] 71 ~ if let &mut TransactionData::TransferTokens { [INFO] [stdout] 72 + to: _, [INFO] [stdout] 73 + ref mut amount, [INFO] [stdout] 74 + } = transaction_data.record.borrow_mut() { [INFO] [stdout] 75 + *amount = 100; // Actually change the value in place [INFO] [stdout] 76 + } [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:98:5 [INFO] [stdout] | [INFO] [stdout] 98 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 99 | | &mut TransactionData::CreateTokens { [INFO] [stdout] 100 | | receiver: _, [INFO] [stdout] 101 | | ref mut amount, [INFO] [stdout] ... | [INFO] [stdout] 105 | | _ => {} // We know that that record is a Token Create Action so we ignore the rest [INFO] [stdout] 106 | | } [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] 98 ~ if let &mut TransactionData::CreateTokens { [INFO] [stdout] 99 + receiver: _, [INFO] [stdout] 100 + ref mut amount, [INFO] [stdout] 101 + } = transaction_data.record.borrow_mut() { [INFO] [stdout] 102 + *amount = 100_000_000_000; // Let's dont be small on that [INFO] [stdout] 103 + } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: field `pending_transactions` is never read [INFO] [stdout] --> src/bchain/mod.rs:13:5 [INFO] [stdout] | [INFO] [stdout] 10 | pub struct Blockchain { [INFO] [stdout] | ---------- field in this struct [INFO] [stdout] ... [INFO] [stdout] 13 | 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/bchain/mod.rs:44:5 [INFO] [stdout] | [INFO] [stdout] 42 | pub enum TransactionData { [INFO] [stdout] | --------------- variant in this enum [INFO] [stdout] 43 | CreateUserAccount(String), [INFO] [stdout] 44 | ChangeStoreValue { key: String, value: String }, [INFO] [stdout] | ^^^^^^^^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `TransactionData` has derived impls for the traits `Clone` and `Debug`, 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/bchain/mod.rs:51:5 [INFO] [stdout] | [INFO] [stdout] 50 | pub struct Account { [INFO] [stdout] | ------- fields in this struct [INFO] [stdout] 51 | store: HashMap, [INFO] [stdout] | ^^^^^ [INFO] [stdout] 52 | acc_type: AccountType, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `Account` has derived impls for the traits `Clone` and `Debug`, 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/bchain/mod.rs:59:5 [INFO] [stdout] | [INFO] [stdout] 57 | pub enum AccountType { [INFO] [stdout] | ----------- variants in this enum [INFO] [stdout] 58 | User, [INFO] [stdout] 59 | Contract, [INFO] [stdout] | ^^^^^^^^ [INFO] [stdout] 60 | Validator { [INFO] [stdout] | ^^^^^^^^^ [INFO] [stdout] | [INFO] [stdout] = note: `AccountType` has derived impls for the traits `Clone` and `Debug`, but these are intentionally ignored during dead code analysis [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: writing `&String` instead of `&str` involves a new object where a slice will do [INFO] [stdout] --> src/bchain/mod.rs:18:45 [INFO] [stdout] | [INFO] [stdout] 18 | 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/bchain/mod.rs:19:37 [INFO] [stdout] | [INFO] [stdout] 19 | 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: unneeded `return` statement [INFO] [stdout] --> src/bchain/mod.rs:69:9 [INFO] [stdout] | [INFO] [stdout] 69 | / return Self { [INFO] [stdout] 70 | | tokens: 0, [INFO] [stdout] 71 | | acc_type: account_type, [INFO] [stdout] 72 | | store: HashMap::new(), [INFO] [stdout] 73 | | }; [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] 69 ~ Self { [INFO] [stdout] 70 + tokens: 0, [INFO] [stdout] 71 + acc_type: account_type, [INFO] [stdout] 72 + store: HashMap::new(), [INFO] [stdout] 73 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: this boolean expression can be simplified [INFO] [stdout] --> src/bchain/mod.rs:96:12 [INFO] [stdout] | [INFO] [stdout] 96 | 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/bchain/mod.rs:154:20 [INFO] [stdout] | [INFO] [stdout] 154 | 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/bchain/mod.rs:131:28 [INFO] [stdout] | [INFO] [stdout] 131 | return Err(format!( [INFO] [stdout] | ____________________________^ [INFO] [stdout] 132 | | "Stored hash for Block #{} does not match calculated hash (Code: 665234234)", [INFO] [stdout] 133 | | block_num + 1 [INFO] [stdout] 134 | | ) [INFO] [stdout] 135 | | .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] 131 ~ return Err(format!( [INFO] [stdout] 132 + "Stored hash for Block #{} does not match calculated hash (Code: 665234234)", [INFO] [stdout] 133 + block_num + 1 [INFO] [stdout] 134 ~ )); [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: useless conversion to the same type: `std::string::String` [INFO] [stdout] --> src/bchain/mod.rs:147:32 [INFO] [stdout] | [INFO] [stdout] 147 | 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/bchain/mod.rs:154:21 [INFO] [stdout] | [INFO] [stdout] 154 | 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] 154 - if !(&block.prev_hash == &self.blocks[block_num - 1].hash) { [INFO] [stdout] 154 + 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/bchain/mod.rs:155:32 [INFO] [stdout] | [INFO] [stdout] 155 | ...rr(format!("Block #{} is not connected to previous block (Hashes do not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, prev_hash_actual).into()); [INFO] [stdout] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider removing `.into()`: `format!("Block #{} is not connected to previous block (Hashes do not match. Should be `{}` but is `{}`)", block_num, prev_hash_proposed, prev_hash_actual)` [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: you are using an explicit closure for cloning elements [INFO] [stdout] --> src/bchain/mod.rs:231:9 [INFO] [stdout] | [INFO] [stdout] 231 | 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/bchain/mod.rs:247:9 [INFO] [stdout] | [INFO] [stdout] 247 | / return if !self.get_user_ids().contains(&id) { [INFO] [stdout] 248 | | let acc = Account::new(account_type); [INFO] [stdout] 249 | | self.accounts.insert(id, acc); [INFO] [stdout] 250 | | Ok(()) [INFO] [stdout] 251 | | } else { [INFO] [stdout] 252 | | Err("User already exists! (Code: 934823094)") [INFO] [stdout] 253 | | }; [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] 247 ~ if !self.get_user_ids().contains(&id) { [INFO] [stdout] 248 + let acc = Account::new(account_type); [INFO] [stdout] 249 + self.accounts.insert(id, acc); [INFO] [stdout] 250 + Ok(()) [INFO] [stdout] 251 + } else { [INFO] [stdout] 252 + Err("User already exists! (Code: 934823094)") [INFO] [stdout] 253 ~ } [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/bchain/mod.rs:328:35 [INFO] [stdout] | [INFO] [stdout] 324 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | ---------------------------- the check is happening here [INFO] [stdout] ... [INFO] [stdout] 328 | .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/bchain/mod.rs:330:25 [INFO] [stdout] | [INFO] [stdout] 324 | if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] | -------------------------- the check is happening here [INFO] [stdout] ... [INFO] [stdout] 330 | 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/bchain/mod.rs:284:9 [INFO] [stdout] | [INFO] [stdout] 284 | / return match &self.record { [INFO] [stdout] 285 | | TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 286 | | world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] ... | [INFO] [stdout] 341 | | }; [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] 284 ~ match &self.record { [INFO] [stdout] 285 + TransactionData::CreateUserAccount(account) => { [INFO] [stdout] 286 + world_state.create_account(account.into(), AccountType::User) [INFO] [stdout] 287 + } [INFO] [stdout] 288 + [INFO] [stdout] 289 + TransactionData::CreateTokens { receiver, amount } => { [INFO] [stdout] 290 + if !is_initial { [INFO] [stdout] 291 + return Err( [INFO] [stdout] 292 + "Token creation is only available on initial creation (Code: 2394233)", [INFO] [stdout] 293 + ); [INFO] [stdout] 294 + } [INFO] [stdout] 295 + // Get the receiving user (must exist) [INFO] [stdout] 296 + return if let Some(account) = world_state.get_account_by_id_mut(receiver) { [INFO] [stdout] 297 + account.tokens += *amount; [INFO] [stdout] 298 + Ok(()) [INFO] [stdout] 299 + } else { [INFO] [stdout] 300 + Err("Receiver Account does not exist (Code: 23482309)") [INFO] [stdout] 301 + }; [INFO] [stdout] 302 + } [INFO] [stdout] 303 + [INFO] [stdout] 304 + TransactionData::TransferTokens { to, amount } => { [INFO] [stdout] 305 + let recv_tokens: u128; [INFO] [stdout] 306 + let sender_tokens: u128; [INFO] [stdout] 307 + [INFO] [stdout] 308 + if let Some(recv) = world_state.get_account_by_id_mut(to) { [INFO] [stdout] 309 + // Be extra careful here, even in the genesis block the sender account has to exist [INFO] [stdout] 310 + recv_tokens = recv.tokens; [INFO] [stdout] 311 + } else { [INFO] [stdout] 312 + return Err("Receiver Account does not exist! (Code: 3242342380)"); [INFO] [stdout] 313 + } [INFO] [stdout] 314 + [INFO] [stdout] 315 + if let Some(sender) = world_state.get_account_by_id_mut(&self.from) { [INFO] [stdout] 316 + sender_tokens = sender.tokens; [INFO] [stdout] 317 + } else { [INFO] [stdout] 318 + return Err("That account does not exist! (Code: 23423923)"); [INFO] [stdout] 319 + } [INFO] [stdout] 320 + [INFO] [stdout] 321 + let balance_recv_new = recv_tokens.checked_add(*amount); [INFO] [stdout] 322 + let balance_sender_new = sender_tokens.checked_sub(*amount); [INFO] [stdout] 323 + [INFO] [stdout] 324 + if balance_recv_new.is_some() && balance_sender_new.is_some() { [INFO] [stdout] 325 + world_state [INFO] [stdout] 326 + .get_account_by_id_mut(&self.from) [INFO] [stdout] 327 + .unwrap() [INFO] [stdout] 328 + .tokens = balance_sender_new.unwrap(); [INFO] [stdout] 329 + world_state.get_account_by_id_mut(to).unwrap().tokens = [INFO] [stdout] 330 + balance_recv_new.unwrap(); [INFO] [stdout] 331 + return Ok(()); [INFO] [stdout] 332 + } else { [INFO] [stdout] 333 + return Err("Overspent or Arithmetic error (Code: 48239084203)"); [INFO] [stdout] 334 + } [INFO] [stdout] 335 + } [INFO] [stdout] 336 + [INFO] [stdout] 337 + _ => { [INFO] [stdout] 338 + // Not implemented transaction type [INFO] [stdout] 339 + Err("Unknown Transaction type (not implemented) (Code: 487289724389)") [INFO] [stdout] 340 + } [INFO] [stdout] 341 ~ } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stdout] warning: unneeded `return` statement [INFO] [stdout] --> src/bchain/mod.rs:353:9 [INFO] [stdout] | [INFO] [stdout] 353 | 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] 353 - return Vec::from(hasher.finalize().as_ref()); [INFO] [stdout] 353 + Vec::from(hasher.finalize().as_ref()) [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/bchain/mod.rs:385:31 [INFO] [stdout] | [INFO] [stdout] 385 | 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] 385 - fn byte_vector_to_string(arr: &Vec) -> String { [INFO] [stdout] 385 + 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:71:5 [INFO] [stdout] | [INFO] [stdout] 71 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 72 | | &mut TransactionData::TransferTokens { [INFO] [stdout] 73 | | to: _, [INFO] [stdout] 74 | | ref mut amount, [INFO] [stdout] ... | [INFO] [stdout] 79 | | _ => {} // We know that that recors is a TransferToken Action so we ignore the rest [INFO] [stdout] 80 | | } [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] 71 ~ if let &mut TransactionData::TransferTokens { [INFO] [stdout] 72 + to: _, [INFO] [stdout] 73 + ref mut amount, [INFO] [stdout] 74 + } = transaction_data.record.borrow_mut() { [INFO] [stdout] 75 + *amount = 100; // Actually change the value in place [INFO] [stdout] 76 + } [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:98:5 [INFO] [stdout] | [INFO] [stdout] 98 | / match transaction_data.record.borrow_mut() { [INFO] [stdout] 99 | | &mut TransactionData::CreateTokens { [INFO] [stdout] 100 | | receiver: _, [INFO] [stdout] 101 | | ref mut amount, [INFO] [stdout] ... | [INFO] [stdout] 105 | | _ => {} // We know that that record is a Token Create Action so we ignore the rest [INFO] [stdout] 106 | | } [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] 98 ~ if let &mut TransactionData::CreateTokens { [INFO] [stdout] 99 + receiver: _, [INFO] [stdout] 100 + ref mut amount, [INFO] [stdout] 101 + } = transaction_data.record.borrow_mut() { [INFO] [stdout] 102 + *amount = 100_000_000_000; // Let's dont be small on that [INFO] [stdout] 103 + } [INFO] [stdout] | [INFO] [stdout] [INFO] [stdout] [INFO] [stderr] Finished `dev` profile [unoptimized + debuginfo] target(s) in 3.39s [INFO] running `Command { std: "docker" "inspect" "e7cb29886fe1b730ba19f7d7e6939d001e863996bc35a5286838c0ef5a84adc0", kill_on_drop: false }` [INFO] running `Command { std: "docker" "rm" "-f" "e7cb29886fe1b730ba19f7d7e6939d001e863996bc35a5286838c0ef5a84adc0", kill_on_drop: false }` [INFO] [stdout] e7cb29886fe1b730ba19f7d7e6939d001e863996bc35a5286838c0ef5a84adc0