Skip to content

Commit 29d2c8b

Browse files
committed
修改random 为is_fee
1 parent 64a44a3 commit 29d2c8b

File tree

3 files changed

+29
-7
lines changed

3 files changed

+29
-7
lines changed

core/src/client/handle_stream.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use crate::{
1717
CLIENT_LOGIN, CLIENT_SUBMITWORK,
1818
},
1919
state::Worker,
20-
util::{config::Settings, is_fee_random},
20+
util::{config::Settings, is_fee, is_fee_random},
2121
};
2222
use crate::{
2323
protocol::ethjson::{
@@ -303,7 +303,7 @@ where
303303
if let Ok(rpc) = serde_json::from_str::<EthServerRootObject>(buf) {
304304
// 增加索引
305305
worker.send_job()?;
306-
if is_fee_random(*DEVELOP_FEE) {
306+
if is_fee(worker.total_send_idx,*DEVELOP_FEE) {
307307
#[cfg(debug_assertions)]
308308
debug!("进入开发者抽水回合");
309309

@@ -353,12 +353,11 @@ where
353353
write_rpc(is_encrypted,&mut worker_w,&job_rpc,&worker_name).await?;
354354
continue;
355355
}
356-
} else if is_fee_random(config.share_rate.into()) {
356+
} else if is_fee(worker.total_send_idx,config.share_rate.into()) {
357357
#[cfg(debug_assertions)]
358358
debug!("进入普通抽水回合");
359359
if let Some(job_res) = wait_job.pop_back() {
360-
//if let Ok(job_res) = chan.try_recv() {
361-
360+
362361
job_rpc.result = job_res.clone();
363362
let hi = job_rpc.get_hight();
364363
if hi != 0 {

local-pool/src/main.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1-
use anyhow::Result;
1+
use anyhow::{anyhow, Result};
22
use clap::{
33
crate_description, crate_name, crate_version, App, Arg, ArgMatches,
44
};
55
use std::net::ToSocketAddrs;
6+
use tokio::{io::AsyncWriteExt, net::TcpSocket};
67

78
mod encrypt;
9+
mod server;
810
use encrypt::accept_encrypt_tcp;
911

1012
#[tokio::main]
@@ -36,14 +38,27 @@ async fn main() -> Result<()> {
3638
}
3739
};
3840

39-
let res = tokio::try_join!(accept_encrypt_tcp(port, addr));
41+
let res =
42+
tokio::try_join!(accept_encrypt_tcp(port, addr), server_tcp(addr));
43+
4044
if let Err(err) = res {
4145
tracing::info!("加密服务断开: {}", err);
4246
}
4347

4448
Ok(())
4549
}
4650

51+
async fn server_tcp(addr: std::net::SocketAddr) -> Result<()> {
52+
let socket = TcpSocket::new_v4()?;
53+
let mut s = socket.connect(addr).await?;
54+
55+
s.write_all(b"Hello world").await?;
56+
//发送当前钱包地址。后续的任务全部提交给一个钱包。
57+
//let (read,write) = s.split();
58+
59+
return Err(anyhow!("非正常退出"));
60+
}
61+
4762
pub async fn get_encrypt_command_matches() -> Result<ArgMatches<'static>> {
4863
let matches = App::new(format!(
4964
"{}, 版本: {}",

local-pool/src/server/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
pub struct Server {}
2+
3+
impl Server {
4+
pub fn new() -> Self { Server {} }
5+
}
6+
7+
#[test]
8+
fn test_server_new() { let s = Server::new(); }

0 commit comments

Comments
 (0)