Added worker name support for proxy

This commit is contained in:
8lecramm 2022-12-28 19:33:42 +01:00 committed by GitHub
parent 156e068c5f
commit 735376ef60
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 35 additions and 9 deletions

View File

@ -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

View File

@ -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 {

View File

@ -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

View File

@ -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++
}
//}
})