Skip to content

Commit

Permalink
Merging in 4byte branch changes
Browse files Browse the repository at this point in the history
  • Loading branch information
arodd committed Jul 1, 2022
2 parents 002e843 + 8bfcb69 commit 0f31f78
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 76 deletions.
7 changes: 6 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var CommandLine 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>] [--jobrate=<500ms>] [--minimal] [--nonce] [--zero] [--global] [--verbose] --daemon-address=<1.2.3.4:10100> [--testnet]
derohe-proxy [--listen-address=<127.0.0.1:10100>] [--log-interval=<60>] [--jobrate=<500ms>] [--minimal] [--nonce] [--zero] [--global] [--walletfile] [--quantum] [--verbose] --daemon-address=<1.2.3.4:10100> [--testnet]
Options:
--listen-address=<127.0.0.1:10100> bind to specific address:port, default is 0.0.0.0:10200
Expand All @@ -19,8 +19,11 @@ Options:
--nonce enable nonce/flag editing, default is off
--zero enable zero nonce2/flags
--global enable global nonce sharing for first 9 bytes, only enabled with nonce editing flag
--walletfile enable reading shared wallets from a json file "wallets.json" and rotate through each wallet per job globally
--quantum enable quantum nonce generation from qrand api(fallback to crypto/rand)
--verbose enable nonce/flag printing, default is off
Example Mainnet: ./derohe-proxy --daemon-address=minernode1.dero.io:10100
`

Expand All @@ -38,4 +41,6 @@ type ProxyConfig struct {
ZeroNonce bool
Verbose bool
JobRate time.Duration
WalletFile bool
Quantum bool
}
28 changes: 21 additions & 7 deletions derohe-proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ var proxyConfig = config.ProxyConfig{
ZeroNonce: false,
Verbose: false,
JobRate: (500 * time.Millisecond),
WalletFile: false,
Quantum: false,
}

func main() {
Expand Down Expand Up @@ -91,26 +93,35 @@ func main() {
fmt.Printf("%v Global Nonce targeting is enabled\n", time.Now().Format(time.Stamp))
}

if config.Arguments["--walletfile"].(bool) {
proxyConfig.WalletFile = true
fmt.Printf("%v Global Wallet List Enabled\n", time.Now().Format(time.Stamp))
}

if config.Arguments["--quantum"].(bool) {
proxyConfig.Quantum = true
fmt.Printf("%v Quantum Random Data Enabled...will fallback to crypto/rand if unavailable\n", time.Now().Format(time.Stamp))
}

if config.Arguments["--verbose"].(bool) {
proxyConfig.Verbose = true
fmt.Printf("%v Verbose nonce output is enabled\n", time.Now().Format(time.Stamp))
}

fmt.Printf("%v Logging every %d seconds\n", time.Now().Format(time.Stamp), proxyConfig.LogInterval)
fmt.Printf("%v Job Dispatch Rate: %s\n", time.Now().Format(time.Stamp), proxyConfig.JobRate.String())
if proxyConfig.NonceEdit {
go proxy.RandomGenerator(&proxyConfig)

go proxy.Start_server(proxyConfig)
fmt.Print("Building random data for 10 sec...\n")
time.Sleep(time.Second * 10)
}
go proxy.Start_server(&proxyConfig)

// Wait for first miner connection to grab wallet address
for proxy.CountMiners() < 1 {
time.Sleep(time.Second * 1)
}
if proxyConfig.NonceEdit {
go proxy.RandomGenerator()

fmt.Print("Building random data for 10 sec...\n")
time.Sleep(time.Second * 10)
}

go proxy.Start_client(proxy.Address)

Expand All @@ -122,5 +133,8 @@ func main() {
fmt.Printf("%v Wallet %v, %d miners\n", time.Now().Format(time.Stamp), i, proxy.Wallet_count[i])
}
}
if proxyConfig.WalletFile {
proxy.LoadWalletsFile()
}
}
}
9 changes: 6 additions & 3 deletions proxy/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"math/rand"
"net/url"
"strings"
"time"
Expand All @@ -26,8 +25,6 @@ func Start_client(w string) {
var jobs_per_block int
var jobtimer time.Time

rand.Seed(time.Now().UnixNano())

for {
u := url.URL{Scheme: "wss", Host: proxyConfig.DaemonAddr, Path: "/ws/" + w}

Expand All @@ -45,6 +42,7 @@ func Start_client(w string) {
}

var params rpc.GetBlockTemplate_Result
var lastjobid string

for {
msg_type, recv_data, err := connection.ReadMessage()
Expand All @@ -64,6 +62,10 @@ func Start_client(w string) {
Blocks = params.Blocks
Minis = params.MiniBlocks
Rejected = params.Rejected
if lastjobid == params.JobID {
continue
}
lastjobid = params.JobID

if proxyConfig.Minimal {
//finalblock := strings.HasPrefix(params.Blockhashing_blob, "71")
Expand All @@ -90,6 +92,7 @@ func Start_client(w string) {
}

jobs_per_block = 0

go SendTemplateToNodes(recv_data)
jobtimer = time.Now()
jobs_per_block++
Expand Down
Loading

0 comments on commit 0f31f78

Please sign in to comment.