Skip to content

Commit

Permalink
remove f0 string from UI (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
LexLuthr authored Oct 23, 2024
1 parent 82c295b commit 3944336
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 18 deletions.
31 changes: 20 additions & 11 deletions web/api/webrpc/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"github.com/dustin/go-humanize"
"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
)

type MachineSummary struct {
Expand Down Expand Up @@ -172,6 +174,7 @@ type MachineInfo struct {
Posted string

PoRepSector, PoRepSectorSP *int64
PoRepSectorMiner string
}

FinishedTasks []struct {
Expand Down Expand Up @@ -286,8 +289,9 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
Task string
Posted string

PoRepSector *int64
PoRepSectorSP *int64
PoRepSector *int64
PoRepSectorSP *int64
PoRepSectorMiner string
}

var posted time.Time
Expand All @@ -300,15 +304,15 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
// try to find in the porep pipeline
rows4, err := a.deps.DB.Query(ctx, `SELECT sp_id, sector_number FROM sectors_sdr_pipeline
WHERE task_id_sdr=$1
OR task_id_tree_d=$1
OR task_id_tree_c=$1
OR task_id_tree_r=$1
OR task_id_precommit_msg=$1
OR task_id_porep=$1
OR task_id_commit_msg=$1
OR task_id_finalize=$1
OR task_id_move_storage=$1
`, t.ID)
OR task_id_tree_d=$1
OR task_id_tree_c=$1
OR task_id_tree_r=$1
OR task_id_synth=$1
OR task_id_precommit_msg=$1
OR task_id_porep=$1
OR task_id_commit_msg=$1
OR task_id_finalize=$1
OR task_id_move_storage=$1`, t.ID)
if err != nil {
return nil, err
}
Expand All @@ -321,6 +325,11 @@ func (a *WebRPC) ClusterNodeInfo(ctx context.Context, id int64) (*MachineInfo, e
}
t.PoRepSector = &sector
t.PoRepSectorSP = &spid
maddr, err := address.NewIDAddress(uint64(spid))
if err != nil {
return nil, err
}
t.PoRepSectorMiner = maddr.String()
}

rows4.Close()
Expand Down
7 changes: 7 additions & 0 deletions web/api/webrpc/deals.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ type OpenDealInfo struct {

PieceSizeStr string `db:"-"`
CreatedAtStr string `db:"-"`

Miner string
}

func (a *WebRPC) DealsPending(ctx context.Context) ([]OpenDealInfo, error) {
Expand All @@ -34,6 +36,11 @@ func (a *WebRPC) DealsPending(ctx context.Context) ([]OpenDealInfo, error) {
for i, deal := range deals {
deals[i].PieceSizeStr = types.SizeStr(types.NewInt(deal.PieceSize))
deals[i].CreatedAtStr = deal.CreatedAt.Format("2006-01-02 15:04:05")
maddr, err := address.NewIDAddress(uint64(deals[i].Actor))
if err != nil {
return nil, err
}
deals[i].Miner = maddr.String()
}

return deals, nil
Expand Down
19 changes: 19 additions & 0 deletions web/api/webrpc/storage_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import (
"github.com/samber/lo"
"github.com/snadrus/must"

"github.com/filecoin-project/go-address"

"github.com/filecoin-project/curio/lib/paths"
"github.com/filecoin-project/curio/lib/storiface"

Expand All @@ -18,6 +20,7 @@ import (
type StorageGCStats struct {
Actor int64 `db:"sp_id"`
Count int `db:"count"`
Miner string
}

func (a *WebRPC) StorageGCStats(ctx context.Context) ([]StorageGCStats, error) {
Expand All @@ -26,6 +29,15 @@ func (a *WebRPC) StorageGCStats(ctx context.Context) ([]StorageGCStats, error) {
if err != nil {
return nil, err
}

for _, s := range stats {
maddr, err := address.NewIDAddress(uint64(s.Actor))
if err != nil {
return nil, err
}
s.Miner = maddr.String()
}

return stats, nil
}

Expand Down Expand Up @@ -86,6 +98,8 @@ type StorageGCMarks struct {
// db ignored
TypeName string `db:"-"`
PathType string `db:"-"`

Miner string
}

func (a *WebRPC) StorageGCMarks(ctx context.Context) ([]StorageGCMarks, error) {
Expand Down Expand Up @@ -115,6 +129,11 @@ func (a *WebRPC) StorageGCMarks(ctx context.Context) ([]StorageGCMarks, error) {
return must.One(url.Parse(u)).Host
})
marks[i].Urls = strings.Join(us, ", ")
maddr, err := address.NewIDAddress(uint64(marks[i].Actor))
if err != nil {
return nil, err
}
marks[i].Miner = maddr.String()
}

return marks, nil
Expand Down
22 changes: 22 additions & 0 deletions web/api/webrpc/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@ package webrpc

import (
"context"
"strconv"
"time"

"github.com/samber/lo"

"github.com/filecoin-project/go-address"

"github.com/filecoin-project/curio/harmony/harmonydb"
"github.com/filecoin-project/curio/harmony/harmonytask"
)
Expand All @@ -19,6 +22,8 @@ type TaskSummary struct {

// db ignored
SincePostedStr string `db:"-"`

Miner string
}

func (a *WebRPC) ClusterTaskSummary(ctx context.Context) ([]TaskSummary, error) {
Expand All @@ -39,6 +44,23 @@ func (a *WebRPC) ClusterTaskSummary(ctx context.Context) ([]TaskSummary, error)
if v, ok := a.taskSPIDs[ts[i].Name]; ok {
ts[i].SpID = v.GetSpid(a.deps.DB, ts[i].ID)
}

if ts[i].SpID != "" {
spid, err := strconv.ParseInt(ts[i].SpID, 10, 64)
if err != nil {
return nil, err
}

if spid > 0 {
maddr, err := address.NewIDAddress(uint64(spid))
if err != nil {
return nil, err
}
ts[i].Miner = maddr.String()
} else {
ts[i].Miner = ""
}
}
}

return ts, nil
Expand Down
12 changes: 12 additions & 0 deletions web/api/webrpc/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"golang.org/x/xerrors"

"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-state-types/abi"

"github.com/filecoin-project/curio/tasks/snap"
Expand All @@ -31,6 +32,8 @@ type UpgradeSector struct {
Failed bool `db:"failed"`
FailedReason string `db:"failed_reason"`
FailedMsg string `db:"failed_reason_msg"`

Miner string
}

func (a *WebRPC) UpgradeSectors(ctx context.Context) ([]UpgradeSector, error) {
Expand All @@ -39,6 +42,15 @@ func (a *WebRPC) UpgradeSectors(ctx context.Context) ([]UpgradeSector, error) {
if err != nil {
return nil, err
}

for _, s := range sectors {
maddr, err := address.NewIDAddress(s.SpID)
if err != nil {
return nil, err
}
s.Miner = maddr.String()
}

return sectors, nil
}

Expand Down
9 changes: 9 additions & 0 deletions web/api/webrpc/win_stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"context"
"fmt"
"time"

"github.com/filecoin-project/go-address"
)

type WinStats struct {
Expand All @@ -21,6 +23,8 @@ type WinStats struct {
TaskSuccess string `db:"-"`
IncludedStr string `db:"-"`
ComputeTime string `db:"-"`

Miner string
}

func (a *WebRPC) WinStats(ctx context.Context) ([]WinStats, error) {
Expand Down Expand Up @@ -74,6 +78,11 @@ func (a *WebRPC) WinStats(ctx context.Context) ([]WinStats, error) {
if success > 0 {
marks[i].TaskSuccess += "Success"
}
maddr, err := address.NewIDAddress(uint64(marks[i].Actor))
if err != nil {
return nil, err
}
marks[i].Miner = maddr.String()
}

return marks, nil
Expand Down
2 changes: 1 addition & 1 deletion web/static/cluster-tasks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ customElements.define('cluster-tasks', class ClusterTasks extends LitElement {
.map(
(entry) => html`
<tr>
<td>${entry.SpID ? 'f0' + entry.SpID : 'n/a'}</td>
<td>${entry.SpID ? entry.Miner : 'n/a'}</td>
<td>${entry.Name}</td>
<td>${entry.ID}</td>
<td>${entry.SincePostedStr}</td>
Expand Down
2 changes: 1 addition & 1 deletion web/static/deals/pending-deals.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class PendingDeals extends LitElement {
<tbody>
${this.data.map(entry => html`
<tr>
<td>f0${entry.Actor}</td>
<td>${entry.Miner}</td>
<td>${entry.SectorNumber}</td>
<td>${entry.PieceCID}</td>
<td>${entry.PieceSizeStr}</td>
Expand Down
2 changes: 1 addition & 1 deletion web/static/gc/gc-marks.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class StorageGCStats extends LitElement {
<tbody>
${this.data.map(entry => html`
<tr>
<td>f0${entry.Actor}</td>
<td>${entry.Miner}</td>
<td>${entry.SectorNum}</td>
<td>
<div>
Expand Down
2 changes: 1 addition & 1 deletion web/static/pages/node_info/node-info.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ customElements.define('node-info',class NodeInfoElement extends LitElement {
<td>${task.ID}</td>
<td>${task.Task}</td>
<td>${task.Posted}</td>
<td>${task.PoRepSector ? html`<a href="/pages/sector/?sp=f0${task.PoRepSectorSP}&id=${task.PoRepSector}">f0${task.PoRepSectorSP}:${task.PoRepSector}</a>` : ''}</td>
<td>${task.PoRepSector ? html`<a href="/pages/sector/?sp=${task.PoRepSectorMiner}&id=${task.PoRepSector}">${task.PoRepSectorMiner}:${task.PoRepSector}</a>` : ''}</td>
</tr>
`)}
</table>
Expand Down
2 changes: 1 addition & 1 deletion web/static/snap/upgrade-sectors.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class UpgradeSectors extends LitElement {
<tbody>
${this.data.map(entry => html`
<tr>
<td>f0${entry.SpID}</td>
<td>${entry.Miner}</td>
<td>${entry.SectorNum}</td>
<td>${entry.AfterEncode ? 'Done' : entry.TaskIDEncode === null ? 'Not Started' : entry.TaskIDEncode}</td>
Expand Down
2 changes: 1 addition & 1 deletion web/static/storage-gc.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ customElements.define('storage-gc-stats',class StorageGCStats extends LitElement
<tbody>
${this.data.map(entry => html`
<tr>
<td>f0${entry.Actor}</td>
<td>${entry.Miner}</td>
<td>${entry.Count} files</td>
</tr>
`)}
Expand Down
2 changes: 1 addition & 1 deletion web/static/win-stats.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ class WinStats extends LitElement {
<tbody>
${this.data.map(entry => html`
<tr>
<td>f0${entry.Actor}</td>
<td>${entry.Miner}</td>
<td>${entry.Epoch}</td>
<td>
<span
Expand Down

0 comments on commit 3944336

Please sign in to comment.