Skip to content

Commit

Permalink
show user agent of mining software
Browse files Browse the repository at this point in the history
  • Loading branch information
bold committed Jan 9, 2019
1 parent 057dea9 commit 4fa93a3
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 1 deletion.
2 changes: 2 additions & 0 deletions pkg/modelx/modelx.go
Expand Up @@ -47,6 +47,8 @@ type Miner struct {

PayoutDetail string `db:"account.payout_detail"`

UserAgent string

// this mutex ensures that there is only one concurrent write process
// to the db for each miner
dbMu sync.Mutex
Expand Down
6 changes: 6 additions & 0 deletions pkg/pool/pool.go
Expand Up @@ -238,6 +238,12 @@ func (pool *Pool) processSubmitNonceRequest(w http.ResponseWriter, req *http.Req
return
}

if ua := req.Header.Get("User-Agent"); ua == "" {
miner.UserAgent = req.Header.Get("X-Miner")
} else {
miner.UserAgent = ua
}

// Calculate deadline and check against limit
deadlineReq := burstmath.NewCalcDeadlineRequest(accountID, nonce, ri.BaseTarget, ri.Scoop, ri.GenSig)
deadline := pool.deadlineRequestHandler.CalcDeadline(deadlineReq)
Expand Down
4 changes: 3 additions & 1 deletion pkg/webserver/webserver.go
Expand Up @@ -77,6 +77,7 @@ type MinerInfo struct {
LastActiveBlockHeight uint64
Capacity float64
Deadline uint64
UserAgent string
}

type IndexInfo struct {
Expand Down Expand Up @@ -239,7 +240,8 @@ func (webServer *WebServer) updateMinerInfos() {
NConf: len(miner.DeadlinesParams),
Capacity: capacity,
Deadline: miner.CurrentDeadline(),
LastActiveBlockHeight: miner.CurrentBlockHeight()}
LastActiveBlockHeight: miner.CurrentBlockHeight(),
UserAgent: miner.UserAgent}
miner.Unlock()
mis = append(mis, mi)

Expand Down
2 changes: 2 additions & 0 deletions web/templates/minerTable.tmpl
Expand Up @@ -8,6 +8,7 @@
<th data-sort="float"><i class="sort-toggle fa fa-sort" aria-hidden="true"></i>Historical Share</th>
<th data-sort="float" data-sort-onload="yes" data-sort-default="desc"><i class="sort-toggle fa fa-sort" aria-hidden="true"></i>Effective Capacity</th>
<th data-sort="int"><i class="sort-toggle fa fa-sort" aria-hidden="true"></i>Confirmed Deadlines (Last nAvg Rounds)</th>
<th data-sort="string"><i class="sort-toggle fa fa-sort" aria-hidden="true"></i>Miner</th>
</thead>

<tbody>
Expand All @@ -23,6 +24,7 @@
<td>{{$minerInfo.HistoricalShare | printf "%.3f" | html}} %</td>
<td>{{$minerInfo.Capacity |printf "%.4f"| html}} TB</td>
<td>{{$minerInfo.NConf | html}}</td>
<td>{{$minerInfo.UserAgent | html}}</td>
</tr>
{{end}}
</tbody>
Expand Down

0 comments on commit 4fa93a3

Please sign in to comment.