From e4044151f08d8c16c821b5b2efbd2682ee0279b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Thu, 2 Sep 2021 21:44:26 +0200 Subject: [PATCH] Show deal sizes is sealing sectors --- api/api_storage.go | 6 ++++++ cmd/lotus-miner/sectors.go | 34 +++++++++++++++++++++++++--------- storage/miner_sealing.go | 7 +++++++ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/api/api_storage.go b/api/api_storage.go index a26080617..6ebee9908 100644 --- a/api/api_storage.go +++ b/api/api_storage.go @@ -267,6 +267,11 @@ type SectorLog struct { Message string } +type SectorPiece struct { + Piece abi.PieceInfo + DealInfo *PieceDealInfo // nil for pieces which do not appear in deals (e.g. filler pieces) +} + type SectorInfo struct { SectorID abi.SectorNumber State SectorState @@ -274,6 +279,7 @@ type SectorInfo struct { CommR *cid.Cid Proof []byte Deals []abi.DealID + Pieces []SectorPiece Ticket SealTicket Seed SealSeed PreCommitMsg *cid.Cid diff --git a/cmd/lotus-miner/sectors.go b/cmd/lotus-miner/sectors.go index d09605bd9..9770edb90 100644 --- a/cmd/lotus-miner/sectors.go +++ b/cmd/lotus-miner/sectors.go @@ -394,10 +394,20 @@ var sectorsListCmd = &cli.Command{ _, inASet := activeIDs[s] dw, vp := .0, .0 - if st.Expiration-st.Activation > 0 { + estimate := st.Expiration-st.Activation <= 0 + if !estimate { rdw := big.Add(st.DealWeight, st.VerifiedDealWeight) dw = float64(big.Div(rdw, big.NewInt(int64(st.Expiration-st.Activation))).Uint64()) vp = float64(big.Div(big.Mul(st.VerifiedDealWeight, big.NewInt(9)), big.NewInt(int64(st.Expiration-st.Activation))).Uint64()) + } else { + for _, piece := range st.Pieces { + if piece.DealInfo != nil { + dw += float64(piece.Piece.Size) + if piece.DealInfo.DealProposal != nil && piece.DealInfo.DealProposal.VerifiedDeal { + vp += float64(piece.Piece.Size) * 9 + } + } + } } var deals int @@ -433,20 +443,26 @@ var sectorsListCmd = &cli.Command{ m["Expiration"] = "n/a" } else { m["Expiration"] = lcli.EpochTime(head.Height(), exp) - - if !fast && deals > 0 { - m["DealWeight"] = units.BytesSize(dw) - if vp > 0 { - m["VerifiedPower"] = color.GreenString(units.BytesSize(vp)) - } - } - if st.Early > 0 { m["RecoveryTimeout"] = color.YellowString(lcli.EpochTime(head.Height(), st.Early)) } } } + if !fast && deals > 0 { + estWrap := func(s string) string { + if !estimate { + return s + } + return fmt.Sprintf("[%s]", s) + } + + m["DealWeight"] = estWrap(units.BytesSize(dw)) + if vp > 0 { + m["VerifiedPower"] = estWrap(color.GreenString(units.BytesSize(vp))) + } + } + if cctx.Bool("events") { var events int for _, sectorLog := range st.Log { diff --git a/storage/miner_sealing.go b/storage/miner_sealing.go index 38b24e8c1..01b9546a6 100644 --- a/storage/miner_sealing.go +++ b/storage/miner_sealing.go @@ -94,10 +94,16 @@ func (m *Miner) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnC } deals := make([]abi.DealID, len(info.Pieces)) + pieces := make([]api.SectorPiece, len(info.Pieces)) for i, piece := range info.Pieces { + pieces[i].Piece = piece.Piece if piece.DealInfo == nil { continue } + + pdi := *piece.DealInfo // copy + pieces[i].DealInfo = &pdi + deals[i] = piece.DealInfo.DealID } @@ -118,6 +124,7 @@ func (m *Miner) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnC CommR: info.CommR, Proof: info.Proof, Deals: deals, + Pieces: pieces, Ticket: api.SealTicket{ Value: info.TicketValue, Epoch: info.TicketEpoch,