├── .gitignore ├── LICENSE ├── README.md ├── intermediate-concepts ├── Cargo.lock ├── Cargo.toml └── src │ ├── closures.rs │ ├── errors.rs │ ├── generics.rs │ ├── macros1.rs │ ├── macros2.rs │ ├── os-commands.rs │ ├── traits1.rs │ └── traits2.rs ├── mining-pool-api ├── .dockerignore ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── README.md ├── diesel.toml ├── docker-compose.yml ├── migrations │ ├── .gitkeep │ ├── 00000000000000_diesel_initial_setup │ │ ├── down.sql │ │ └── up.sql │ └── 2022-03-08-033828_mining_pool_api │ │ ├── down.sql │ │ └── up.sql ├── mining_pool_api_pic.jpg └── src │ ├── main.rs │ ├── miner.rs │ ├── miner_controller.rs │ ├── schema.rs │ ├── util.rs │ ├── wallet.rs │ └── wallet_controller.rs ├── pointers ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs ├── rust-and-docker ├── Cargo.lock ├── Cargo.toml ├── alpine-mismatch.Dockerfile ├── docker-alpine.Dockerfile ├── docker-centos.Dockerfile ├── docker-debian.Dockerfile └── src │ └── main.rs ├── some_bin ├── Cargo.lock ├── Cargo.toml └── src │ └── main.rs └── some_lib ├── Cargo.lock ├── Cargo.toml └── src ├── lib.rs └── some_lib_functions.rs /.gitignore: -------------------------------------------------------------------------------- 1 | rust-and-docker/target/ 2 | intermediate-concepts/target/ 3 | some_bin/target/ 4 | some_lib/target/ 5 | mining-pool-api/target/ 6 | pointers/target/ -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | Copyright 2024 Joe Caulfield 179 | 180 | Licensed under the Apache License, Version 2.0 (the "License"); 181 | you may not use this file except in compliance with the License. 182 | You may obtain a copy of the License at 183 | 184 | http://www.apache.org/licenses/LICENSE-2.0 185 | 186 | Unless required by applicable law or agreed to in writing, software 187 | distributed under the License is distributed on an "AS IS" BASIS, 188 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 189 | See the License for the specific language governing permissions and 190 | limitations under the License. 191 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rust-Intermediate-Tutorial 2 | :movie_camera: [Check it out on YouTube!](https://www.youtube.com/playlist?list=PLUBKxx7QjtVk9cVT9VaTtoDKivyWuLZZf) 3 | 4 | ### Tutorial #1 5 | ```shell 6 | rust-and-docker 7 | ``` 8 | 9 | ### Tutorials #2 - #5 10 | ```shell 11 | intermediate-concepts 12 | ``` 13 | 14 | ### Tutorial #6 15 | ```shell 16 | some_bin 17 | some_lib 18 | ``` 19 | 20 | ### Tutorial #7 21 | ```shell 22 | intermediate-concepts 23 | ``` 24 | 25 | ### Tutorials #8 - #10 26 | ```shell 27 | mining-pool-api 28 | ``` 29 | Check the tags for each video! 30 | Tag `video-1` contains only the Actix and web framework stuff from Part 1. 31 | Tag `video-2` contains Diesel configs and service logic (read/write from db). 32 | Tag `video-3` contains read/write from db with JOINs and also Docker. 33 | `video-3 == master` 34 | 35 | ### Tutorial #11 36 | ```shell 37 | pointers 38 | ``` -------------------------------------------------------------------------------- /intermediate-concepts/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "intermediate-concepts" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /intermediate-concepts/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "intermediate-concepts" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /intermediate-concepts/src/closures.rs: -------------------------------------------------------------------------------- 1 | 2 | 3 | fn closures_example_1(number1: i32, number2: i32) -> i32 { 4 | // Closure 5 | let new_number = |x| { 6 | println!("Multiplying {} by 2", x); 7 | x * 2 8 | }; 9 | if number1 > number2 { 10 | new_number(number1) 11 | } else { 12 | new_number(number2) 13 | } 14 | } 15 | 16 | fn closures_example_2() { 17 | let some_printout = |x| { 18 | println!("Print out: {}", x); 19 | x 20 | }; 21 | println!("{}", some_printout(1)); 22 | println!("{}", some_printout("hello")); 23 | } 24 | 25 | 26 | fn main() { 27 | let x = closures_example_1(1, 3); 28 | println!("{}", x); 29 | let y = closures_example_1(6, 3); 30 | println!("{}", y); 31 | } -------------------------------------------------------------------------------- /intermediate-concepts/src/errors.rs: -------------------------------------------------------------------------------- 1 | 2 | use std::process::Command; 3 | use std::io::{Error, ErrorKind}; 4 | 5 | // Linux only 6 | fn error_handling_example_1(dir: &str) { 7 | 8 | println!("\n\n"); 9 | 10 | let mut list_cmd = Command::new("ls"); 11 | 12 | match list_cmd.current_dir(dir).status() { 13 | Ok(cmd) => cmd, 14 | Err(e) => panic!("Error: {}", e), 15 | }; 16 | 17 | println!("\n\n"); 18 | } 19 | 20 | // Linux only 21 | fn error_handling_example_2(dir: &str) { 22 | 23 | println!("\n\n"); 24 | 25 | let mut list_cmd = Command::new("ls"); 26 | 27 | let x = match list_cmd.current_dir(dir).status() { 28 | Ok(cmd) => Some(cmd), 29 | Err(e) => { 30 | println!("Directory not found!"); 31 | None 32 | }, 33 | }; 34 | 35 | println!("\n\n"); 36 | } 37 | 38 | // Linux only 39 | fn error_handling_example_3(dir: &str) { 40 | 41 | println!("\n\n"); 42 | 43 | let mut list_cmd = Command::new("ls"); 44 | 45 | let x = match list_cmd.current_dir(dir).status() { 46 | Ok(cmd) => Some(cmd), 47 | Err(e) => match e.kind() { 48 | ErrorKind::NotFound => { 49 | println!("Directory not found!"); 50 | None 51 | }, 52 | _ => panic!("An unexpected error has occurred!") 53 | }, 54 | }; 55 | 56 | println!("\n\n"); 57 | } 58 | 59 | // Linux only 60 | fn error_handling_example_4(dir: &str) -> Result { 61 | 62 | println!("\n\n"); 63 | 64 | let mut list_cmd = Command::new("ls"); 65 | 66 | list_cmd.current_dir(dir).status()?; 67 | 68 | println!("\n\n"); 69 | 70 | Ok(1) 71 | } 72 | 73 | fn main() { 74 | error_handling_example_1("src"); 75 | error_handling_example_1("lib"); 76 | error_handling_example_2("src"); 77 | error_handling_example_2("lib"); 78 | error_handling_example_3("src"); 79 | error_handling_example_3("lib"); 80 | error_handling_example_4("src"); 81 | error_handling_example_4("lib"); 82 | } 83 | -------------------------------------------------------------------------------- /intermediate-concepts/src/generics.rs: -------------------------------------------------------------------------------- 1 | 2 | // enum Option { 3 | // Some(T), 4 | // None, 5 | // } 6 | 7 | fn option_example(x: i32) -> Option { 8 | match x > 2 { 9 | true => Some(String::from("result")), 10 | false => None, 11 | } 12 | } 13 | 14 | // enum Result { 15 | // Ok(T), 16 | // Err(E), 17 | // } 18 | 19 | fn error_handling_example_1(dir: &str) { 20 | 21 | println!("\n\n"); 22 | 23 | let mut list_cmd = std::process::Command::new("ls"); 24 | 25 | match list_cmd.current_dir(dir).status() { 26 | Ok(cmd) => cmd, 27 | Err(e) => panic!("Error: {}", e), 28 | }; 29 | 30 | println!("\n\n"); 31 | } 32 | 33 | enum Custom { 34 | EXAMPLE(T), 35 | SAMPLE(U), 36 | } 37 | 38 | 39 | // Structs 40 | 41 | struct Rectangle { 42 | height: T, 43 | width: T, 44 | } 45 | 46 | struct Cube { 47 | height: T, 48 | width: U, 49 | length: V, 50 | } 51 | 52 | fn struct_example() { 53 | 54 | let rect1 = Rectangle{height: 1, width: 2}; 55 | let rect1 = Rectangle{height: 1.65, width: 2.22}; 56 | 57 | let cube1 = Cube{height: 1, width: 2, length: 3}; 58 | let cube1 = Cube{height: 1.54, width: 2, length: 3.75}; 59 | } 60 | 61 | 62 | // Functions 63 | 64 | fn sum_of_numbers>(num1: T, num2: T) -> T { 65 | num1 * num2 66 | } 67 | 68 | fn lookup_datatype(object: T) { 69 | println!("{}", std::any::type_name::()); 70 | } 71 | 72 | fn main() { 73 | println!("{}", sum_of_numbers(1, 2)); 74 | lookup_datatype(1); 75 | lookup_datatype(1.96); 76 | lookup_datatype("string_slice"); 77 | } -------------------------------------------------------------------------------- /intermediate-concepts/src/macros1.rs: -------------------------------------------------------------------------------- 1 | 2 | #[macro_export] 3 | macro_rules! vec { 4 | ( $( $x:expr ),* ) => { 5 | { 6 | let mut temp_vec = Vec::new(); 7 | $( 8 | temp_vec.push(($x)); 9 | )* 10 | temp_vec 11 | } 12 | }; 13 | } 14 | 15 | // Make this macro available elsewhere 16 | #[macro_export] 17 | // Establish the name of the macro 18 | macro_rules! vec { 19 | // Match any Rust expression [$x:expr] 20 | // Allows one or more of them [,*] 21 | ( $( $x:expr ),* ) => { 22 | { 23 | // Create a temporary empty vector 24 | let mut temp_vec = Vec::new(); 25 | // Generate this command for all expressions 26 | $( 27 | temp_vec.push(($x)); 28 | )* 29 | temp_vec 30 | } 31 | }; 32 | } 33 | 34 | { 35 | let mut temp_vec = Vec::new(); 36 | temp_vec.push(1); 37 | temp_vec.push(2); 38 | temp_vec 39 | } -------------------------------------------------------------------------------- /intermediate-concepts/src/macros2.rs: -------------------------------------------------------------------------------- 1 | use std::collections::HashMap; 2 | 3 | #[macro_export] 4 | macro_rules! make_map { 5 | ( $k:expr, $v:expr ) => { 6 | { 7 | println!("Key: {}", $k); 8 | println!("Value: {}", $v); 9 | let mut map = HashMap::new(); 10 | map.insert($k, $v); 11 | map 12 | } 13 | }; 14 | } 15 | 16 | #[macro_export] 17 | macro_rules! make_map_2 { 18 | ( $( ( $k:expr, $v:expr ) ),* ) => { 19 | { 20 | let mut map = HashMap::new(); 21 | $( 22 | println!("Key: {}", $k); 23 | println!("Value: {}", $v); 24 | map.insert($k, $v); 25 | )* 26 | map 27 | } 28 | }; 29 | } 30 | 31 | 32 | fn main() { 33 | let int_map: HashMap = make_map!(1, 3); 34 | println!("{:#?}", int_map); 35 | let str_map: HashMap<&str, &str> = make_map!("green", "go"); 36 | println!("{:#?}", str_map); 37 | 38 | let int_map_2: HashMap = make_map_2![ 39 | (1, 3), 40 | (2, -1), 41 | (3, 5) 42 | ]; 43 | println!("{:#?}", int_map_2); 44 | let str_map_2: HashMap<&str, &str> = make_map_2![ 45 | ("green", "go"), 46 | ("yellow", "slow"), 47 | ("red", "stop") 48 | ]; 49 | println!("{:#?}", str_map_2); 50 | } -------------------------------------------------------------------------------- /intermediate-concepts/src/os-commands.rs: -------------------------------------------------------------------------------- 1 | 2 | use std::process::Command; 3 | 4 | fn os_commands_example_1() { 5 | let echo_cmd = if cfg!(target_os = "windows") { 6 | Command::new("cmd") 7 | .args(["/C", "echo aye there from Windows!"]) 8 | .output() 9 | .expect("Failed to execute command.") 10 | } else { 11 | Command::new("sh") 12 | .args(["-c", "echo ahoy there from Linux!"]) 13 | .output() 14 | .expect("Failed to execute command.") 15 | }; 16 | println!("\n\n"); 17 | let cmd_output = String::from_utf8(echo_cmd.stdout).expect("Could not parse byte response."); 18 | println!("{}", cmd_output); 19 | println!("\n\n"); 20 | } 21 | 22 | // Linux only 23 | fn os_commands_example_2() { 24 | 25 | println!("\n\n"); 26 | 27 | let mut cmd_root = Command::new("ls"); 28 | 29 | cmd_root.status().expect("Failed to execute list command."); 30 | 31 | println!("\n\n"); 32 | 33 | cmd_root.current_dir("src").status().expect("Failed to execute list command."); 34 | 35 | println!("\n\n"); 36 | } 37 | 38 | fn main() { 39 | os_commands_example_1(); 40 | os_commands_example_2(); 41 | } 42 | -------------------------------------------------------------------------------- /intermediate-concepts/src/traits1.rs: -------------------------------------------------------------------------------- 1 | 2 | pub trait Vehicle { 3 | 4 | fn forward() -> String; 5 | fn backward() -> String; 6 | 7 | fn turn_ignition() -> String { 8 | String::from("vroom vroom") 9 | } 10 | } 11 | 12 | pub struct Car { 13 | color: String, 14 | } 15 | 16 | impl Vehicle for Car { 17 | fn forward() -> String { 18 | String::from("Driving my car forward") 19 | } 20 | fn backward() -> String { 21 | String::from("Backing my car up...") 22 | } 23 | } 24 | 25 | pub struct Truck { 26 | color: String, 27 | } 28 | 29 | impl Vehicle for Truck { 30 | fn forward() -> String { 31 | String::from("Driving my truck forward") 32 | } 33 | fn backward() -> String { 34 | String::from("Backing my truck up...") 35 | } 36 | } 37 | 38 | fn main() { 39 | println!("{}", Car::turn_ignition()); 40 | println!("{}", Car::forward()); 41 | println!("{}", Car::backward()); 42 | println!("{}", Truck::turn_ignition()); 43 | println!("{}", Truck::forward()); 44 | println!("{}", Truck::backward()); 45 | } -------------------------------------------------------------------------------- /intermediate-concepts/src/traits2.rs: -------------------------------------------------------------------------------- 1 | 2 | pub trait Vehicle { 3 | 4 | fn forward(&self) -> String; 5 | fn backward(&self) -> String; 6 | 7 | fn turn_ignition() -> String { 8 | String::from("vroom vroom") 9 | } 10 | } 11 | 12 | pub struct Car { 13 | color: String, 14 | } 15 | 16 | impl Vehicle for Car { 17 | fn forward(&self) -> String { 18 | String::from(format!("Driving my {} car forward", self.color)) 19 | } 20 | fn backward(&self) -> String { 21 | String::from(format!("Backing my {} car up...", self.color)) 22 | } 23 | } 24 | 25 | pub struct Truck { 26 | color: String, 27 | } 28 | 29 | impl Vehicle for Truck { 30 | fn forward(&self) -> String { 31 | String::from(format!("Driving my {} truck forward", self.color)) 32 | } 33 | fn backward(&self) -> String { 34 | String::from(format!("Backing my {} truck up...", self.color)) 35 | } 36 | } 37 | 38 | fn main() { 39 | 40 | println!("{}", Car::turn_ignition()); 41 | 42 | let car = Car{color: String::from("green")}; 43 | println!("{}", car.forward()); 44 | println!("{}", car.backward()); 45 | 46 | println!("{}", Truck::turn_ignition()); 47 | 48 | let truck = Truck{color: String::from("blue")}; 49 | println!("{}", truck.forward()); 50 | println!("{}", truck.backward()); 51 | } -------------------------------------------------------------------------------- /mining-pool-api/.dockerignore: -------------------------------------------------------------------------------- 1 | Cargo.lock 2 | Dockerfile 3 | docker-compose.yml 4 | README.md 5 | mining_pool_api_pic.jpg 6 | target/ -------------------------------------------------------------------------------- /mining-pool-api/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "actix-codec" 7 | version = "0.3.0" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "78d1833b3838dbe990df0f1f87baf640cf6146e898166afe401839d1b001e570" 10 | dependencies = [ 11 | "bitflags", 12 | "bytes 0.5.6", 13 | "futures-core", 14 | "futures-sink", 15 | "log", 16 | "pin-project 0.4.29", 17 | "tokio", 18 | "tokio-util", 19 | ] 20 | 21 | [[package]] 22 | name = "actix-connect" 23 | version = "2.0.0" 24 | source = "registry+https://github.com/rust-lang/crates.io-index" 25 | checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc" 26 | dependencies = [ 27 | "actix-codec", 28 | "actix-rt", 29 | "actix-service", 30 | "actix-utils", 31 | "derive_more", 32 | "either", 33 | "futures-util", 34 | "http", 35 | "log", 36 | "trust-dns-proto", 37 | "trust-dns-resolver", 38 | ] 39 | 40 | [[package]] 41 | name = "actix-http" 42 | version = "2.2.2" 43 | source = "registry+https://github.com/rust-lang/crates.io-index" 44 | checksum = "2be6b66b62a794a8e6d366ac9415bb7d475ffd1e9f4671f38c1d8a8a5df950b3" 45 | dependencies = [ 46 | "actix-codec", 47 | "actix-connect", 48 | "actix-rt", 49 | "actix-service", 50 | "actix-threadpool", 51 | "actix-utils", 52 | "base64", 53 | "bitflags", 54 | "brotli", 55 | "bytes 0.5.6", 56 | "cookie", 57 | "copyless", 58 | "derive_more", 59 | "either", 60 | "encoding_rs", 61 | "flate2", 62 | "futures-channel", 63 | "futures-core", 64 | "futures-util", 65 | "fxhash", 66 | "h2", 67 | "http", 68 | "httparse", 69 | "indexmap", 70 | "itoa 0.4.8", 71 | "language-tags", 72 | "lazy_static", 73 | "log", 74 | "mime", 75 | "percent-encoding", 76 | "pin-project 1.0.10", 77 | "rand 0.7.3", 78 | "regex", 79 | "serde", 80 | "serde_json", 81 | "serde_urlencoded", 82 | "sha-1", 83 | "slab", 84 | "time 0.2.27", 85 | ] 86 | 87 | [[package]] 88 | name = "actix-macros" 89 | version = "0.1.3" 90 | source = "registry+https://github.com/rust-lang/crates.io-index" 91 | checksum = "b4ca8ce00b267af8ccebbd647de0d61e0674b6e61185cc7a592ff88772bed655" 92 | dependencies = [ 93 | "quote", 94 | "syn", 95 | ] 96 | 97 | [[package]] 98 | name = "actix-router" 99 | version = "0.2.7" 100 | source = "registry+https://github.com/rust-lang/crates.io-index" 101 | checksum = "2ad299af73649e1fc893e333ccf86f377751eb95ff875d095131574c6f43452c" 102 | dependencies = [ 103 | "bytestring", 104 | "http", 105 | "log", 106 | "regex", 107 | "serde", 108 | ] 109 | 110 | [[package]] 111 | name = "actix-rt" 112 | version = "1.1.1" 113 | source = "registry+https://github.com/rust-lang/crates.io-index" 114 | checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" 115 | dependencies = [ 116 | "actix-macros", 117 | "actix-threadpool", 118 | "copyless", 119 | "futures-channel", 120 | "futures-util", 121 | "smallvec", 122 | "tokio", 123 | ] 124 | 125 | [[package]] 126 | name = "actix-server" 127 | version = "1.0.4" 128 | source = "registry+https://github.com/rust-lang/crates.io-index" 129 | checksum = "45407e6e672ca24784baa667c5d32ef109ccdd8d5e0b5ebb9ef8a67f4dfb708e" 130 | dependencies = [ 131 | "actix-codec", 132 | "actix-rt", 133 | "actix-service", 134 | "actix-utils", 135 | "futures-channel", 136 | "futures-util", 137 | "log", 138 | "mio", 139 | "mio-uds", 140 | "num_cpus", 141 | "slab", 142 | "socket2", 143 | ] 144 | 145 | [[package]] 146 | name = "actix-service" 147 | version = "1.0.6" 148 | source = "registry+https://github.com/rust-lang/crates.io-index" 149 | checksum = "0052435d581b5be835d11f4eb3bce417c8af18d87ddf8ace99f8e67e595882bb" 150 | dependencies = [ 151 | "futures-util", 152 | "pin-project 0.4.29", 153 | ] 154 | 155 | [[package]] 156 | name = "actix-testing" 157 | version = "1.0.1" 158 | source = "registry+https://github.com/rust-lang/crates.io-index" 159 | checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c" 160 | dependencies = [ 161 | "actix-macros", 162 | "actix-rt", 163 | "actix-server", 164 | "actix-service", 165 | "log", 166 | "socket2", 167 | ] 168 | 169 | [[package]] 170 | name = "actix-threadpool" 171 | version = "0.3.3" 172 | source = "registry+https://github.com/rust-lang/crates.io-index" 173 | checksum = "d209f04d002854b9afd3743032a27b066158817965bf5d036824d19ac2cc0e30" 174 | dependencies = [ 175 | "derive_more", 176 | "futures-channel", 177 | "lazy_static", 178 | "log", 179 | "num_cpus", 180 | "parking_lot", 181 | "threadpool", 182 | ] 183 | 184 | [[package]] 185 | name = "actix-tls" 186 | version = "2.0.0" 187 | source = "registry+https://github.com/rust-lang/crates.io-index" 188 | checksum = "24789b7d7361cf5503a504ebe1c10806896f61e96eca9a7350e23001aca715fb" 189 | dependencies = [ 190 | "actix-codec", 191 | "actix-service", 192 | "actix-utils", 193 | "futures-util", 194 | ] 195 | 196 | [[package]] 197 | name = "actix-utils" 198 | version = "2.0.0" 199 | source = "registry+https://github.com/rust-lang/crates.io-index" 200 | checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a" 201 | dependencies = [ 202 | "actix-codec", 203 | "actix-rt", 204 | "actix-service", 205 | "bitflags", 206 | "bytes 0.5.6", 207 | "either", 208 | "futures-channel", 209 | "futures-sink", 210 | "futures-util", 211 | "log", 212 | "pin-project 0.4.29", 213 | "slab", 214 | ] 215 | 216 | [[package]] 217 | name = "actix-web" 218 | version = "3.3.3" 219 | source = "registry+https://github.com/rust-lang/crates.io-index" 220 | checksum = "b6534a126df581caf443ba2751cab42092c89b3f1d06a9d829b1e17edfe3e277" 221 | dependencies = [ 222 | "actix-codec", 223 | "actix-http", 224 | "actix-macros", 225 | "actix-router", 226 | "actix-rt", 227 | "actix-server", 228 | "actix-service", 229 | "actix-testing", 230 | "actix-threadpool", 231 | "actix-tls", 232 | "actix-utils", 233 | "actix-web-codegen", 234 | "awc", 235 | "bytes 0.5.6", 236 | "derive_more", 237 | "encoding_rs", 238 | "futures-channel", 239 | "futures-core", 240 | "futures-util", 241 | "fxhash", 242 | "log", 243 | "mime", 244 | "pin-project 1.0.10", 245 | "regex", 246 | "serde", 247 | "serde_json", 248 | "serde_urlencoded", 249 | "socket2", 250 | "time 0.2.27", 251 | "tinyvec", 252 | "url", 253 | ] 254 | 255 | [[package]] 256 | name = "actix-web-codegen" 257 | version = "0.4.0" 258 | source = "registry+https://github.com/rust-lang/crates.io-index" 259 | checksum = "ad26f77093333e0e7c6ffe54ebe3582d908a104e448723eec6d43d08b07143fb" 260 | dependencies = [ 261 | "proc-macro2", 262 | "quote", 263 | "syn", 264 | ] 265 | 266 | [[package]] 267 | name = "adler" 268 | version = "1.0.2" 269 | source = "registry+https://github.com/rust-lang/crates.io-index" 270 | checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" 271 | 272 | [[package]] 273 | name = "aho-corasick" 274 | version = "0.7.18" 275 | source = "registry+https://github.com/rust-lang/crates.io-index" 276 | checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f" 277 | dependencies = [ 278 | "memchr", 279 | ] 280 | 281 | [[package]] 282 | name = "alloc-no-stdlib" 283 | version = "2.0.3" 284 | source = "registry+https://github.com/rust-lang/crates.io-index" 285 | checksum = "35ef4730490ad1c4eae5c4325b2a95f521d023e5c885853ff7aca0a6a1631db3" 286 | 287 | [[package]] 288 | name = "alloc-stdlib" 289 | version = "0.2.1" 290 | source = "registry+https://github.com/rust-lang/crates.io-index" 291 | checksum = "697ed7edc0f1711de49ce108c541623a0af97c6c60b2f6e2b65229847ac843c2" 292 | dependencies = [ 293 | "alloc-no-stdlib", 294 | ] 295 | 296 | [[package]] 297 | name = "async-trait" 298 | version = "0.1.52" 299 | source = "registry+https://github.com/rust-lang/crates.io-index" 300 | checksum = "061a7acccaa286c011ddc30970520b98fa40e00c9d644633fb26b5fc63a265e3" 301 | dependencies = [ 302 | "proc-macro2", 303 | "quote", 304 | "syn", 305 | ] 306 | 307 | [[package]] 308 | name = "atty" 309 | version = "0.2.14" 310 | source = "registry+https://github.com/rust-lang/crates.io-index" 311 | checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" 312 | dependencies = [ 313 | "hermit-abi", 314 | "libc", 315 | "winapi 0.3.9", 316 | ] 317 | 318 | [[package]] 319 | name = "autocfg" 320 | version = "1.1.0" 321 | source = "registry+https://github.com/rust-lang/crates.io-index" 322 | checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" 323 | 324 | [[package]] 325 | name = "awc" 326 | version = "2.0.3" 327 | source = "registry+https://github.com/rust-lang/crates.io-index" 328 | checksum = "b381e490e7b0cfc37ebc54079b0413d8093ef43d14a4e4747083f7fa47a9e691" 329 | dependencies = [ 330 | "actix-codec", 331 | "actix-http", 332 | "actix-rt", 333 | "actix-service", 334 | "base64", 335 | "bytes 0.5.6", 336 | "cfg-if 1.0.0", 337 | "derive_more", 338 | "futures-core", 339 | "log", 340 | "mime", 341 | "percent-encoding", 342 | "rand 0.7.3", 343 | "serde", 344 | "serde_json", 345 | "serde_urlencoded", 346 | ] 347 | 348 | [[package]] 349 | name = "base-x" 350 | version = "0.2.8" 351 | source = "registry+https://github.com/rust-lang/crates.io-index" 352 | checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" 353 | 354 | [[package]] 355 | name = "base64" 356 | version = "0.13.0" 357 | source = "registry+https://github.com/rust-lang/crates.io-index" 358 | checksum = "904dfeac50f3cdaba28fc6f57fdcddb75f49ed61346676a78c4ffe55877802fd" 359 | 360 | [[package]] 361 | name = "bitflags" 362 | version = "1.3.2" 363 | source = "registry+https://github.com/rust-lang/crates.io-index" 364 | checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" 365 | 366 | [[package]] 367 | name = "block-buffer" 368 | version = "0.9.0" 369 | source = "registry+https://github.com/rust-lang/crates.io-index" 370 | checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" 371 | dependencies = [ 372 | "generic-array", 373 | ] 374 | 375 | [[package]] 376 | name = "brotli" 377 | version = "3.3.3" 378 | source = "registry+https://github.com/rust-lang/crates.io-index" 379 | checksum = "f838e47a451d5a8fa552371f80024dd6ace9b7acdf25c4c3d0f9bc6816fb1c39" 380 | dependencies = [ 381 | "alloc-no-stdlib", 382 | "alloc-stdlib", 383 | "brotli-decompressor", 384 | ] 385 | 386 | [[package]] 387 | name = "brotli-decompressor" 388 | version = "2.3.2" 389 | source = "registry+https://github.com/rust-lang/crates.io-index" 390 | checksum = "59ad2d4653bf5ca36ae797b1f4bb4dbddb60ce49ca4aed8a2ce4829f60425b80" 391 | dependencies = [ 392 | "alloc-no-stdlib", 393 | "alloc-stdlib", 394 | ] 395 | 396 | [[package]] 397 | name = "bumpalo" 398 | version = "3.9.1" 399 | source = "registry+https://github.com/rust-lang/crates.io-index" 400 | checksum = "a4a45a46ab1f2412e53d3a0ade76ffad2025804294569aae387231a0cd6e0899" 401 | 402 | [[package]] 403 | name = "byteorder" 404 | version = "1.4.3" 405 | source = "registry+https://github.com/rust-lang/crates.io-index" 406 | checksum = "14c189c53d098945499cdfa7ecc63567cf3886b3332b312a5b4585d8d3a6a610" 407 | 408 | [[package]] 409 | name = "bytes" 410 | version = "0.5.6" 411 | source = "registry+https://github.com/rust-lang/crates.io-index" 412 | checksum = "0e4cec68f03f32e44924783795810fa50a7035d8c8ebe78580ad7e6c703fba38" 413 | 414 | [[package]] 415 | name = "bytes" 416 | version = "1.1.0" 417 | source = "registry+https://github.com/rust-lang/crates.io-index" 418 | checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" 419 | 420 | [[package]] 421 | name = "bytestring" 422 | version = "1.0.0" 423 | source = "registry+https://github.com/rust-lang/crates.io-index" 424 | checksum = "90706ba19e97b90786e19dc0d5e2abd80008d99d4c0c5d1ad0b5e72cec7c494d" 425 | dependencies = [ 426 | "bytes 1.1.0", 427 | ] 428 | 429 | [[package]] 430 | name = "cfg-if" 431 | version = "0.1.10" 432 | source = "registry+https://github.com/rust-lang/crates.io-index" 433 | checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" 434 | 435 | [[package]] 436 | name = "cfg-if" 437 | version = "1.0.0" 438 | source = "registry+https://github.com/rust-lang/crates.io-index" 439 | checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" 440 | 441 | [[package]] 442 | name = "chrono" 443 | version = "0.4.19" 444 | source = "registry+https://github.com/rust-lang/crates.io-index" 445 | checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" 446 | dependencies = [ 447 | "libc", 448 | "num-integer", 449 | "num-traits", 450 | "time 0.1.43", 451 | "winapi 0.3.9", 452 | ] 453 | 454 | [[package]] 455 | name = "const_fn" 456 | version = "0.4.9" 457 | source = "registry+https://github.com/rust-lang/crates.io-index" 458 | checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" 459 | 460 | [[package]] 461 | name = "convert_case" 462 | version = "0.4.0" 463 | source = "registry+https://github.com/rust-lang/crates.io-index" 464 | checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" 465 | 466 | [[package]] 467 | name = "cookie" 468 | version = "0.14.4" 469 | source = "registry+https://github.com/rust-lang/crates.io-index" 470 | checksum = "03a5d7b21829bc7b4bf4754a978a241ae54ea55a40f92bb20216e54096f4b951" 471 | dependencies = [ 472 | "percent-encoding", 473 | "time 0.2.27", 474 | "version_check", 475 | ] 476 | 477 | [[package]] 478 | name = "copyless" 479 | version = "0.1.5" 480 | source = "registry+https://github.com/rust-lang/crates.io-index" 481 | checksum = "a2df960f5d869b2dd8532793fde43eb5427cceb126c929747a26823ab0eeb536" 482 | 483 | [[package]] 484 | name = "cpufeatures" 485 | version = "0.2.1" 486 | source = "registry+https://github.com/rust-lang/crates.io-index" 487 | checksum = "95059428f66df56b63431fdb4e1947ed2190586af5c5a8a8b71122bdf5a7f469" 488 | dependencies = [ 489 | "libc", 490 | ] 491 | 492 | [[package]] 493 | name = "crc32fast" 494 | version = "1.3.2" 495 | source = "registry+https://github.com/rust-lang/crates.io-index" 496 | checksum = "b540bd8bc810d3885c6ea91e2018302f68baba2129ab3e88f32389ee9370880d" 497 | dependencies = [ 498 | "cfg-if 1.0.0", 499 | ] 500 | 501 | [[package]] 502 | name = "derive_more" 503 | version = "0.99.17" 504 | source = "registry+https://github.com/rust-lang/crates.io-index" 505 | checksum = "4fb810d30a7c1953f91334de7244731fc3f3c10d7fe163338a35b9f640960321" 506 | dependencies = [ 507 | "convert_case", 508 | "proc-macro2", 509 | "quote", 510 | "rustc_version 0.4.0", 511 | "syn", 512 | ] 513 | 514 | [[package]] 515 | name = "diesel" 516 | version = "1.4.8" 517 | source = "registry+https://github.com/rust-lang/crates.io-index" 518 | checksum = "b28135ecf6b7d446b43e27e225622a038cc4e2930a1022f51cdb97ada19b8e4d" 519 | dependencies = [ 520 | "bitflags", 521 | "byteorder", 522 | "chrono", 523 | "diesel_derives", 524 | "pq-sys", 525 | "r2d2", 526 | "uuid", 527 | ] 528 | 529 | [[package]] 530 | name = "diesel_derives" 531 | version = "1.4.1" 532 | source = "registry+https://github.com/rust-lang/crates.io-index" 533 | checksum = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" 534 | dependencies = [ 535 | "proc-macro2", 536 | "quote", 537 | "syn", 538 | ] 539 | 540 | [[package]] 541 | name = "digest" 542 | version = "0.9.0" 543 | source = "registry+https://github.com/rust-lang/crates.io-index" 544 | checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" 545 | dependencies = [ 546 | "generic-array", 547 | ] 548 | 549 | [[package]] 550 | name = "discard" 551 | version = "1.0.4" 552 | source = "registry+https://github.com/rust-lang/crates.io-index" 553 | checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" 554 | 555 | [[package]] 556 | name = "either" 557 | version = "1.6.1" 558 | source = "registry+https://github.com/rust-lang/crates.io-index" 559 | checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" 560 | 561 | [[package]] 562 | name = "encoding_rs" 563 | version = "0.8.30" 564 | source = "registry+https://github.com/rust-lang/crates.io-index" 565 | checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" 566 | dependencies = [ 567 | "cfg-if 1.0.0", 568 | ] 569 | 570 | [[package]] 571 | name = "enum-as-inner" 572 | version = "0.3.4" 573 | source = "registry+https://github.com/rust-lang/crates.io-index" 574 | checksum = "570d109b813e904becc80d8d5da38376818a143348413f7149f1340fe04754d4" 575 | dependencies = [ 576 | "heck", 577 | "proc-macro2", 578 | "quote", 579 | "syn", 580 | ] 581 | 582 | [[package]] 583 | name = "env_logger" 584 | version = "0.7.1" 585 | source = "registry+https://github.com/rust-lang/crates.io-index" 586 | checksum = "44533bbbb3bb3c1fa17d9f2e4e38bbbaf8396ba82193c4cb1b6445d711445d36" 587 | dependencies = [ 588 | "atty", 589 | "humantime", 590 | "log", 591 | "regex", 592 | "termcolor", 593 | ] 594 | 595 | [[package]] 596 | name = "flate2" 597 | version = "1.0.22" 598 | source = "registry+https://github.com/rust-lang/crates.io-index" 599 | checksum = "1e6988e897c1c9c485f43b47a529cef42fde0547f9d8d41a7062518f1d8fc53f" 600 | dependencies = [ 601 | "cfg-if 1.0.0", 602 | "crc32fast", 603 | "libc", 604 | "miniz_oxide", 605 | ] 606 | 607 | [[package]] 608 | name = "fnv" 609 | version = "1.0.7" 610 | source = "registry+https://github.com/rust-lang/crates.io-index" 611 | checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" 612 | 613 | [[package]] 614 | name = "form_urlencoded" 615 | version = "1.0.1" 616 | source = "registry+https://github.com/rust-lang/crates.io-index" 617 | checksum = "5fc25a87fa4fd2094bffb06925852034d90a17f0d1e05197d4956d3555752191" 618 | dependencies = [ 619 | "matches", 620 | "percent-encoding", 621 | ] 622 | 623 | [[package]] 624 | name = "fuchsia-cprng" 625 | version = "0.1.1" 626 | source = "registry+https://github.com/rust-lang/crates.io-index" 627 | checksum = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba" 628 | 629 | [[package]] 630 | name = "fuchsia-zircon" 631 | version = "0.3.3" 632 | source = "registry+https://github.com/rust-lang/crates.io-index" 633 | checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" 634 | dependencies = [ 635 | "bitflags", 636 | "fuchsia-zircon-sys", 637 | ] 638 | 639 | [[package]] 640 | name = "fuchsia-zircon-sys" 641 | version = "0.3.3" 642 | source = "registry+https://github.com/rust-lang/crates.io-index" 643 | checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" 644 | 645 | [[package]] 646 | name = "futures" 647 | version = "0.3.21" 648 | source = "registry+https://github.com/rust-lang/crates.io-index" 649 | checksum = "f73fe65f54d1e12b726f517d3e2135ca3125a437b6d998caf1962961f7172d9e" 650 | dependencies = [ 651 | "futures-channel", 652 | "futures-core", 653 | "futures-io", 654 | "futures-sink", 655 | "futures-task", 656 | "futures-util", 657 | ] 658 | 659 | [[package]] 660 | name = "futures-channel" 661 | version = "0.3.21" 662 | source = "registry+https://github.com/rust-lang/crates.io-index" 663 | checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" 664 | dependencies = [ 665 | "futures-core", 666 | "futures-sink", 667 | ] 668 | 669 | [[package]] 670 | name = "futures-core" 671 | version = "0.3.21" 672 | source = "registry+https://github.com/rust-lang/crates.io-index" 673 | checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" 674 | 675 | [[package]] 676 | name = "futures-io" 677 | version = "0.3.21" 678 | source = "registry+https://github.com/rust-lang/crates.io-index" 679 | checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" 680 | 681 | [[package]] 682 | name = "futures-macro" 683 | version = "0.3.21" 684 | source = "registry+https://github.com/rust-lang/crates.io-index" 685 | checksum = "33c1e13800337f4d4d7a316bf45a567dbcb6ffe087f16424852d97e97a91f512" 686 | dependencies = [ 687 | "proc-macro2", 688 | "quote", 689 | "syn", 690 | ] 691 | 692 | [[package]] 693 | name = "futures-sink" 694 | version = "0.3.21" 695 | source = "registry+https://github.com/rust-lang/crates.io-index" 696 | checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" 697 | 698 | [[package]] 699 | name = "futures-task" 700 | version = "0.3.21" 701 | source = "registry+https://github.com/rust-lang/crates.io-index" 702 | checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" 703 | 704 | [[package]] 705 | name = "futures-util" 706 | version = "0.3.21" 707 | source = "registry+https://github.com/rust-lang/crates.io-index" 708 | checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" 709 | dependencies = [ 710 | "futures-channel", 711 | "futures-core", 712 | "futures-io", 713 | "futures-macro", 714 | "futures-sink", 715 | "futures-task", 716 | "memchr", 717 | "pin-project-lite 0.2.8", 718 | "pin-utils", 719 | "slab", 720 | ] 721 | 722 | [[package]] 723 | name = "fxhash" 724 | version = "0.2.1" 725 | source = "registry+https://github.com/rust-lang/crates.io-index" 726 | checksum = "c31b6d751ae2c7f11320402d34e41349dd1016f8d5d45e48c4312bc8625af50c" 727 | dependencies = [ 728 | "byteorder", 729 | ] 730 | 731 | [[package]] 732 | name = "generic-array" 733 | version = "0.14.5" 734 | source = "registry+https://github.com/rust-lang/crates.io-index" 735 | checksum = "fd48d33ec7f05fbfa152300fdad764757cbded343c1aa1cff2fbaf4134851803" 736 | dependencies = [ 737 | "typenum", 738 | "version_check", 739 | ] 740 | 741 | [[package]] 742 | name = "getrandom" 743 | version = "0.1.16" 744 | source = "registry+https://github.com/rust-lang/crates.io-index" 745 | checksum = "8fc3cb4d91f53b50155bdcfd23f6a4c39ae1969c2ae85982b135750cccaf5fce" 746 | dependencies = [ 747 | "cfg-if 1.0.0", 748 | "libc", 749 | "wasi 0.9.0+wasi-snapshot-preview1", 750 | ] 751 | 752 | [[package]] 753 | name = "getrandom" 754 | version = "0.2.5" 755 | source = "registry+https://github.com/rust-lang/crates.io-index" 756 | checksum = "d39cd93900197114fa1fcb7ae84ca742095eed9442088988ae74fa744e930e77" 757 | dependencies = [ 758 | "cfg-if 1.0.0", 759 | "libc", 760 | "wasi 0.10.2+wasi-snapshot-preview1", 761 | ] 762 | 763 | [[package]] 764 | name = "h2" 765 | version = "0.2.7" 766 | source = "registry+https://github.com/rust-lang/crates.io-index" 767 | checksum = "5e4728fd124914ad25e99e3d15a9361a879f6620f63cb56bbb08f95abb97a535" 768 | dependencies = [ 769 | "bytes 0.5.6", 770 | "fnv", 771 | "futures-core", 772 | "futures-sink", 773 | "futures-util", 774 | "http", 775 | "indexmap", 776 | "slab", 777 | "tokio", 778 | "tokio-util", 779 | "tracing", 780 | "tracing-futures", 781 | ] 782 | 783 | [[package]] 784 | name = "hashbrown" 785 | version = "0.11.2" 786 | source = "registry+https://github.com/rust-lang/crates.io-index" 787 | checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" 788 | 789 | [[package]] 790 | name = "heck" 791 | version = "0.4.0" 792 | source = "registry+https://github.com/rust-lang/crates.io-index" 793 | checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9" 794 | 795 | [[package]] 796 | name = "hermit-abi" 797 | version = "0.1.19" 798 | source = "registry+https://github.com/rust-lang/crates.io-index" 799 | checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33" 800 | dependencies = [ 801 | "libc", 802 | ] 803 | 804 | [[package]] 805 | name = "hostname" 806 | version = "0.3.1" 807 | source = "registry+https://github.com/rust-lang/crates.io-index" 808 | checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" 809 | dependencies = [ 810 | "libc", 811 | "match_cfg", 812 | "winapi 0.3.9", 813 | ] 814 | 815 | [[package]] 816 | name = "http" 817 | version = "0.2.6" 818 | source = "registry+https://github.com/rust-lang/crates.io-index" 819 | checksum = "31f4c6746584866f0feabcc69893c5b51beef3831656a968ed7ae254cdc4fd03" 820 | dependencies = [ 821 | "bytes 1.1.0", 822 | "fnv", 823 | "itoa 1.0.1", 824 | ] 825 | 826 | [[package]] 827 | name = "httparse" 828 | version = "1.6.0" 829 | source = "registry+https://github.com/rust-lang/crates.io-index" 830 | checksum = "9100414882e15fb7feccb4897e5f0ff0ff1ca7d1a86a23208ada4d7a18e6c6c4" 831 | 832 | [[package]] 833 | name = "humantime" 834 | version = "1.3.0" 835 | source = "registry+https://github.com/rust-lang/crates.io-index" 836 | checksum = "df004cfca50ef23c36850aaaa59ad52cc70d0e90243c3c7737a4dd32dc7a3c4f" 837 | dependencies = [ 838 | "quick-error", 839 | ] 840 | 841 | [[package]] 842 | name = "idna" 843 | version = "0.2.3" 844 | source = "registry+https://github.com/rust-lang/crates.io-index" 845 | checksum = "418a0a6fab821475f634efe3ccc45c013f742efe03d853e8d3355d5cb850ecf8" 846 | dependencies = [ 847 | "matches", 848 | "unicode-bidi", 849 | "unicode-normalization", 850 | ] 851 | 852 | [[package]] 853 | name = "indexmap" 854 | version = "1.8.0" 855 | source = "registry+https://github.com/rust-lang/crates.io-index" 856 | checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" 857 | dependencies = [ 858 | "autocfg", 859 | "hashbrown", 860 | ] 861 | 862 | [[package]] 863 | name = "instant" 864 | version = "0.1.12" 865 | source = "registry+https://github.com/rust-lang/crates.io-index" 866 | checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" 867 | dependencies = [ 868 | "cfg-if 1.0.0", 869 | ] 870 | 871 | [[package]] 872 | name = "iovec" 873 | version = "0.1.4" 874 | source = "registry+https://github.com/rust-lang/crates.io-index" 875 | checksum = "b2b3ea6ff95e175473f8ffe6a7eb7c00d054240321b84c57051175fe3c1e075e" 876 | dependencies = [ 877 | "libc", 878 | ] 879 | 880 | [[package]] 881 | name = "ipconfig" 882 | version = "0.2.2" 883 | source = "registry+https://github.com/rust-lang/crates.io-index" 884 | checksum = "f7e2f18aece9709094573a9f24f483c4f65caa4298e2f7ae1b71cc65d853fad7" 885 | dependencies = [ 886 | "socket2", 887 | "widestring", 888 | "winapi 0.3.9", 889 | "winreg", 890 | ] 891 | 892 | [[package]] 893 | name = "itoa" 894 | version = "0.4.8" 895 | source = "registry+https://github.com/rust-lang/crates.io-index" 896 | checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" 897 | 898 | [[package]] 899 | name = "itoa" 900 | version = "1.0.1" 901 | source = "registry+https://github.com/rust-lang/crates.io-index" 902 | checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" 903 | 904 | [[package]] 905 | name = "kernel32-sys" 906 | version = "0.2.2" 907 | source = "registry+https://github.com/rust-lang/crates.io-index" 908 | checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" 909 | dependencies = [ 910 | "winapi 0.2.8", 911 | "winapi-build", 912 | ] 913 | 914 | [[package]] 915 | name = "language-tags" 916 | version = "0.2.2" 917 | source = "registry+https://github.com/rust-lang/crates.io-index" 918 | checksum = "a91d884b6667cd606bb5a69aa0c99ba811a115fc68915e7056ec08a46e93199a" 919 | 920 | [[package]] 921 | name = "lazy_static" 922 | version = "1.4.0" 923 | source = "registry+https://github.com/rust-lang/crates.io-index" 924 | checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" 925 | 926 | [[package]] 927 | name = "libc" 928 | version = "0.2.119" 929 | source = "registry+https://github.com/rust-lang/crates.io-index" 930 | checksum = "1bf2e165bb3457c8e098ea76f3e3bc9db55f87aa90d52d0e6be741470916aaa4" 931 | 932 | [[package]] 933 | name = "linked-hash-map" 934 | version = "0.5.4" 935 | source = "registry+https://github.com/rust-lang/crates.io-index" 936 | checksum = "7fb9b38af92608140b86b693604b9ffcc5824240a484d1ecd4795bacb2fe88f3" 937 | 938 | [[package]] 939 | name = "lock_api" 940 | version = "0.4.6" 941 | source = "registry+https://github.com/rust-lang/crates.io-index" 942 | checksum = "88943dd7ef4a2e5a4bfa2753aaab3013e34ce2533d1996fb18ef591e315e2b3b" 943 | dependencies = [ 944 | "scopeguard", 945 | ] 946 | 947 | [[package]] 948 | name = "log" 949 | version = "0.4.14" 950 | source = "registry+https://github.com/rust-lang/crates.io-index" 951 | checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" 952 | dependencies = [ 953 | "cfg-if 1.0.0", 954 | ] 955 | 956 | [[package]] 957 | name = "lru-cache" 958 | version = "0.1.2" 959 | source = "registry+https://github.com/rust-lang/crates.io-index" 960 | checksum = "31e24f1ad8321ca0e8a1e0ac13f23cb668e6f5466c2c57319f6a5cf1cc8e3b1c" 961 | dependencies = [ 962 | "linked-hash-map", 963 | ] 964 | 965 | [[package]] 966 | name = "match_cfg" 967 | version = "0.1.0" 968 | source = "registry+https://github.com/rust-lang/crates.io-index" 969 | checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" 970 | 971 | [[package]] 972 | name = "matches" 973 | version = "0.1.9" 974 | source = "registry+https://github.com/rust-lang/crates.io-index" 975 | checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" 976 | 977 | [[package]] 978 | name = "memchr" 979 | version = "2.4.1" 980 | source = "registry+https://github.com/rust-lang/crates.io-index" 981 | checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" 982 | 983 | [[package]] 984 | name = "mime" 985 | version = "0.3.16" 986 | source = "registry+https://github.com/rust-lang/crates.io-index" 987 | checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" 988 | 989 | [[package]] 990 | name = "mining-pool-api" 991 | version = "0.1.0" 992 | dependencies = [ 993 | "actix-rt", 994 | "actix-web", 995 | "diesel", 996 | "env_logger", 997 | "r2d2", 998 | "r2d2-diesel", 999 | "rand 0.8.5", 1000 | "serde", 1001 | "serde_json", 1002 | "uuid", 1003 | ] 1004 | 1005 | [[package]] 1006 | name = "miniz_oxide" 1007 | version = "0.4.4" 1008 | source = "registry+https://github.com/rust-lang/crates.io-index" 1009 | checksum = "a92518e98c078586bc6c934028adcca4c92a53d6a958196de835170a01d84e4b" 1010 | dependencies = [ 1011 | "adler", 1012 | "autocfg", 1013 | ] 1014 | 1015 | [[package]] 1016 | name = "mio" 1017 | version = "0.6.23" 1018 | source = "registry+https://github.com/rust-lang/crates.io-index" 1019 | checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" 1020 | dependencies = [ 1021 | "cfg-if 0.1.10", 1022 | "fuchsia-zircon", 1023 | "fuchsia-zircon-sys", 1024 | "iovec", 1025 | "kernel32-sys", 1026 | "libc", 1027 | "log", 1028 | "miow", 1029 | "net2", 1030 | "slab", 1031 | "winapi 0.2.8", 1032 | ] 1033 | 1034 | [[package]] 1035 | name = "mio-uds" 1036 | version = "0.6.8" 1037 | source = "registry+https://github.com/rust-lang/crates.io-index" 1038 | checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" 1039 | dependencies = [ 1040 | "iovec", 1041 | "libc", 1042 | "mio", 1043 | ] 1044 | 1045 | [[package]] 1046 | name = "miow" 1047 | version = "0.2.2" 1048 | source = "registry+https://github.com/rust-lang/crates.io-index" 1049 | checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" 1050 | dependencies = [ 1051 | "kernel32-sys", 1052 | "net2", 1053 | "winapi 0.2.8", 1054 | "ws2_32-sys", 1055 | ] 1056 | 1057 | [[package]] 1058 | name = "net2" 1059 | version = "0.2.37" 1060 | source = "registry+https://github.com/rust-lang/crates.io-index" 1061 | checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" 1062 | dependencies = [ 1063 | "cfg-if 0.1.10", 1064 | "libc", 1065 | "winapi 0.3.9", 1066 | ] 1067 | 1068 | [[package]] 1069 | name = "num-integer" 1070 | version = "0.1.44" 1071 | source = "registry+https://github.com/rust-lang/crates.io-index" 1072 | checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" 1073 | dependencies = [ 1074 | "autocfg", 1075 | "num-traits", 1076 | ] 1077 | 1078 | [[package]] 1079 | name = "num-traits" 1080 | version = "0.2.14" 1081 | source = "registry+https://github.com/rust-lang/crates.io-index" 1082 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 1083 | dependencies = [ 1084 | "autocfg", 1085 | ] 1086 | 1087 | [[package]] 1088 | name = "num_cpus" 1089 | version = "1.13.1" 1090 | source = "registry+https://github.com/rust-lang/crates.io-index" 1091 | checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" 1092 | dependencies = [ 1093 | "hermit-abi", 1094 | "libc", 1095 | ] 1096 | 1097 | [[package]] 1098 | name = "opaque-debug" 1099 | version = "0.3.0" 1100 | source = "registry+https://github.com/rust-lang/crates.io-index" 1101 | checksum = "624a8340c38c1b80fd549087862da4ba43e08858af025b236e509b6649fc13d5" 1102 | 1103 | [[package]] 1104 | name = "parking_lot" 1105 | version = "0.11.2" 1106 | source = "registry+https://github.com/rust-lang/crates.io-index" 1107 | checksum = "7d17b78036a60663b797adeaee46f5c9dfebb86948d1255007a1d6be0271ff99" 1108 | dependencies = [ 1109 | "instant", 1110 | "lock_api", 1111 | "parking_lot_core", 1112 | ] 1113 | 1114 | [[package]] 1115 | name = "parking_lot_core" 1116 | version = "0.8.5" 1117 | source = "registry+https://github.com/rust-lang/crates.io-index" 1118 | checksum = "d76e8e1493bcac0d2766c42737f34458f1c8c50c0d23bcb24ea953affb273216" 1119 | dependencies = [ 1120 | "cfg-if 1.0.0", 1121 | "instant", 1122 | "libc", 1123 | "redox_syscall", 1124 | "smallvec", 1125 | "winapi 0.3.9", 1126 | ] 1127 | 1128 | [[package]] 1129 | name = "percent-encoding" 1130 | version = "2.1.0" 1131 | source = "registry+https://github.com/rust-lang/crates.io-index" 1132 | checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" 1133 | 1134 | [[package]] 1135 | name = "pin-project" 1136 | version = "0.4.29" 1137 | source = "registry+https://github.com/rust-lang/crates.io-index" 1138 | checksum = "9615c18d31137579e9ff063499264ddc1278e7b1982757ebc111028c4d1dc909" 1139 | dependencies = [ 1140 | "pin-project-internal 0.4.29", 1141 | ] 1142 | 1143 | [[package]] 1144 | name = "pin-project" 1145 | version = "1.0.10" 1146 | source = "registry+https://github.com/rust-lang/crates.io-index" 1147 | checksum = "58ad3879ad3baf4e44784bc6a718a8698867bb991f8ce24d1bcbe2cfb4c3a75e" 1148 | dependencies = [ 1149 | "pin-project-internal 1.0.10", 1150 | ] 1151 | 1152 | [[package]] 1153 | name = "pin-project-internal" 1154 | version = "0.4.29" 1155 | source = "registry+https://github.com/rust-lang/crates.io-index" 1156 | checksum = "044964427019eed9d49d9d5bbce6047ef18f37100ea400912a9fa4a3523ab12a" 1157 | dependencies = [ 1158 | "proc-macro2", 1159 | "quote", 1160 | "syn", 1161 | ] 1162 | 1163 | [[package]] 1164 | name = "pin-project-internal" 1165 | version = "1.0.10" 1166 | source = "registry+https://github.com/rust-lang/crates.io-index" 1167 | checksum = "744b6f092ba29c3650faf274db506afd39944f48420f6c86b17cfe0ee1cb36bb" 1168 | dependencies = [ 1169 | "proc-macro2", 1170 | "quote", 1171 | "syn", 1172 | ] 1173 | 1174 | [[package]] 1175 | name = "pin-project-lite" 1176 | version = "0.1.12" 1177 | source = "registry+https://github.com/rust-lang/crates.io-index" 1178 | checksum = "257b64915a082f7811703966789728173279bdebb956b143dbcd23f6f970a777" 1179 | 1180 | [[package]] 1181 | name = "pin-project-lite" 1182 | version = "0.2.8" 1183 | source = "registry+https://github.com/rust-lang/crates.io-index" 1184 | checksum = "e280fbe77cc62c91527259e9442153f4688736748d24660126286329742b4c6c" 1185 | 1186 | [[package]] 1187 | name = "pin-utils" 1188 | version = "0.1.0" 1189 | source = "registry+https://github.com/rust-lang/crates.io-index" 1190 | checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" 1191 | 1192 | [[package]] 1193 | name = "ppv-lite86" 1194 | version = "0.2.16" 1195 | source = "registry+https://github.com/rust-lang/crates.io-index" 1196 | checksum = "eb9f9e6e233e5c4a35559a617bf40a4ec447db2e84c20b55a6f83167b7e57872" 1197 | 1198 | [[package]] 1199 | name = "pq-sys" 1200 | version = "0.4.6" 1201 | source = "registry+https://github.com/rust-lang/crates.io-index" 1202 | checksum = "6ac25eee5a0582f45a67e837e350d784e7003bd29a5f460796772061ca49ffda" 1203 | dependencies = [ 1204 | "vcpkg", 1205 | ] 1206 | 1207 | [[package]] 1208 | name = "proc-macro-hack" 1209 | version = "0.5.19" 1210 | source = "registry+https://github.com/rust-lang/crates.io-index" 1211 | checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" 1212 | 1213 | [[package]] 1214 | name = "proc-macro2" 1215 | version = "1.0.36" 1216 | source = "registry+https://github.com/rust-lang/crates.io-index" 1217 | checksum = "c7342d5883fbccae1cc37a2353b09c87c9b0f3afd73f5fb9bba687a1f733b029" 1218 | dependencies = [ 1219 | "unicode-xid", 1220 | ] 1221 | 1222 | [[package]] 1223 | name = "quick-error" 1224 | version = "1.2.3" 1225 | source = "registry+https://github.com/rust-lang/crates.io-index" 1226 | checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" 1227 | 1228 | [[package]] 1229 | name = "quote" 1230 | version = "1.0.15" 1231 | source = "registry+https://github.com/rust-lang/crates.io-index" 1232 | checksum = "864d3e96a899863136fc6e99f3d7cae289dafe43bf2c5ac19b70df7210c0a145" 1233 | dependencies = [ 1234 | "proc-macro2", 1235 | ] 1236 | 1237 | [[package]] 1238 | name = "r2d2" 1239 | version = "0.8.9" 1240 | source = "registry+https://github.com/rust-lang/crates.io-index" 1241 | checksum = "545c5bc2b880973c9c10e4067418407a0ccaa3091781d1671d46eb35107cb26f" 1242 | dependencies = [ 1243 | "log", 1244 | "parking_lot", 1245 | "scheduled-thread-pool", 1246 | ] 1247 | 1248 | [[package]] 1249 | name = "r2d2-diesel" 1250 | version = "1.0.0" 1251 | source = "registry+https://github.com/rust-lang/crates.io-index" 1252 | checksum = "eb9c29bad92da76d02bc2c020452ebc3a3fe6fa74cfab91e711c43116e4fb1a3" 1253 | dependencies = [ 1254 | "diesel", 1255 | "r2d2", 1256 | ] 1257 | 1258 | [[package]] 1259 | name = "rand" 1260 | version = "0.4.6" 1261 | source = "registry+https://github.com/rust-lang/crates.io-index" 1262 | checksum = "552840b97013b1a26992c11eac34bdd778e464601a4c2054b5f0bff7c6761293" 1263 | dependencies = [ 1264 | "fuchsia-cprng", 1265 | "libc", 1266 | "rand_core 0.3.1", 1267 | "rdrand", 1268 | "winapi 0.3.9", 1269 | ] 1270 | 1271 | [[package]] 1272 | name = "rand" 1273 | version = "0.7.3" 1274 | source = "registry+https://github.com/rust-lang/crates.io-index" 1275 | checksum = "6a6b1679d49b24bbfe0c803429aa1874472f50d9b363131f0e89fc356b544d03" 1276 | dependencies = [ 1277 | "getrandom 0.1.16", 1278 | "libc", 1279 | "rand_chacha 0.2.2", 1280 | "rand_core 0.5.1", 1281 | "rand_hc", 1282 | ] 1283 | 1284 | [[package]] 1285 | name = "rand" 1286 | version = "0.8.5" 1287 | source = "registry+https://github.com/rust-lang/crates.io-index" 1288 | checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" 1289 | dependencies = [ 1290 | "libc", 1291 | "rand_chacha 0.3.1", 1292 | "rand_core 0.6.3", 1293 | ] 1294 | 1295 | [[package]] 1296 | name = "rand_chacha" 1297 | version = "0.2.2" 1298 | source = "registry+https://github.com/rust-lang/crates.io-index" 1299 | checksum = "f4c8ed856279c9737206bf725bf36935d8666ead7aa69b52be55af369d193402" 1300 | dependencies = [ 1301 | "ppv-lite86", 1302 | "rand_core 0.5.1", 1303 | ] 1304 | 1305 | [[package]] 1306 | name = "rand_chacha" 1307 | version = "0.3.1" 1308 | source = "registry+https://github.com/rust-lang/crates.io-index" 1309 | checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" 1310 | dependencies = [ 1311 | "ppv-lite86", 1312 | "rand_core 0.6.3", 1313 | ] 1314 | 1315 | [[package]] 1316 | name = "rand_core" 1317 | version = "0.3.1" 1318 | source = "registry+https://github.com/rust-lang/crates.io-index" 1319 | checksum = "7a6fdeb83b075e8266dcc8762c22776f6877a63111121f5f8c7411e5be7eed4b" 1320 | dependencies = [ 1321 | "rand_core 0.4.2", 1322 | ] 1323 | 1324 | [[package]] 1325 | name = "rand_core" 1326 | version = "0.4.2" 1327 | source = "registry+https://github.com/rust-lang/crates.io-index" 1328 | checksum = "9c33a3c44ca05fa6f1807d8e6743f3824e8509beca625669633be0acbdf509dc" 1329 | 1330 | [[package]] 1331 | name = "rand_core" 1332 | version = "0.5.1" 1333 | source = "registry+https://github.com/rust-lang/crates.io-index" 1334 | checksum = "90bde5296fc891b0cef12a6d03ddccc162ce7b2aff54160af9338f8d40df6d19" 1335 | dependencies = [ 1336 | "getrandom 0.1.16", 1337 | ] 1338 | 1339 | [[package]] 1340 | name = "rand_core" 1341 | version = "0.6.3" 1342 | source = "registry+https://github.com/rust-lang/crates.io-index" 1343 | checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" 1344 | dependencies = [ 1345 | "getrandom 0.2.5", 1346 | ] 1347 | 1348 | [[package]] 1349 | name = "rand_hc" 1350 | version = "0.2.0" 1351 | source = "registry+https://github.com/rust-lang/crates.io-index" 1352 | checksum = "ca3129af7b92a17112d59ad498c6f81eaf463253766b90396d39ea7a39d6613c" 1353 | dependencies = [ 1354 | "rand_core 0.5.1", 1355 | ] 1356 | 1357 | [[package]] 1358 | name = "rdrand" 1359 | version = "0.4.0" 1360 | source = "registry+https://github.com/rust-lang/crates.io-index" 1361 | checksum = "678054eb77286b51581ba43620cc911abf02758c91f93f479767aed0f90458b2" 1362 | dependencies = [ 1363 | "rand_core 0.3.1", 1364 | ] 1365 | 1366 | [[package]] 1367 | name = "redox_syscall" 1368 | version = "0.2.11" 1369 | source = "registry+https://github.com/rust-lang/crates.io-index" 1370 | checksum = "8380fe0152551244f0747b1bf41737e0f8a74f97a14ccefd1148187271634f3c" 1371 | dependencies = [ 1372 | "bitflags", 1373 | ] 1374 | 1375 | [[package]] 1376 | name = "regex" 1377 | version = "1.5.4" 1378 | source = "registry+https://github.com/rust-lang/crates.io-index" 1379 | checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" 1380 | dependencies = [ 1381 | "aho-corasick", 1382 | "memchr", 1383 | "regex-syntax", 1384 | ] 1385 | 1386 | [[package]] 1387 | name = "regex-syntax" 1388 | version = "0.6.25" 1389 | source = "registry+https://github.com/rust-lang/crates.io-index" 1390 | checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" 1391 | 1392 | [[package]] 1393 | name = "resolv-conf" 1394 | version = "0.7.0" 1395 | source = "registry+https://github.com/rust-lang/crates.io-index" 1396 | checksum = "52e44394d2086d010551b14b53b1f24e31647570cd1deb0379e2c21b329aba00" 1397 | dependencies = [ 1398 | "hostname", 1399 | "quick-error", 1400 | ] 1401 | 1402 | [[package]] 1403 | name = "rustc_version" 1404 | version = "0.2.3" 1405 | source = "registry+https://github.com/rust-lang/crates.io-index" 1406 | checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" 1407 | dependencies = [ 1408 | "semver 0.9.0", 1409 | ] 1410 | 1411 | [[package]] 1412 | name = "rustc_version" 1413 | version = "0.4.0" 1414 | source = "registry+https://github.com/rust-lang/crates.io-index" 1415 | checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" 1416 | dependencies = [ 1417 | "semver 1.0.6", 1418 | ] 1419 | 1420 | [[package]] 1421 | name = "ryu" 1422 | version = "1.0.9" 1423 | source = "registry+https://github.com/rust-lang/crates.io-index" 1424 | checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" 1425 | 1426 | [[package]] 1427 | name = "scheduled-thread-pool" 1428 | version = "0.2.5" 1429 | source = "registry+https://github.com/rust-lang/crates.io-index" 1430 | checksum = "dc6f74fd1204073fa02d5d5d68bec8021be4c38690b61264b2fdb48083d0e7d7" 1431 | dependencies = [ 1432 | "parking_lot", 1433 | ] 1434 | 1435 | [[package]] 1436 | name = "scopeguard" 1437 | version = "1.1.0" 1438 | source = "registry+https://github.com/rust-lang/crates.io-index" 1439 | checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" 1440 | 1441 | [[package]] 1442 | name = "semver" 1443 | version = "0.9.0" 1444 | source = "registry+https://github.com/rust-lang/crates.io-index" 1445 | checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" 1446 | dependencies = [ 1447 | "semver-parser", 1448 | ] 1449 | 1450 | [[package]] 1451 | name = "semver" 1452 | version = "1.0.6" 1453 | source = "registry+https://github.com/rust-lang/crates.io-index" 1454 | checksum = "a4a3381e03edd24287172047536f20cabde766e2cd3e65e6b00fb3af51c4f38d" 1455 | 1456 | [[package]] 1457 | name = "semver-parser" 1458 | version = "0.7.0" 1459 | source = "registry+https://github.com/rust-lang/crates.io-index" 1460 | checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" 1461 | 1462 | [[package]] 1463 | name = "serde" 1464 | version = "1.0.136" 1465 | source = "registry+https://github.com/rust-lang/crates.io-index" 1466 | checksum = "ce31e24b01e1e524df96f1c2fdd054405f8d7376249a5110886fb4b658484789" 1467 | dependencies = [ 1468 | "serde_derive", 1469 | ] 1470 | 1471 | [[package]] 1472 | name = "serde_derive" 1473 | version = "1.0.136" 1474 | source = "registry+https://github.com/rust-lang/crates.io-index" 1475 | checksum = "08597e7152fcd306f41838ed3e37be9eaeed2b61c42e2117266a554fab4662f9" 1476 | dependencies = [ 1477 | "proc-macro2", 1478 | "quote", 1479 | "syn", 1480 | ] 1481 | 1482 | [[package]] 1483 | name = "serde_json" 1484 | version = "1.0.79" 1485 | source = "registry+https://github.com/rust-lang/crates.io-index" 1486 | checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95" 1487 | dependencies = [ 1488 | "itoa 1.0.1", 1489 | "ryu", 1490 | "serde", 1491 | ] 1492 | 1493 | [[package]] 1494 | name = "serde_urlencoded" 1495 | version = "0.7.1" 1496 | source = "registry+https://github.com/rust-lang/crates.io-index" 1497 | checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" 1498 | dependencies = [ 1499 | "form_urlencoded", 1500 | "itoa 1.0.1", 1501 | "ryu", 1502 | "serde", 1503 | ] 1504 | 1505 | [[package]] 1506 | name = "sha-1" 1507 | version = "0.9.8" 1508 | source = "registry+https://github.com/rust-lang/crates.io-index" 1509 | checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" 1510 | dependencies = [ 1511 | "block-buffer", 1512 | "cfg-if 1.0.0", 1513 | "cpufeatures", 1514 | "digest", 1515 | "opaque-debug", 1516 | ] 1517 | 1518 | [[package]] 1519 | name = "sha1" 1520 | version = "0.6.1" 1521 | source = "registry+https://github.com/rust-lang/crates.io-index" 1522 | checksum = "c1da05c97445caa12d05e848c4a4fcbbea29e748ac28f7e80e9b010392063770" 1523 | dependencies = [ 1524 | "sha1_smol", 1525 | ] 1526 | 1527 | [[package]] 1528 | name = "sha1_smol" 1529 | version = "1.0.0" 1530 | source = "registry+https://github.com/rust-lang/crates.io-index" 1531 | checksum = "ae1a47186c03a32177042e55dbc5fd5aee900b8e0069a8d70fba96a9375cd012" 1532 | 1533 | [[package]] 1534 | name = "signal-hook-registry" 1535 | version = "1.4.0" 1536 | source = "registry+https://github.com/rust-lang/crates.io-index" 1537 | checksum = "e51e73328dc4ac0c7ccbda3a494dfa03df1de2f46018127f60c693f2648455b0" 1538 | dependencies = [ 1539 | "libc", 1540 | ] 1541 | 1542 | [[package]] 1543 | name = "slab" 1544 | version = "0.4.5" 1545 | source = "registry+https://github.com/rust-lang/crates.io-index" 1546 | checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" 1547 | 1548 | [[package]] 1549 | name = "smallvec" 1550 | version = "1.8.0" 1551 | source = "registry+https://github.com/rust-lang/crates.io-index" 1552 | checksum = "f2dd574626839106c320a323308629dcb1acfc96e32a8cba364ddc61ac23ee83" 1553 | 1554 | [[package]] 1555 | name = "socket2" 1556 | version = "0.3.19" 1557 | source = "registry+https://github.com/rust-lang/crates.io-index" 1558 | checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" 1559 | dependencies = [ 1560 | "cfg-if 1.0.0", 1561 | "libc", 1562 | "winapi 0.3.9", 1563 | ] 1564 | 1565 | [[package]] 1566 | name = "standback" 1567 | version = "0.2.17" 1568 | source = "registry+https://github.com/rust-lang/crates.io-index" 1569 | checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" 1570 | dependencies = [ 1571 | "version_check", 1572 | ] 1573 | 1574 | [[package]] 1575 | name = "stdweb" 1576 | version = "0.4.20" 1577 | source = "registry+https://github.com/rust-lang/crates.io-index" 1578 | checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" 1579 | dependencies = [ 1580 | "discard", 1581 | "rustc_version 0.2.3", 1582 | "stdweb-derive", 1583 | "stdweb-internal-macros", 1584 | "stdweb-internal-runtime", 1585 | "wasm-bindgen", 1586 | ] 1587 | 1588 | [[package]] 1589 | name = "stdweb-derive" 1590 | version = "0.5.3" 1591 | source = "registry+https://github.com/rust-lang/crates.io-index" 1592 | checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" 1593 | dependencies = [ 1594 | "proc-macro2", 1595 | "quote", 1596 | "serde", 1597 | "serde_derive", 1598 | "syn", 1599 | ] 1600 | 1601 | [[package]] 1602 | name = "stdweb-internal-macros" 1603 | version = "0.2.9" 1604 | source = "registry+https://github.com/rust-lang/crates.io-index" 1605 | checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" 1606 | dependencies = [ 1607 | "base-x", 1608 | "proc-macro2", 1609 | "quote", 1610 | "serde", 1611 | "serde_derive", 1612 | "serde_json", 1613 | "sha1", 1614 | "syn", 1615 | ] 1616 | 1617 | [[package]] 1618 | name = "stdweb-internal-runtime" 1619 | version = "0.1.5" 1620 | source = "registry+https://github.com/rust-lang/crates.io-index" 1621 | checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" 1622 | 1623 | [[package]] 1624 | name = "syn" 1625 | version = "1.0.86" 1626 | source = "registry+https://github.com/rust-lang/crates.io-index" 1627 | checksum = "8a65b3f4ffa0092e9887669db0eae07941f023991ab58ea44da8fe8e2d511c6b" 1628 | dependencies = [ 1629 | "proc-macro2", 1630 | "quote", 1631 | "unicode-xid", 1632 | ] 1633 | 1634 | [[package]] 1635 | name = "termcolor" 1636 | version = "1.1.3" 1637 | source = "registry+https://github.com/rust-lang/crates.io-index" 1638 | checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" 1639 | dependencies = [ 1640 | "winapi-util", 1641 | ] 1642 | 1643 | [[package]] 1644 | name = "thiserror" 1645 | version = "1.0.30" 1646 | source = "registry+https://github.com/rust-lang/crates.io-index" 1647 | checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417" 1648 | dependencies = [ 1649 | "thiserror-impl", 1650 | ] 1651 | 1652 | [[package]] 1653 | name = "thiserror-impl" 1654 | version = "1.0.30" 1655 | source = "registry+https://github.com/rust-lang/crates.io-index" 1656 | checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b" 1657 | dependencies = [ 1658 | "proc-macro2", 1659 | "quote", 1660 | "syn", 1661 | ] 1662 | 1663 | [[package]] 1664 | name = "threadpool" 1665 | version = "1.8.1" 1666 | source = "registry+https://github.com/rust-lang/crates.io-index" 1667 | checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa" 1668 | dependencies = [ 1669 | "num_cpus", 1670 | ] 1671 | 1672 | [[package]] 1673 | name = "time" 1674 | version = "0.1.43" 1675 | source = "registry+https://github.com/rust-lang/crates.io-index" 1676 | checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" 1677 | dependencies = [ 1678 | "libc", 1679 | "winapi 0.3.9", 1680 | ] 1681 | 1682 | [[package]] 1683 | name = "time" 1684 | version = "0.2.27" 1685 | source = "registry+https://github.com/rust-lang/crates.io-index" 1686 | checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" 1687 | dependencies = [ 1688 | "const_fn", 1689 | "libc", 1690 | "standback", 1691 | "stdweb", 1692 | "time-macros", 1693 | "version_check", 1694 | "winapi 0.3.9", 1695 | ] 1696 | 1697 | [[package]] 1698 | name = "time-macros" 1699 | version = "0.1.1" 1700 | source = "registry+https://github.com/rust-lang/crates.io-index" 1701 | checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" 1702 | dependencies = [ 1703 | "proc-macro-hack", 1704 | "time-macros-impl", 1705 | ] 1706 | 1707 | [[package]] 1708 | name = "time-macros-impl" 1709 | version = "0.1.2" 1710 | source = "registry+https://github.com/rust-lang/crates.io-index" 1711 | checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" 1712 | dependencies = [ 1713 | "proc-macro-hack", 1714 | "proc-macro2", 1715 | "quote", 1716 | "standback", 1717 | "syn", 1718 | ] 1719 | 1720 | [[package]] 1721 | name = "tinyvec" 1722 | version = "1.5.1" 1723 | source = "registry+https://github.com/rust-lang/crates.io-index" 1724 | checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" 1725 | dependencies = [ 1726 | "tinyvec_macros", 1727 | ] 1728 | 1729 | [[package]] 1730 | name = "tinyvec_macros" 1731 | version = "0.1.0" 1732 | source = "registry+https://github.com/rust-lang/crates.io-index" 1733 | checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" 1734 | 1735 | [[package]] 1736 | name = "tokio" 1737 | version = "0.2.25" 1738 | source = "registry+https://github.com/rust-lang/crates.io-index" 1739 | checksum = "6703a273949a90131b290be1fe7b039d0fc884aa1935860dfcbe056f28cd8092" 1740 | dependencies = [ 1741 | "bytes 0.5.6", 1742 | "futures-core", 1743 | "iovec", 1744 | "lazy_static", 1745 | "libc", 1746 | "memchr", 1747 | "mio", 1748 | "mio-uds", 1749 | "pin-project-lite 0.1.12", 1750 | "signal-hook-registry", 1751 | "slab", 1752 | "winapi 0.3.9", 1753 | ] 1754 | 1755 | [[package]] 1756 | name = "tokio-util" 1757 | version = "0.3.1" 1758 | source = "registry+https://github.com/rust-lang/crates.io-index" 1759 | checksum = "be8242891f2b6cbef26a2d7e8605133c2c554cd35b3e4948ea892d6d68436499" 1760 | dependencies = [ 1761 | "bytes 0.5.6", 1762 | "futures-core", 1763 | "futures-sink", 1764 | "log", 1765 | "pin-project-lite 0.1.12", 1766 | "tokio", 1767 | ] 1768 | 1769 | [[package]] 1770 | name = "tracing" 1771 | version = "0.1.31" 1772 | source = "registry+https://github.com/rust-lang/crates.io-index" 1773 | checksum = "f6c650a8ef0cd2dd93736f033d21cbd1224c5a967aa0c258d00fcf7dafef9b9f" 1774 | dependencies = [ 1775 | "cfg-if 1.0.0", 1776 | "log", 1777 | "pin-project-lite 0.2.8", 1778 | "tracing-core", 1779 | ] 1780 | 1781 | [[package]] 1782 | name = "tracing-core" 1783 | version = "0.1.22" 1784 | source = "registry+https://github.com/rust-lang/crates.io-index" 1785 | checksum = "03cfcb51380632a72d3111cb8d3447a8d908e577d31beeac006f836383d29a23" 1786 | dependencies = [ 1787 | "lazy_static", 1788 | ] 1789 | 1790 | [[package]] 1791 | name = "tracing-futures" 1792 | version = "0.2.5" 1793 | source = "registry+https://github.com/rust-lang/crates.io-index" 1794 | checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" 1795 | dependencies = [ 1796 | "pin-project 1.0.10", 1797 | "tracing", 1798 | ] 1799 | 1800 | [[package]] 1801 | name = "trust-dns-proto" 1802 | version = "0.19.7" 1803 | source = "registry+https://github.com/rust-lang/crates.io-index" 1804 | checksum = "1cad71a0c0d68ab9941d2fb6e82f8fb2e86d9945b94e1661dd0aaea2b88215a9" 1805 | dependencies = [ 1806 | "async-trait", 1807 | "cfg-if 1.0.0", 1808 | "enum-as-inner", 1809 | "futures", 1810 | "idna", 1811 | "lazy_static", 1812 | "log", 1813 | "rand 0.7.3", 1814 | "smallvec", 1815 | "thiserror", 1816 | "tokio", 1817 | "url", 1818 | ] 1819 | 1820 | [[package]] 1821 | name = "trust-dns-resolver" 1822 | version = "0.19.7" 1823 | source = "registry+https://github.com/rust-lang/crates.io-index" 1824 | checksum = "710f593b371175db53a26d0b38ed2978fafb9e9e8d3868b1acd753ea18df0ceb" 1825 | dependencies = [ 1826 | "cfg-if 0.1.10", 1827 | "futures", 1828 | "ipconfig", 1829 | "lazy_static", 1830 | "log", 1831 | "lru-cache", 1832 | "resolv-conf", 1833 | "smallvec", 1834 | "thiserror", 1835 | "tokio", 1836 | "trust-dns-proto", 1837 | ] 1838 | 1839 | [[package]] 1840 | name = "typenum" 1841 | version = "1.15.0" 1842 | source = "registry+https://github.com/rust-lang/crates.io-index" 1843 | checksum = "dcf81ac59edc17cc8697ff311e8f5ef2d99fcbd9817b34cec66f90b6c3dfd987" 1844 | 1845 | [[package]] 1846 | name = "unicode-bidi" 1847 | version = "0.3.7" 1848 | source = "registry+https://github.com/rust-lang/crates.io-index" 1849 | checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" 1850 | 1851 | [[package]] 1852 | name = "unicode-normalization" 1853 | version = "0.1.19" 1854 | source = "registry+https://github.com/rust-lang/crates.io-index" 1855 | checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" 1856 | dependencies = [ 1857 | "tinyvec", 1858 | ] 1859 | 1860 | [[package]] 1861 | name = "unicode-xid" 1862 | version = "0.2.2" 1863 | source = "registry+https://github.com/rust-lang/crates.io-index" 1864 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 1865 | 1866 | [[package]] 1867 | name = "url" 1868 | version = "2.2.2" 1869 | source = "registry+https://github.com/rust-lang/crates.io-index" 1870 | checksum = "a507c383b2d33b5fc35d1861e77e6b383d158b2da5e14fe51b83dfedf6fd578c" 1871 | dependencies = [ 1872 | "form_urlencoded", 1873 | "idna", 1874 | "matches", 1875 | "percent-encoding", 1876 | ] 1877 | 1878 | [[package]] 1879 | name = "uuid" 1880 | version = "0.6.5" 1881 | source = "registry+https://github.com/rust-lang/crates.io-index" 1882 | checksum = "e1436e58182935dcd9ce0add9ea0b558e8a87befe01c1a301e6020aeb0876363" 1883 | dependencies = [ 1884 | "cfg-if 0.1.10", 1885 | "rand 0.4.6", 1886 | "serde", 1887 | ] 1888 | 1889 | [[package]] 1890 | name = "vcpkg" 1891 | version = "0.2.15" 1892 | source = "registry+https://github.com/rust-lang/crates.io-index" 1893 | checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" 1894 | 1895 | [[package]] 1896 | name = "version_check" 1897 | version = "0.9.4" 1898 | source = "registry+https://github.com/rust-lang/crates.io-index" 1899 | checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" 1900 | 1901 | [[package]] 1902 | name = "wasi" 1903 | version = "0.9.0+wasi-snapshot-preview1" 1904 | source = "registry+https://github.com/rust-lang/crates.io-index" 1905 | checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" 1906 | 1907 | [[package]] 1908 | name = "wasi" 1909 | version = "0.10.2+wasi-snapshot-preview1" 1910 | source = "registry+https://github.com/rust-lang/crates.io-index" 1911 | checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" 1912 | 1913 | [[package]] 1914 | name = "wasm-bindgen" 1915 | version = "0.2.79" 1916 | source = "registry+https://github.com/rust-lang/crates.io-index" 1917 | checksum = "25f1af7423d8588a3d840681122e72e6a24ddbcb3f0ec385cac0d12d24256c06" 1918 | dependencies = [ 1919 | "cfg-if 1.0.0", 1920 | "wasm-bindgen-macro", 1921 | ] 1922 | 1923 | [[package]] 1924 | name = "wasm-bindgen-backend" 1925 | version = "0.2.79" 1926 | source = "registry+https://github.com/rust-lang/crates.io-index" 1927 | checksum = "8b21c0df030f5a177f3cba22e9bc4322695ec43e7257d865302900290bcdedca" 1928 | dependencies = [ 1929 | "bumpalo", 1930 | "lazy_static", 1931 | "log", 1932 | "proc-macro2", 1933 | "quote", 1934 | "syn", 1935 | "wasm-bindgen-shared", 1936 | ] 1937 | 1938 | [[package]] 1939 | name = "wasm-bindgen-macro" 1940 | version = "0.2.79" 1941 | source = "registry+https://github.com/rust-lang/crates.io-index" 1942 | checksum = "2f4203d69e40a52ee523b2529a773d5ffc1dc0071801c87b3d270b471b80ed01" 1943 | dependencies = [ 1944 | "quote", 1945 | "wasm-bindgen-macro-support", 1946 | ] 1947 | 1948 | [[package]] 1949 | name = "wasm-bindgen-macro-support" 1950 | version = "0.2.79" 1951 | source = "registry+https://github.com/rust-lang/crates.io-index" 1952 | checksum = "bfa8a30d46208db204854cadbb5d4baf5fcf8071ba5bf48190c3e59937962ebc" 1953 | dependencies = [ 1954 | "proc-macro2", 1955 | "quote", 1956 | "syn", 1957 | "wasm-bindgen-backend", 1958 | "wasm-bindgen-shared", 1959 | ] 1960 | 1961 | [[package]] 1962 | name = "wasm-bindgen-shared" 1963 | version = "0.2.79" 1964 | source = "registry+https://github.com/rust-lang/crates.io-index" 1965 | checksum = "3d958d035c4438e28c70e4321a2911302f10135ce78a9c7834c0cab4123d06a2" 1966 | 1967 | [[package]] 1968 | name = "widestring" 1969 | version = "0.4.3" 1970 | source = "registry+https://github.com/rust-lang/crates.io-index" 1971 | checksum = "c168940144dd21fd8046987c16a46a33d5fc84eec29ef9dcddc2ac9e31526b7c" 1972 | 1973 | [[package]] 1974 | name = "winapi" 1975 | version = "0.2.8" 1976 | source = "registry+https://github.com/rust-lang/crates.io-index" 1977 | checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" 1978 | 1979 | [[package]] 1980 | name = "winapi" 1981 | version = "0.3.9" 1982 | source = "registry+https://github.com/rust-lang/crates.io-index" 1983 | checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" 1984 | dependencies = [ 1985 | "winapi-i686-pc-windows-gnu", 1986 | "winapi-x86_64-pc-windows-gnu", 1987 | ] 1988 | 1989 | [[package]] 1990 | name = "winapi-build" 1991 | version = "0.1.1" 1992 | source = "registry+https://github.com/rust-lang/crates.io-index" 1993 | checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" 1994 | 1995 | [[package]] 1996 | name = "winapi-i686-pc-windows-gnu" 1997 | version = "0.4.0" 1998 | source = "registry+https://github.com/rust-lang/crates.io-index" 1999 | checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" 2000 | 2001 | [[package]] 2002 | name = "winapi-util" 2003 | version = "0.1.5" 2004 | source = "registry+https://github.com/rust-lang/crates.io-index" 2005 | checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" 2006 | dependencies = [ 2007 | "winapi 0.3.9", 2008 | ] 2009 | 2010 | [[package]] 2011 | name = "winapi-x86_64-pc-windows-gnu" 2012 | version = "0.4.0" 2013 | source = "registry+https://github.com/rust-lang/crates.io-index" 2014 | checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" 2015 | 2016 | [[package]] 2017 | name = "winreg" 2018 | version = "0.6.2" 2019 | source = "registry+https://github.com/rust-lang/crates.io-index" 2020 | checksum = "b2986deb581c4fe11b621998a5e53361efe6b48a151178d0cd9eeffa4dc6acc9" 2021 | dependencies = [ 2022 | "winapi 0.3.9", 2023 | ] 2024 | 2025 | [[package]] 2026 | name = "ws2_32-sys" 2027 | version = "0.2.1" 2028 | source = "registry+https://github.com/rust-lang/crates.io-index" 2029 | checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" 2030 | dependencies = [ 2031 | "winapi 0.2.8", 2032 | "winapi-build", 2033 | ] 2034 | -------------------------------------------------------------------------------- /mining-pool-api/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "mining-pool-api" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | actix-rt = "1.1.0" 10 | actix-web = "3.0.0-alpha.1" 11 | diesel = { version = "1.4.4", features = ["postgres", "r2d2", "chrono", "uuid"] } 12 | env_logger = "0.7.1" 13 | r2d2 = "0.8.8" 14 | r2d2-diesel = "1.0.0" 15 | rand = "0.8.4" 16 | serde = "1.0.106" 17 | serde_json = "1.0.51" 18 | uuid = { version = "0.6", features = ["serde", "v4"] } -------------------------------------------------------------------------------- /mining-pool-api/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:latest as builder 2 | 3 | RUN cargo new --bin mining-pool-api 4 | WORKDIR ./mining-pool-api 5 | COPY . . 6 | RUN cargo build --release 7 | 8 | 9 | FROM debian:buster-slim 10 | 11 | COPY --from=builder /mining-pool-api/target/release/mining-pool-api ./mining-pool-api 12 | RUN apt update && apt install libpq-dev -y 13 | CMD ["./mining-pool-api"] -------------------------------------------------------------------------------- /mining-pool-api/README.md: -------------------------------------------------------------------------------- 1 | # Mining Pool API 2 | 3 | ![](mining_pool_api_pic.jpg) -------------------------------------------------------------------------------- /mining-pool-api/diesel.toml: -------------------------------------------------------------------------------- 1 | # For documentation on how to configure this file, 2 | # see diesel.rs/guides/configuring-diesel-cli 3 | 4 | [print_schema] 5 | file = "src/schema.rs" 6 | -------------------------------------------------------------------------------- /mining-pool-api/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.3' 2 | 3 | services: 4 | mining-pool-api: 5 | build: . 6 | ports: 7 | - 9090:9090 8 | environment: 9 | DATABASE_URL: postgres://postgres:pass@postgres-docker/mining_pool_api 10 | depends_on: 11 | - postgres 12 | 13 | postgres: 14 | image: postgres:14.2 15 | hostname: postgres-docker 16 | expose: 17 | - 5432 18 | environment: 19 | POSTGRES_USER: postgres 20 | POSTGRES_PASSWORD: pass 21 | POSTGRES_DB: mining_pool_api 22 | volumes: 23 | - ./migrations/2022-03-08-033828_mining_pool_api/up.sql:/docker-entrypoint-initdb.d/up.sql -------------------------------------------------------------------------------- /mining-pool-api/migrations/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Intermediate-Tutorial/bddde5bd094d09d6ef986aa15369fc344a275494/mining-pool-api/migrations/.gitkeep -------------------------------------------------------------------------------- /mining-pool-api/migrations/00000000000000_diesel_initial_setup/down.sql: -------------------------------------------------------------------------------- 1 | -- This file was automatically created by Diesel to setup helper functions 2 | -- and other internal bookkeeping. This file is safe to edit, any future 3 | -- changes will be added to existing projects as new migrations. 4 | 5 | DROP FUNCTION IF EXISTS diesel_manage_updated_at(_tbl regclass); 6 | DROP FUNCTION IF EXISTS diesel_set_updated_at(); 7 | -------------------------------------------------------------------------------- /mining-pool-api/migrations/00000000000000_diesel_initial_setup/up.sql: -------------------------------------------------------------------------------- 1 | -- This file was automatically created by Diesel to setup helper functions 2 | -- and other internal bookkeeping. This file is safe to edit, any future 3 | -- changes will be added to existing projects as new migrations. 4 | 5 | 6 | 7 | 8 | -- Sets up a trigger for the given table to automatically set a column called 9 | -- `updated_at` whenever the row is modified (unless `updated_at` was included 10 | -- in the modified columns) 11 | -- 12 | -- # Example 13 | -- 14 | -- ```sql 15 | -- CREATE TABLE users (id SERIAL PRIMARY KEY, updated_at TIMESTAMP NOT NULL DEFAULT NOW()); 16 | -- 17 | -- SELECT diesel_manage_updated_at('users'); 18 | -- ``` 19 | CREATE OR REPLACE FUNCTION diesel_manage_updated_at(_tbl regclass) RETURNS VOID AS $$ 20 | BEGIN 21 | EXECUTE format('CREATE TRIGGER set_updated_at BEFORE UPDATE ON %s 22 | FOR EACH ROW EXECUTE PROCEDURE diesel_set_updated_at()', _tbl); 23 | END; 24 | $$ LANGUAGE plpgsql; 25 | 26 | CREATE OR REPLACE FUNCTION diesel_set_updated_at() RETURNS trigger AS $$ 27 | BEGIN 28 | IF ( 29 | NEW IS DISTINCT FROM OLD AND 30 | NEW.updated_at IS NOT DISTINCT FROM OLD.updated_at 31 | ) THEN 32 | NEW.updated_at := current_timestamp; 33 | END IF; 34 | RETURN NEW; 35 | END; 36 | $$ LANGUAGE plpgsql; 37 | -------------------------------------------------------------------------------- /mining-pool-api/migrations/2022-03-08-033828_mining_pool_api/down.sql: -------------------------------------------------------------------------------- 1 | DROP TABLE IF EXISTS miners; 2 | DROP TABLE IF EXISTS wallets; -------------------------------------------------------------------------------- /mining-pool-api/migrations/2022-03-08-033828_mining_pool_api/up.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE IF NOT EXISTS wallets 2 | ( 3 | address UUID PRIMARY KEY NOT NULL, 4 | club_name TEXT NOT NULL 5 | ); 6 | 7 | CREATE TABLE IF NOT EXISTS miners 8 | ( 9 | id UUID PRIMARY KEY NOT NULL, 10 | address UUID NOT NULL REFERENCES wallets(address), 11 | nickname TEXT NOT NULL, 12 | hash_rate INT NOT NULL, 13 | shares_mined INT NOT NULL 14 | ); -------------------------------------------------------------------------------- /mining-pool-api/mining_pool_api_pic.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Coding-and-Crypto/Rust-Intermediate-Tutorial/bddde5bd094d09d6ef986aa15369fc344a275494/mining-pool-api/mining_pool_api_pic.jpg -------------------------------------------------------------------------------- /mining-pool-api/src/main.rs: -------------------------------------------------------------------------------- 1 | #[macro_use] 2 | extern crate actix_web; 3 | #[macro_use] 4 | extern crate diesel; 5 | 6 | use { 7 | actix_web::{middleware, App, HttpServer}, 8 | actix_web::web::Data, 9 | diesel::r2d2::ConnectionManager, 10 | diesel::PgConnection, 11 | r2d2::{Pool, PooledConnection}, 12 | std::{env, io}, 13 | }; 14 | 15 | 16 | mod miner; 17 | mod miner_controller; 18 | mod schema; 19 | mod util; 20 | mod wallet; 21 | mod wallet_controller; 22 | 23 | pub type DBPool = Pool>; 24 | pub type DBPooledConnection = PooledConnection>; 25 | 26 | pub fn get_connection_to_pool(pool: Data) -> DBPooledConnection { 27 | pool.get().expect("Failed to reach DB connection pool.") 28 | } 29 | 30 | 31 | 32 | #[actix_rt::main] 33 | async fn main() -> io::Result<()> { 34 | 35 | env::set_var("RUST_LOG", "actix_web=debug,actix_server=info"); 36 | env_logger::init(); 37 | 38 | let database_url = env::var("DATABASE_URL").expect("DATABASE_URL not detected."); 39 | let manager = ConnectionManager::::new(database_url); 40 | let pool = r2d2::Pool::builder() 41 | .build(manager) 42 | .expect("Failed to initialize DB connection pool."); 43 | 44 | HttpServer::new(move|| { 45 | App::new() 46 | .data(pool.clone()) 47 | .wrap(middleware::Logger::default()) 48 | .service(wallet_controller::list_wallets) 49 | .service(wallet_controller::get_wallet) 50 | .service(wallet_controller::create_wallet) 51 | .service(miner_controller::list_miners) 52 | .service(miner_controller::get_miner) 53 | .service(miner_controller::create_miner) 54 | }) 55 | .bind("0.0.0.0:9090")? 56 | .run() 57 | .await 58 | } -------------------------------------------------------------------------------- /mining-pool-api/src/miner.rs: -------------------------------------------------------------------------------- 1 | use { 2 | diesel::{ 3 | ExpressionMethods, 4 | Insertable, 5 | Queryable, 6 | QueryDsl, 7 | RunQueryDsl 8 | }, 9 | diesel::result::Error, 10 | rand::Rng, 11 | serde::{ 12 | Deserialize, 13 | Serialize 14 | }, 15 | uuid::Uuid, 16 | super::schema::miners, 17 | crate::DBPooledConnection, 18 | crate::wallet::*, 19 | }; 20 | 21 | 22 | // --------------- JSON Payload (REST) 23 | 24 | 25 | #[derive(Debug, Deserialize, Serialize)] 26 | pub struct Miner { 27 | pub id: String, 28 | pub address: String, 29 | pub club_name: String, 30 | pub nickname: String, 31 | pub hash_rate: i32, // MH/s 32 | pub shares_mined: i32, 33 | } 34 | 35 | impl Miner { 36 | pub fn to_miner_dao(&self) -> MinerDAO { 37 | MinerDAO { 38 | id: Uuid::parse_str(self.id.as_str()).unwrap(), 39 | address: Uuid::parse_str(self.address.as_str()).unwrap(), 40 | nickname: self.nickname.to_string(), 41 | hash_rate: self.hash_rate, 42 | shares_mined: self.shares_mined, 43 | } 44 | } 45 | } 46 | 47 | 48 | // --------------- POST Request Body for new Miner 49 | 50 | 51 | #[derive(Debug, Deserialize, Serialize)] 52 | pub struct NewMinerRequest { 53 | nickname: String, 54 | } 55 | 56 | 57 | // --------------- DAO Object (DB Table Records) 58 | 59 | 60 | #[derive(Queryable, Insertable)] 61 | #[table_name = "miners"] 62 | pub struct MinerDAO { 63 | pub id: Uuid, 64 | pub address: Uuid, 65 | pub nickname: String, 66 | pub hash_rate: i32, 67 | pub shares_mined: i32, 68 | } 69 | 70 | impl MinerDAO { 71 | pub fn to_miner(&self, club_name: String) -> Miner { 72 | Miner { 73 | id: self.id.to_string(), 74 | address: self.address.to_string(), 75 | club_name, 76 | nickname: self.nickname.to_string(), 77 | hash_rate: self.hash_rate, 78 | shares_mined: self.shares_mined, 79 | } 80 | } 81 | } 82 | 83 | 84 | // --------------- Service Methods 85 | 86 | 87 | pub fn fetch_all_miners(conn: &DBPooledConnection) -> Vec { 88 | use crate::schema::miners::dsl::*; 89 | use crate::schema::wallets::dsl::*; 90 | match wallets 91 | .inner_join(miners) 92 | .load::<(WalletDAO, MinerDAO)>(conn) { 93 | Ok(result) => { 94 | result.into_iter().map(|(w, m)| { 95 | m.to_miner(w.club_name) 96 | }).collect::>() 97 | }, 98 | Err(_) => vec![], 99 | } 100 | } 101 | 102 | 103 | pub fn fetch_miner_by_id(_id: Uuid, conn: &DBPooledConnection) -> Option { 104 | use crate::schema::miners::dsl::*; 105 | use crate::schema::wallets::dsl::*; 106 | match wallets 107 | .inner_join(miners) 108 | .filter(id.eq(_id)) 109 | .load::<(WalletDAO, MinerDAO)>(conn) { 110 | Ok(result) => { 111 | match result.first() { 112 | Some((w, m)) => { 113 | Some(m.to_miner(w.club_name.clone())) 114 | }, 115 | _ => None, 116 | } 117 | }, 118 | Err(_) => None, 119 | } 120 | } 121 | 122 | 123 | pub fn create_new_miner(new_miner_request: NewMinerRequest, 124 | _address: Uuid, 125 | conn: &DBPooledConnection) -> Result { 126 | use crate::schema::miners::dsl::*; 127 | let new_miner_dao = MinerDAO { 128 | id: Uuid::new_v4(), 129 | address: _address, 130 | nickname: new_miner_request.nickname, 131 | hash_rate: rand::thread_rng().gen_range(20..100), // MH/s 132 | shares_mined: rand::thread_rng().gen_range(1..40), 133 | }; 134 | match diesel::insert_into(miners).values(&new_miner_dao).execute(conn) { 135 | Ok(_) => match fetch_miner_by_id(new_miner_dao.id, conn) { 136 | Some(result) => Ok(result), 137 | None => Err(Error::NotFound) 138 | }, 139 | Err(e) => Err(e), 140 | } 141 | } -------------------------------------------------------------------------------- /mining-pool-api/src/miner_controller.rs: -------------------------------------------------------------------------------- 1 | use { 2 | actix_web::HttpResponse, 3 | actix_web::web::{Data, Json, Path}, 4 | uuid::Uuid, 5 | 6 | crate::DBPool, 7 | crate::miner::*, 8 | crate::util::{NotFoundMessage, ResponseType}, 9 | }; 10 | 11 | 12 | // List all Miners 13 | #[get("/miners")] 14 | pub async fn list_miners(pool: Data) -> HttpResponse { 15 | let conn = crate::get_connection_to_pool(pool); 16 | let miners: Vec = fetch_all_miners(&conn); 17 | ResponseType::Ok(miners).get_response() 18 | } 19 | 20 | // Get a Miner 21 | #[get("/miners/{id}")] 22 | pub async fn get_miner(path: Path<(String,)>, pool: Data) -> HttpResponse { 23 | let conn = crate::get_connection_to_pool(pool); 24 | let miner: Option = fetch_miner_by_id( 25 | Uuid::parse_str(path.0.0.as_str()).unwrap(), &conn); 26 | match miner { 27 | Some(miner) => ResponseType::Ok(miner).get_response(), 28 | None => ResponseType::NotFound( 29 | NotFoundMessage::new("Miner not found.".to_string()) 30 | ).get_response(), 31 | } 32 | } 33 | 34 | // Create new Miner 35 | #[post("/wallets/{id}/miners")] 36 | pub async fn create_miner(path: Path<(String,)>, 37 | miner_request: Json, 38 | pool: Data) -> HttpResponse { 39 | let conn = crate::get_connection_to_pool(pool); 40 | match create_new_miner(miner_request.0, Uuid::parse_str(path.0.0.as_str()).unwrap(), &conn) { 41 | Ok(created_miner) => ResponseType::Created(created_miner).get_response(), 42 | Err(_) => ResponseType::NotFound( 43 | NotFoundMessage::new("Error creating miner.".to_string()) 44 | ).get_response(), 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /mining-pool-api/src/schema.rs: -------------------------------------------------------------------------------- 1 | table! { 2 | miners (id) { 3 | id -> Uuid, 4 | address -> Uuid, 5 | nickname -> Text, 6 | hash_rate -> Int4, 7 | shares_mined -> Int4, 8 | } 9 | } 10 | 11 | table! { 12 | wallets (address) { 13 | address -> Uuid, 14 | club_name -> Text, 15 | } 16 | } 17 | 18 | joinable!(miners -> wallets (address)); 19 | 20 | allow_tables_to_appear_in_same_query!( 21 | miners, 22 | wallets, 23 | ); 24 | -------------------------------------------------------------------------------- /mining-pool-api/src/util.rs: -------------------------------------------------------------------------------- 1 | use { 2 | actix_web::HttpResponse, 3 | serde::{Deserialize, Serialize}, 4 | }; 5 | 6 | 7 | #[derive(Debug, Deserialize, Serialize)] 8 | pub struct NotFoundMessage { 9 | message: String, 10 | } 11 | 12 | impl NotFoundMessage { 13 | pub fn new(message: String) -> Self { 14 | Self { 15 | message 16 | } 17 | } 18 | } 19 | 20 | pub enum ResponseType { 21 | Ok(T), 22 | NotFound(T), 23 | Created(T), 24 | } 25 | 26 | impl ResponseType { 27 | pub fn get_response(&self) -> HttpResponse { 28 | match self { 29 | ResponseType::Ok(payload) => HttpResponse::Ok() 30 | .content_type("application/json") 31 | .json(payload), 32 | ResponseType::NotFound(message) => HttpResponse::BadRequest() 33 | .content_type("application/json") 34 | .json(message), 35 | ResponseType::Created(payload) => HttpResponse::Created() 36 | .content_type("application/json") 37 | .json(payload), 38 | } 39 | } 40 | } -------------------------------------------------------------------------------- /mining-pool-api/src/wallet.rs: -------------------------------------------------------------------------------- 1 | use { 2 | diesel::{ 3 | ExpressionMethods, 4 | Insertable, 5 | Queryable, 6 | RunQueryDsl 7 | }, 8 | diesel::query_dsl::methods::FilterDsl, 9 | diesel::result::Error, 10 | serde::{ 11 | Deserialize, 12 | Serialize 13 | }, 14 | uuid::Uuid, 15 | super::schema::wallets, 16 | crate::DBPooledConnection, 17 | crate::miner::{Miner, MinerDAO}, 18 | }; 19 | 20 | 21 | 22 | // --------------- JSON Payload (REST) 23 | 24 | 25 | #[derive(Debug, Deserialize, Serialize)] 26 | pub struct Wallet { 27 | pub address: String, 28 | pub club_name: String, 29 | pub total_hash_rate: i32, 30 | pub total_shares_mined: i32, 31 | pub total_workers_online: i32, 32 | pub workers_online: Vec, 33 | } 34 | 35 | impl Wallet { 36 | pub fn to_wallet_dao(&self) -> WalletDAO { 37 | WalletDAO { 38 | address: Uuid::parse_str(self.address.as_str()).unwrap(), 39 | club_name: self.club_name.to_string(), 40 | } 41 | } 42 | } 43 | 44 | 45 | // --------------- POST Request Body for new Miner 46 | 47 | 48 | #[derive(Debug, Deserialize, Serialize)] 49 | pub struct NewWalletRequest { 50 | club_name: String, 51 | } 52 | 53 | 54 | 55 | // --------------- DAO Object (DB Table Records) 56 | 57 | 58 | #[derive(Queryable, Insertable)] 59 | #[table_name = "wallets"] 60 | pub struct WalletDAO { 61 | pub address: Uuid, 62 | pub club_name: String, 63 | } 64 | 65 | impl WalletDAO { 66 | pub fn to_wallet(&self, workers_online: Vec) -> Wallet { 67 | Wallet { 68 | address: self.address.to_string(), 69 | club_name: self.club_name.to_string(), 70 | total_hash_rate: workers_online.iter().map(|w| w.hash_rate).sum(), 71 | total_shares_mined: workers_online.iter().map(|w| w.shares_mined).sum(), 72 | total_workers_online: workers_online.len() as i32, 73 | workers_online, 74 | } 75 | } 76 | } 77 | 78 | 79 | // --------------- Service Methods 80 | 81 | 82 | pub fn fetch_all_wallets(conn: &DBPooledConnection) -> Vec { 83 | use crate::schema::miners::dsl::*; 84 | use crate::schema::wallets::dsl::*; 85 | let all_wallets = match wallets.load::(conn) { 86 | Ok(result) => result, 87 | Err(_) => vec![], 88 | }; 89 | let all_miners = match miners.load::(conn) { 90 | Ok(result) => result, 91 | Err(_) => vec![], 92 | }; 93 | all_wallets.into_iter().map(|w| { 94 | let mut workers_online = vec![]; 95 | for m in all_miners.iter() { 96 | if m.address.eq(&w.address) { 97 | workers_online.push( 98 | m.to_miner(w.club_name.clone()) 99 | ); 100 | }; 101 | }; 102 | w.to_wallet(workers_online) 103 | }).collect::>() 104 | } 105 | 106 | 107 | pub fn fetch_wallet_by_id(_address: Uuid, conn: &DBPooledConnection) -> Option { 108 | use crate::schema::miners::dsl::*; 109 | use crate::schema::wallets::dsl::*; 110 | match wallets 111 | .filter(crate::schema::wallets::address.eq(_address)) 112 | .load::(conn) { 113 | Ok(result) => match result.first() { 114 | Some(matched_wallet_dao) => { 115 | match miners 116 | .filter(crate::schema::miners::address.eq(_address)) 117 | .load::(conn) { 118 | Ok(miner_result) => Some(matched_wallet_dao.to_wallet( 119 | miner_result.into_iter().map(|m| { 120 | m.to_miner(matched_wallet_dao.club_name.clone()) 121 | }).collect::>())), 122 | Err(_) => Some(matched_wallet_dao.to_wallet(vec![])), 123 | } 124 | }, 125 | _ => return None, 126 | }, 127 | Err(_) => None, 128 | } 129 | } 130 | 131 | pub fn create_new_wallet(new_wallet_request: NewWalletRequest, conn: &DBPooledConnection) -> Result { 132 | use crate::schema::wallets::dsl::*; 133 | let new_wallet_dao = WalletDAO { 134 | address: Uuid::new_v4(), 135 | club_name: new_wallet_request.club_name, 136 | }; 137 | match diesel::insert_into(wallets).values(&new_wallet_dao).execute(conn) { 138 | Ok(_) => Ok(new_wallet_dao.to_wallet(vec![])), 139 | Err(e) => Err(e), 140 | } 141 | } -------------------------------------------------------------------------------- /mining-pool-api/src/wallet_controller.rs: -------------------------------------------------------------------------------- 1 | use { 2 | actix_web::HttpResponse, 3 | actix_web::web::{Data, Json, Path}, 4 | uuid::Uuid, 5 | 6 | crate::DBPool, 7 | crate::util::{NotFoundMessage, ResponseType}, 8 | crate::wallet::*, 9 | }; 10 | 11 | 12 | // List all Wallets 13 | #[get("/wallets")] 14 | pub async fn list_wallets(pool: Data) -> HttpResponse { 15 | let conn = crate::get_connection_to_pool(pool); 16 | let wallets: Vec = fetch_all_wallets(&conn); 17 | ResponseType::Ok(wallets).get_response() 18 | } 19 | 20 | // Get a wallet 21 | #[get("/wallets/{id}")] 22 | pub async fn get_wallet(path: Path<(String,)>, pool: Data) -> HttpResponse { 23 | let conn = crate::get_connection_to_pool(pool); 24 | let wallet: Option = fetch_wallet_by_id( 25 | Uuid::parse_str(path.0.0.as_str()).unwrap(), &conn); 26 | match wallet { 27 | Some(wallet) => ResponseType::Ok(wallet).get_response(), 28 | None => ResponseType::NotFound( 29 | NotFoundMessage::new("Wallet/Club not found".to_string()) 30 | ).get_response(), 31 | } 32 | } 33 | 34 | // Create New Wallet 35 | #[post("/wallets")] 36 | pub async fn create_wallet(wallet_request: Json, pool: Data) -> HttpResponse { 37 | let conn = crate::get_connection_to_pool(pool); 38 | match create_new_wallet(wallet_request.0, &conn) { 39 | Ok(created_wallet) => ResponseType::Created(created_wallet).get_response(), 40 | Err(_) => ResponseType::NotFound( 41 | NotFoundMessage::new("Error creating wallet.".to_string()) 42 | ).get_response(), 43 | } 44 | } -------------------------------------------------------------------------------- /pointers/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "pointers" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /pointers/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "pointers" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /pointers/src/main.rs: -------------------------------------------------------------------------------- 1 | 2 | 3 | // Pointers 4 | 5 | // Lifetimes 6 | 7 | fn lifetimes() { 8 | let x = 5; 9 | 10 | println!("{}", &x); 11 | 12 | println!("{}", &x); 13 | } 14 | 15 | fn specific_lifetimes<'a>(val1: &str, val2: &str) -> &'a str { 16 | 17 | println!("{}, {}", val1, val2); 18 | 19 | let q = "some string slice q"; 20 | q 21 | } 22 | 23 | const constant: &'static str = "some constant static string slice."; 24 | 25 | // Strings vs String Slices (&str) 26 | 27 | fn burn_this_string(string: &String) { 28 | if string.len() < 0 { 29 | panic![]; 30 | } 31 | } 32 | 33 | fn burn_this_string_slice(string_slice: &str) { 34 | if string_slice.len() < 0 { 35 | panic![]; 36 | } 37 | } 38 | 39 | fn main() { 40 | 41 | let some_string = String::from("Johnny"); 42 | burn_this_string(&some_string); 43 | println!("{}", some_string); 44 | 45 | let some_string_slice = "Johnny"; 46 | burn_this_string_slice(some_string_slice); 47 | println!("{}", some_string_slice); 48 | 49 | } 50 | -------------------------------------------------------------------------------- /rust-and-docker/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "rust-and-docker" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /rust-and-docker/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rust-and-docker" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /rust-and-docker/alpine-mismatch.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:1.58 as builder 2 | 3 | RUN cargo new --bin rust-and-docker 4 | WORKDIR ./rust-and-docker 5 | COPY ./Cargo.toml ./Cargo.toml 6 | COPY ./src ./src 7 | RUN cargo build --release 8 | 9 | FROM alpine:latest 10 | COPY --from=builder /rust-and-docker/target/release/rust-and-docker ./rust-and-docker 11 | CMD ["./rust-and-docker"] -------------------------------------------------------------------------------- /rust-and-docker/docker-alpine.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:alpine3.14 as builder 2 | 3 | RUN cargo new --bin rust-and-docker 4 | WORKDIR ./rust-and-docker 5 | COPY ./Cargo.toml ./Cargo.toml 6 | COPY ./src ./src 7 | RUN cargo build --release 8 | 9 | FROM alpine:latest 10 | COPY --from=builder /rust-and-docker/target/release/rust-and-docker ./rust-and-docker 11 | CMD ["./rust-and-docker"] -------------------------------------------------------------------------------- /rust-and-docker/docker-centos.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:1.58 as builder 2 | 3 | RUN cargo new --bin rust-and-docker 4 | WORKDIR ./rust-and-docker 5 | COPY ./Cargo.toml ./Cargo.toml 6 | COPY ./src ./src 7 | RUN cargo build --release 8 | 9 | FROM centos:latest 10 | COPY --from=builder /rust-and-docker/target/release/rust-and-docker ./rust-and-docker 11 | CMD ["./rust-and-docker"] -------------------------------------------------------------------------------- /rust-and-docker/docker-debian.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:slim-buster as builder 2 | 3 | RUN cargo new --bin rust-and-docker 4 | WORKDIR ./rust-and-docker 5 | COPY ./Cargo.toml ./Cargo.toml 6 | COPY ./src ./src 7 | RUN cargo build --release 8 | 9 | FROM debian:buster-slim 10 | COPY --from=builder /rust-and-docker/target/release/rust-and-docker ./rust-and-docker 11 | CMD ["./rust-and-docker"] -------------------------------------------------------------------------------- /rust-and-docker/src/main.rs: -------------------------------------------------------------------------------- 1 | fn main() { 2 | println!("Hello, world, from Docker!"); 3 | } 4 | -------------------------------------------------------------------------------- /some_bin/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "some_bin" 7 | version = "0.1.0" 8 | dependencies = [ 9 | "some_lib", 10 | ] 11 | 12 | [[package]] 13 | name = "some_lib" 14 | version = "0.1.0" 15 | -------------------------------------------------------------------------------- /some_bin/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "some_bin" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | some_lib = {path = "../some_lib"} -------------------------------------------------------------------------------- /some_bin/src/main.rs: -------------------------------------------------------------------------------- 1 | 2 | use some_lib::*; 3 | use some_lib_functions::*; 4 | 5 | fn main() { 6 | whats_up(); 7 | nothing_much(); 8 | } 9 | -------------------------------------------------------------------------------- /some_lib/Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "some_lib" 7 | version = "0.1.0" 8 | -------------------------------------------------------------------------------- /some_lib/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "some_lib" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | -------------------------------------------------------------------------------- /some_lib/src/lib.rs: -------------------------------------------------------------------------------- 1 | 2 | pub mod some_lib_functions; 3 | 4 | pub fn whats_up() { 5 | println!("What's up?"); 6 | let x = vec![1, 2]; 7 | let x = vec!['1', '2']; 8 | } 9 | 10 | -------------------------------------------------------------------------------- /some_lib/src/some_lib_functions.rs: -------------------------------------------------------------------------------- 1 | 2 | 3 | pub fn nothing_much() { 4 | println!("Nothing much!"); 5 | } --------------------------------------------------------------------------------