mirror of
https://github.com/kaspanet/kaspad.git
synced 2025-03-30 15:08:33 +00:00

* [NOD-833] Remove getBlockTemplate capabilites and move mining address to getBlockTemplate * [NOD-833] Fix tests * [NOD-833] Break long lines
66 lines
1.3 KiB
Go
66 lines
1.3 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/kaspanet/kaspad/util"
|
|
"os"
|
|
|
|
"github.com/kaspanet/kaspad/version"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
_ "net/http/pprof"
|
|
|
|
"github.com/kaspanet/kaspad/signal"
|
|
"github.com/kaspanet/kaspad/util/panics"
|
|
"github.com/kaspanet/kaspad/util/profiling"
|
|
)
|
|
|
|
func main() {
|
|
defer panics.HandlePanic(log, nil)
|
|
interrupt := signal.InterruptListener()
|
|
|
|
cfg, err := parseConfig()
|
|
if err != nil {
|
|
fmt.Fprintf(os.Stderr, "Error parsing command-line arguments: %s\n", err)
|
|
os.Exit(1)
|
|
}
|
|
|
|
// Show version at startup.
|
|
log.Infof("Version %s", version.Version())
|
|
|
|
if cfg.Verbose {
|
|
enableRPCLogging()
|
|
}
|
|
|
|
// Enable http profiling server if requested.
|
|
if cfg.Profile != "" {
|
|
profiling.Start(cfg.Profile, log)
|
|
}
|
|
|
|
client, err := connectToServer(cfg)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error connecting to the RPC server"))
|
|
}
|
|
defer client.Disconnect()
|
|
|
|
miningAddr, err := util.DecodeAddress(cfg.MiningAddr, cfg.ActiveNetParams.Prefix)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error decoding mining address"))
|
|
}
|
|
|
|
doneChan := make(chan struct{})
|
|
spawn(func() {
|
|
err = mineLoop(client, cfg.NumberOfBlocks, cfg.BlockDelay, cfg.MineWhenNotSynced, miningAddr)
|
|
if err != nil {
|
|
panic(errors.Wrap(err, "error in mine loop"))
|
|
}
|
|
doneChan <- struct{}{}
|
|
})
|
|
|
|
select {
|
|
case <-doneChan:
|
|
case <-interrupt:
|
|
}
|
|
}
|