Skip to content

Commit

Permalink
Mining functional with lycl on Linux
Browse files Browse the repository at this point in the history
  • Loading branch information
gertjaap committed Jun 27, 2019
1 parent 9482153 commit 42b2170
Show file tree
Hide file tree
Showing 10 changed files with 754 additions and 107 deletions.
17 changes: 12 additions & 5 deletions frontend/src/components/Checks.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
<template>
<div class="container">
<p v-if="checkStatus !== 'Failed'">{{checkStatus}}...</p>
<p v-if="checkStatus === 'Failed'">
<div class="failureReason" v-if="checkStatus === 'Failed'">
Checks failed:<br/>
<pre>
{{failureReason}}
</pre>
</p>
{{failureReason}}
</div>
<div class="col-12" style="position: fixed; bottom: 10px" v-if="checkStatus === 'Failed'" >
<p>
<a @click="check">Retry</a>
Expand Down Expand Up @@ -86,4 +84,13 @@ a {
text-align: center;
border-radius: 5px;
}
div.failureReason {
height: 200px;
overflow-y: auto;
font-family: 'Courier New', Courier, monospace;
color: red;
border: 1px solid red;
width: 600px;
margin: 0 auto;
}
</style>
7 changes: 6 additions & 1 deletion frontend/src/components/Mining.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
<p class="spacer">&nbsp;</p>
<p class="header">Expected Earnings (24h):</p>
<p class="earning">~{{avgearn}} ({{hashrate}})</p>
<p class="netHash"><small>(Network hashrate: <b>{{netHash}}</b>)</small></p>
</div>
<!--<div class="col-6">
<p><b><u>Your Graphics Card(s):</u></b></p>
Expand All @@ -52,6 +53,7 @@ export default {
return {
hashrate: "0 MH/s",
avgearn:"0.00 VTC",
netHash:"Unknown",
gpu: "Unknown",
wallet: "Unknown",
balance: "0.00000000",
Expand All @@ -64,6 +66,9 @@ export default {
wails.events.on("hashRate",(result) => {
self.hashrate = result;
});
wails.events.on("networkHashRate",(result) => {
self.netHash = result;
});
wails.events.on("avgEarnings",(result) => {
self.avgearn = result;
});
Expand Down Expand Up @@ -144,7 +149,7 @@ p.spendableBalance {
padding: 0;
font-size: 24px;
}
p.immatureBalance, p.poolBalance {
p.immatureBalance, p.poolBalance, p.netHash {
margin: 0;
padding: 0;
font-size: 10pt;
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ go 1.12
require (
github.com/btcsuite/btcd v0.0.0-20190614013741-962a206e94e9
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941
github.com/leaanthony/mewn v0.10.7
github.com/tidwall/btree v0.0.0-20170113224114-9876f1454cf0 // indirect
github.com/tidwall/buntdb v1.1.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ github.com/btcsuite/btcd v0.0.0-20190614013741-962a206e94e9/go.mod h1:3J08xEfcug
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d h1:yJzD/yFppdVCf6ApMkVy8cUxV0XrxdP9rVf6D87/Mng=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941 h1:kij1x2aL7VE6gtx8KMIt8PGPgI5GV9LgtHFG5KaEMPY=
github.com/btcsuite/fastsha256 v0.0.0-20160815193821-637e65642941/go.mod h1:QcFA8DZHtuIAdYKCq/BzELOaznRsCvwf4zTPmaYwaig=
github.com/btcsuite/go-socks v0.0.0-20170105172521-4720035b7bfd/go.mod h1:HHNXQzUsZCxOoE+CPiyCTO6x34Zs86zZUiwtpXoGdtg=
github.com/btcsuite/goleveldb v0.0.0-20160330041536-7834afc9e8cd/go.mod h1:F+uVaaLLH7j4eDXPRvw78tMflu7Ie2bzYOH4Y8rRKBY=
github.com/btcsuite/snappy-go v0.0.0-20151229074030-0bdef8d06723/go.mod h1:8woku9dyThutzjeg+3xrA5iCpBRH8XEEg3lh6TiUghc=
Expand Down
4 changes: 3 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ func main() {
Colour: "#131313",
})

app.Bind(mining.NewMinerCore())
core := mining.NewMinerCore()
app.Bind(core)
app.Run()
core.StopMining()
}
92 changes: 92 additions & 0 deletions miners/lyclminer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package miners

import (
"bufio"
"fmt"
"os"
"path"
"strconv"
"strings"

"github.com/vertcoin-project/one-click-miner-vnext/logging"
"github.com/vertcoin-project/one-click-miner-vnext/util"
)

// Compile time assertion on interface
var _ MinerImpl = &LyclMinerImpl{}

type LyclMinerImpl struct {
binaryRunner *BinaryRunner
hashRate uint64
}

func NewLyclMinerImpl(br *BinaryRunner) MinerImpl {
return &LyclMinerImpl{binaryRunner: br}
}

func (l *LyclMinerImpl) Configure(args BinaryArguments) error {
os.Remove(path.Join(util.DataDirectory(), "lyclMiner_tmpl.conf"))
err := l.binaryRunner.launch([]string{"-g", path.Join(util.DataDirectory(), "lyclMiner_tmpl.conf")})
err2 := l.binaryRunner.wait()
if err != nil {
return err
}
if err2 != nil {
return err2
}

in, err := os.Open(path.Join(util.DataDirectory(), "lyclMiner_tmpl.conf"))
if err != nil {
logging.Error(err)
return err
}
defer in.Close()

os.Remove(path.Join(util.DataDirectory(), "lyclMiner.conf"))
out, err := os.Create(path.Join(util.DataDirectory(), "lyclMiner.conf"))
defer out.Close()

scanner := bufio.NewScanner(in)
skip := false
for scanner.Scan() {
line := scanner.Text()
if strings.HasPrefix(line, "#") {
skip = false
}
if strings.HasPrefix(line, "<Connection") {
out.WriteString(fmt.Sprintf("<Connection Url = \"%s\"\n\tUsername = \"%s\"\n\tPassword = \"%s\"\n\tAlgorithm = \"Lyra2REv3\">\n\n", args.StratumUrl, args.StratumUsername, args.StratumPassword))
skip = true
}
if !skip {
out.WriteString(fmt.Sprintf("%s\n", line))
}
}
if err := scanner.Err(); err != nil {
return err
}
return nil
}

func (l *LyclMinerImpl) ParseOutput(line string) {
line = strings.TrimSpace(line)
if strings.HasSuffix(line, "MH/s") {
startMHs := strings.LastIndex(line, ", ")
if startMHs > -1 {
line = line[startMHs+2 : len(line)-5]
f, err := strconv.ParseFloat(line, 64)
if err != nil {
logging.Errorf("Error parsing hashrate: %s\n", err.Error())
}
f = f * 1000 * 1000
l.hashRate = uint64(f)
}
}
}

func (l *LyclMinerImpl) HashRate() uint64 {
return l.hashRate
}

func (l *LyclMinerImpl) ConstructCommandlineArgs(args BinaryArguments) []string {
return []string{path.Join(util.DataDirectory(), "lyclMiner.conf")}
}
Loading

0 comments on commit 42b2170

Please sign in to comment.