From 735376ef6099cc22b233e20ee3673a4d2d39c084 Mon Sep 17 00:00:00 2001 From: 8lecramm <89603217+8lecramm@users.noreply.github.com> Date: Wed, 28 Dec 2022 19:33:42 +0100 Subject: [PATCH] Added worker name support for proxy --- config/config.go | 1 + derohe-proxy.go | 29 ++++++++++++++++++++++++++--- proxy/client.go | 9 ++++++--- proxy/server.go | 5 ++--- 4 files changed, 35 insertions(+), 9 deletions(-) diff --git a/config/config.go b/config/config.go index d0fb4cf..2fe5a52 100644 --- a/config/config.go +++ b/config/config.go @@ -24,6 +24,7 @@ var Arguments = map[string]interface{}{} var Listen_addr string = "0.0.0.0:10200" var Daemon_address string = "minernode1.dero.io:10100" var WalletAddr string = "" +var Worker string // logging interval in seconds var Log_intervall int = 60 diff --git a/derohe-proxy.go b/derohe-proxy.go index 4b58ed7..cc3c4e3 100644 --- a/derohe-proxy.go +++ b/derohe-proxy.go @@ -6,6 +6,7 @@ import ( "fmt" "net" "strconv" + "strings" "sync" "time" @@ -43,12 +44,29 @@ func main() { } if config.Arguments["--wallet-address"] != nil { - addr, err := globals.ParseValidateAddress(config.Arguments["--wallet-address"].(string)) + + // check for worker suffix + var parseWorker []string + var address string + + if strings.Contains(config.Arguments["--wallet-address"].(string), ".") { + parseWorker = strings.Split(config.Arguments["--wallet-address"].(string), ".") + config.Worker = parseWorker[1] + address = parseWorker[0] + } else { + address = config.Arguments["--wallet-address"].(string) + } + + addr, err := globals.ParseValidateAddress(address) if err != nil { fmt.Printf("%v Wallet address is invalid!\n", time.Now().Format(time.Stamp)) } config.WalletAddr = addr.String() - fmt.Printf("%v Using wallet %s for all connections\n", time.Now().Format(time.Stamp), config.WalletAddr) + if config.Worker != "" { + fmt.Printf("%v Using wallet %s and name %s for all connections\n", time.Now().Format(time.Stamp), config.WalletAddr, config.Worker) + } else { + fmt.Printf("%v Using wallet %s for all connections\n", time.Now().Format(time.Stamp), config.WalletAddr) + } } if config.Arguments["--log-interval"] != nil { @@ -88,7 +106,11 @@ func main() { for proxy.CountMiners() < 1 { time.Sleep(time.Second * 1) } - go proxy.Start_client(proxy.Address) + if config.Worker == "" { + go proxy.Start_client(proxy.Address) + } else { + go proxy.Start_client(proxy.Address + "." + config.Worker) + } //go proxy.SendUpdateToDaemon() for { @@ -113,6 +135,7 @@ func main() { fmt.Printf("%v %d miners connected, IB:%d MB:%d MBR:%d MBO:%d - MINING @ %s\n", time.Now().Format(time.Stamp), proxy.CountMiners(), proxy.Blocks, proxy.Minis, proxy.Rejected, proxy.Orphans, hash_rate_string) } else { fmt.Printf("%v %d miners connected, Pool stats: IB:%d MB:%d MBR:%d MBO:%d - MINING @ %s\n", time.Now().Format(time.Stamp), proxy.CountMiners(), proxy.Blocks, proxy.Minis, proxy.Rejected, proxy.Orphans, hash_rate_string) + fmt.Printf("%v Shares submitted: %d\n", time.Now().Format(time.Stamp), proxy.Shares) } rwmutex.RLock() for i := range proxy.Wallet_count { diff --git a/proxy/client.go b/proxy/client.go index be02b5f..a72031b 100644 --- a/proxy/client.go +++ b/proxy/client.go @@ -50,6 +50,7 @@ var Minis uint64 var Rejected uint64 var Orphans uint64 var ModdedNode bool = false +var noRepeat bool var Hashrate float64 // proxy-client @@ -106,12 +107,14 @@ func Start_client(w string) { if params.Hansen33Mod { fmt.Printf("%v Hansen33 Mod Mining Node Detected - Happy Mining\n", time.Now().Format(time.Stamp)) } + } else { + if !noRepeat { + noRepeat = true + fmt.Printf("%v Official Mining Node Detected - Happy Mining\n", time.Now().Format(time.Stamp)) + } } ModdedNode = params.Hansen33Mod - if !ModdedNode { - fmt.Printf("%v Official Mining Node Detected - Happy Mining\n", time.Now().Format(time.Stamp)) - } if config.Minimal { if params.Height != last_height || params.Difficultyuint64 != last_diff { last_height = params.Height diff --git a/proxy/server.go b/proxy/server.go index 2a136bf..8a345e7 100644 --- a/proxy/server.go +++ b/proxy/server.go @@ -59,7 +59,7 @@ var client_list_mutex sync.Mutex var client_list = map[*websocket.Conn]*user_session{} var miners_count int -var shares uint64 +var Shares uint64 var Wallet_count map[string]uint var Address string @@ -238,8 +238,7 @@ func newUpgrader() *websocket.Upgrader { if !config.Pool_mode { fmt.Printf("%v Submitting result from miner: %v (%v), Wallet: %v\n", time.Now().Format(time.Stamp), c.RemoteAddr().String(), client_list[c].worker, client_list[c].address.String()) } else { - shares++ - fmt.Printf("%v Shares submitted: %d\n", time.Now().Format(time.Stamp), shares) + Shares++ } //} })