diff --git a/config.go b/config.go index a01583d..ddd6aff 100644 --- a/config.go +++ b/config.go @@ -4,12 +4,13 @@ var command_line string = `derohe-proxy Proxy to combine all miners and to reduce network load Usage: - derohe-proxy [--listen-address=<127.0.0.1:10100>] [--log-interval=<60>] --daemon-address=<1.2.3.4:10100> + derohe-proxy [--listen-address=<127.0.0.1:10100>] [--log-interval=<60>] [--minimal-jobs] --daemon-address=<1.2.3.4:10100> Options: --listen-address=<127.0.0.1:10100> bind to specific address:port, default is 0.0.0.0:10200 --daemon-address=<1.2.3.4:10100> connect to this daemon --log-interval=<60> set logging interval in seconds (range 60 - 3600), default is 60 seconds + --minimal-jobs forward only 2 jobs per block (1 for miniblocks and 1 for final miniblock), by default all jobs are forwarded Example Mainnet: ./derohe-proxy --daemon-address=minernode1.dero.io:10100 ` @@ -22,3 +23,6 @@ var daemon_address string = "minernode1.dero.io:10100" // logging interval in seconds var log_intervall int = 60 + +// send only 2 jobs per block +var minimal = false diff --git a/derohe-proxy b/derohe-proxy new file mode 100644 index 0000000..21a774f Binary files /dev/null and b/derohe-proxy differ diff --git a/derohe-proxy.go b/derohe-proxy.go index 4f3b6c0..db8adbe 100644 --- a/derohe-proxy.go +++ b/derohe-proxy.go @@ -51,6 +51,11 @@ func main() { } } + if Arguments["--minimal-jobs"] != nil { + minimal = true + fmt.Printf("Forward 2 jobs per block\n") + } + fmt.Printf("Logging every %d seconds\n", log_intervall) go proxy.Start_server(listen_addr) @@ -59,7 +64,7 @@ func main() { for proxy.CountMiners() < 1 { time.Sleep(time.Second * 1) } - go proxy.Start_client(daemon_address, proxy.Address) + go proxy.Start_client(daemon_address, proxy.Address, minimal) for { time.Sleep(time.Second * time.Duration(log_intervall)) diff --git a/proxy/client.go b/proxy/client.go index 35c77b8..9e37e7e 100644 --- a/proxy/client.go +++ b/proxy/client.go @@ -18,8 +18,10 @@ var Minis uint64 var Rejected uint64 // proxy-client -func Start_client(v string, w string) { +func Start_client(v string, w string, min_jobs bool) { var err error + var last_diff uint64 + var last_height uint64 rand.Seed(time.Now().UnixMilli()) @@ -60,7 +62,15 @@ func Start_client(v string, w string) { Minis = params.MiniBlocks Rejected = params.Rejected - go SendTemplateToNodes(recv_data) + if min_jobs { + if params.Height != last_height || params.Difficultyuint64 != last_diff { + last_height = params.Height + last_diff = params.Difficultyuint64 + go SendTemplateToNodes(recv_data) + } + } else { + go SendTemplateToNodes(recv_data) + } } } }