/
main.go
43 lines (37 loc) · 1.12 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"github.com/sedraxnet/sedrax/domain/consensus"
"github.com/sedraxnet/sedrax/stability-tests/common"
"github.com/sedraxnet/sedrax/stability-tests/common/mine"
"github.com/sedraxnet/sedrax/stability-tests/common/rpc"
"github.com/sedraxnet/sedrax/util/panics"
"github.com/sedraxnet/sedrax/util/profiling"
"github.com/pkg/errors"
)
func main() {
defer panics.HandlePanic(log, "minejson-main", nil)
err := parseConfig()
if err != nil {
panic(errors.Wrap(err, "error parsing configuration"))
}
defer backendLog.Close()
common.UseLogger(backendLog, log.Level())
cfg := activeConfig()
if cfg.Profile != "" {
profiling.Start(cfg.Profile, log)
}
rpcClient, err := rpc.ConnectToRPC(&cfg.Config, cfg.NetParams())
if err != nil {
panic(errors.Wrap(err, "error connecting to JSON-RPC server"))
}
defer rpcClient.Disconnect()
dataDir, err := common.TempDir("minejson")
if err != nil {
panic(err)
}
consensusConfig := consensus.Config{Params: *cfg.NetParams()}
err = mine.FromFile(cfg.DAGFile, &consensusConfig, rpcClient, dataDir)
if err != nil {
panic(errors.Wrap(err, "error in mine.FromFile"))
}
}