Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configurable stratum diff, block refresh, and extranonce #59

Merged
merged 10 commits into from
Dec 13, 2022
23 changes: 22 additions & 1 deletion cmd/kaspabridge/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,27 @@ stratum_port: :5555
# kaspad_address: 46.17.104.200:16110
kaspad_address: localhost:16110

# min_share_diff: only accept shares of the specified difficulty (or higher) from
# the miner(s). Higher values will reduce the number of shares submitted, thereby
# reducing network traffic and server load, while lower values will increase the
# number of shares submitted, thereby reducing the amount of time needed for
# accurate hashrate measurements
# min_share_diff: 4

# block_wait_time: time to wait since last new block message from kaspad before
# manually requesting a new block
# block_wait_time: 500ms

# extranonce_size: size in bytes of extranonce, from 0 (no extranonce) to 3.
# With no extranonce (0), all clients will search through the same nonce-space,
# therefore performing duplicate work unless the miner(s) implement client
# side nonce randomizing. More bytes allow for more clients with unique
# nonce-spaces (i.e. no overlapping work), but reduces the per client
# overall nonce-space (though with 1s block times, this shouldn't really
# be a concern).
# 1 byte = 256 clients, 2 bytes = 65536, 3 bytes = 16777216.
# extranonce_size: 0

# print_stats: if true will print stats to the console, false just workers
# joining/disconnecting, blocks found, and errors will be printed
print_stats: true
Expand All @@ -22,4 +43,4 @@ log_to_file: true
# Note `:PORT` format is needed if not specifiying a specific ip range
prom_port: :2114


18 changes: 12 additions & 6 deletions cmd/kaspabridge/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,25 @@ func main() {
flag.StringVar(&cfg.StratumPort, "stratum", cfg.StratumPort, "stratum port to listen on, default `:5555`")
flag.BoolVar(&cfg.PrintStats, "stats", cfg.PrintStats, "true to show periodic stats to console, default `true`")
flag.StringVar(&cfg.RPCServer, "kaspa", cfg.RPCServer, "address of the kaspad node, default `localhost:16110`")
flag.DurationVar(&cfg.BlockWaitTime, "blockwait", cfg.BlockWaitTime, "time in ms to wait before manually requesting new block, default `500`")
flag.UintVar(&cfg.MinShareDiff, "mindiff", cfg.MinShareDiff, "minimum share difficulty to accept from miner(s), default `4`")
flag.UintVar(&cfg.ExtranonceSize, "extranonce", cfg.ExtranonceSize, "size in bytes of extranonce, default `0`")
flag.StringVar(&cfg.PromPort, "prom", cfg.PromPort, "address to serve prom stats, default `:2112`")
flag.BoolVar(&cfg.UseLogFile, "log", cfg.UseLogFile, "if true will output errors to log file, default `true`")
flag.StringVar(&cfg.HealthCheckPort, "hcp", cfg.HealthCheckPort, `(rarely used) if defined will expose a health check on /readyz, default ""`)
flag.Parse()

log.Println("----------------------------------")
log.Printf("initializing bridge")
log.Printf("\tkaspad: %s", cfg.RPCServer)
log.Printf("\tstratum: %s", cfg.StratumPort)
log.Printf("\tprom: %s", cfg.PromPort)
log.Printf("\tstats: %t", cfg.PrintStats)
log.Printf("\tlog: %t", cfg.UseLogFile)
log.Printf("\thealth check: %s", cfg.HealthCheckPort)
log.Printf("\tkaspad: %s", cfg.RPCServer)
log.Printf("\tstratum: %s", cfg.StratumPort)
log.Printf("\tprom: %s", cfg.PromPort)
log.Printf("\tstats: %t", cfg.PrintStats)
log.Printf("\tlog: %t", cfg.UseLogFile)
log.Printf("\tmin diff: %d", cfg.MinShareDiff)
log.Printf("\tblock wait: %s", cfg.BlockWaitTime)
log.Printf("\textranonce size: %d", cfg.ExtranonceSize)
log.Printf("\thealth check: %s", cfg.HealthCheckPort)
log.Println("----------------------------------")

if err := kaspastratum.ListenAndServe(cfg); err != nil {
Expand Down
2 changes: 1 addition & 1 deletion make_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ CMD_PATH="../cmd/kaspabridge"
rm -rf release
mkdir -p release
cd release
VERSION=1.1.5
VERSION=1.1.6
ARCHIVE="ks_bridge-${VERSION}"
OUTFILE="ks_bridge"
OUTDIR="ks_bridge"
Expand Down
Loading