Skip to content

Commit

Permalink
remove unuse code
Browse files Browse the repository at this point in the history
  • Loading branch information
frankcrypto committed May 22, 2024
1 parent 1989f17 commit 9792fbd
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 155 deletions.
134 changes: 0 additions & 134 deletions cmd/miner/common/rpc.go

This file was deleted.

6 changes: 3 additions & 3 deletions cmd/miner/core/robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package core

import (
"context"
"github.com/Qitmeer/qng/cmd/miner/common"
"strings"
"sync"

"github.com/Qitmeer/qng/cmd/miner/common"
)

//var devicesTypesForMining = cl.DeviceTypeAll
Expand All @@ -30,13 +31,12 @@ type MinerRobot struct {
Quit context.Context
Work *Work
ClDevices []string
Rpc *common.RpcClient
Pool bool
SubmitStr chan string
UseDevices []string
}

//init GPU device
// init GPU device
func (this *MinerRobot) InitDevice() {
this.UseDevices = []string{}
if this.Cfg.OptionConfig.UseDevices != "" {
Expand Down
6 changes: 3 additions & 3 deletions cmd/miner/core/work.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ package core

import (
"context"
"sync"

"github.com/Qitmeer/qng/cmd/miner/common"
"github.com/Qitmeer/qng/core/types"
"sync"
)

const SYMBOL_PMEER = "MEER"
Expand All @@ -19,10 +20,9 @@ type BaseWork interface {
PoolSubmit(subm string) error
}

//standard work template
// standard work template
type Work struct {
Cfg *common.GlobalConfig
Rpc *common.RpcClient
Clean bool
sync.Mutex
Quit context.Context
Expand Down
12 changes: 6 additions & 6 deletions cmd/miner/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,21 @@ package main

import (
"context"
"github.com/Qitmeer/qng/cmd/miner/common"
"github.com/Qitmeer/qng/cmd/miner/core"
qitmeer "github.com/Qitmeer/qng/cmd/miner/symbols/lib"
"log"
"os"
"os/signal"
"runtime"
"strings"
"time"

"github.com/Qitmeer/qng/cmd/miner/common"
"github.com/Qitmeer/qng/cmd/miner/core"
qitmeer "github.com/Qitmeer/qng/cmd/miner/symbols/lib"
)

var robotminer core.Robot

//init the config file
// init the config file
func init() {
cfg, _, err := common.LoadConfig()
if err != nil {
Expand Down Expand Up @@ -50,15 +51,14 @@ func main() {
common.MinerLoger.Info("All services exited")
}

//get current coin miner
// get current coin miner
func GetRobot(cfg *common.GlobalConfig) core.Robot {
switch strings.ToUpper(cfg.NecessaryConfig.Symbol) {
case core.SYMBOL_PMEER:
r := &qitmeer.QitmeerRobot{}
r.Cfg = cfg
r.NeedGBT = make(chan struct{}, 1)
r.Started = uint32(time.Now().Unix())
r.Rpc = &common.RpcClient{Cfg: cfg}
r.SubmitStr = make(chan string)
r.PendingBlocks = map[string]qitmeer.PendingBlock{}
return r
Expand Down
1 change: 0 additions & 1 deletion cmd/miner/symbols/lib/robot.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ func (this *QitmeerRobot) Run(ctx context.Context) {
common.MinerLoger.Info(fmt.Sprintf("[%s miner] start", connectName))
this.Work = QitmeerWork{}
this.Work.Cfg = this.Cfg
this.Work.Rpc = this.Rpc
this.Work.stra = this.Stratu
this.Work.Quit = this.Quit
this.Work.WorkLock = sync.Mutex{}
Expand Down
18 changes: 10 additions & 8 deletions cmd/miner/symbols/lib/work.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ type QitmeerWork struct {
WorkLock sync.Mutex
WsClient *client.Client
LastSubmit time.Time
GbtID int64
SubmitID int64
}

func (this *QitmeerWork) GetPowType() pow.PowType {
Expand Down Expand Up @@ -83,14 +85,14 @@ func (this *QitmeerWork) Get() bool {

// BuildBlock
func (this *QitmeerWork) BuildBlock(header *types.BlockHeader) bool {
this.Rpc.GbtID++
this.GbtID++
this.Block = &BlockHeader{}
this.Block.ParentRoot = header.ParentRoot
this.Block.WorkData = header.BlockData()
this.Block.Target = fmt.Sprintf("%064x", pow.CompactToBig(header.Difficulty))
this.Block.GBTID = this.Rpc.GbtID
common.LatestGBTID = this.Rpc.GbtID
common.MinerLoger.Debug(fmt.Sprintf("getRemoteBlockTemplate , target :%s , GBTID:%d", this.Block.Target, this.Rpc.GbtID))
this.Block.GBTID = this.GbtID
common.LatestGBTID = this.GbtID
common.MinerLoger.Debug(fmt.Sprintf("getRemoteBlockTemplate , target :%s , GBTID:%d", this.Block.Target, this.GbtID))
this.GetWorkTime = time.Now().Unix()
return true
}
Expand All @@ -100,13 +102,13 @@ func (this *QitmeerWork) Submit(header *types.BlockHeader, gbtID string) (string
this.Lock()
defer this.Unlock()
gbtIDInt64, _ := strconv.ParseInt(gbtID, 10, 64)
if this.Rpc.GbtID != gbtIDInt64 {
common.MinerLoger.Debug(fmt.Sprintf("gbt old , target :%d , current:%d", this.Rpc.GbtID, gbtIDInt64))
if this.GbtID != gbtIDInt64 {
common.MinerLoger.Debug(fmt.Sprintf("gbt old , target :%d , current:%d", this.GbtID, gbtIDInt64))
return "", 0, ErrSameWork
}
this.Rpc.SubmitID++
this.SubmitID++

id := fmt.Sprintf("miner_submit_gbtID:%s_id:%d", gbtID, this.Rpc.SubmitID)
id := fmt.Sprintf("miner_submit_gbtID:%s_id:%d", gbtID, this.SubmitID)
res, err := this.WsClient.SubmitBlockHeader(header)
if err != nil {
common.MinerLoger.Error("[submit error] " + id + " " + err.Error())
Expand Down

0 comments on commit 9792fbd

Please sign in to comment.