fakelm: deals in SectorStatus
This commit is contained in:
parent
bbf05bcccf
commit
f8183a7122
@ -380,7 +380,7 @@ var lpBoostProxyCmd = &cli.Command{
|
|||||||
return xerrors.Errorf("getting miner info: %w", err)
|
return xerrors.Errorf("getting miner info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lp := fakelm.NewLMRPCProvider(si, maddr, abi.ActorID(mid), mi.SectorSize, pin, db, cctx.String("layers"))
|
lp := fakelm.NewLMRPCProvider(si, full, maddr, abi.ActorID(mid), mi.SectorSize, pin, db, cctx.String("layers"))
|
||||||
|
|
||||||
laddr, err := net.ResolveTCPAddr("tcp", cctx.String("listen"))
|
laddr, err := net.ResolveTCPAddr("tcp", cctx.String("listen"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -489,6 +489,11 @@ var lpBoostProxyCmd = &cli.Command{
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if r.Method != http.MethodGet {
|
||||||
|
http.Error(w, "bad method", http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Printf("%s request for piece from %s\n", pieceCid, r.RemoteAddr)
|
fmt.Printf("%s request for piece from %s\n", pieceCid, r.RemoteAddr)
|
||||||
|
|
||||||
pieceInfoLk.Lock()
|
pieceInfoLk.Lock()
|
||||||
|
@ -83,7 +83,7 @@ func connectHarmony(apiInfo string, fapi v1api.FullNode, mctx helpers.MetricsCtx
|
|||||||
return nil, xerrors.Errorf("getting miner info: %w", err)
|
return nil, xerrors.Errorf("getting miner info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
lp := fakelm.NewLMRPCProvider(si, maddr, abi.ActorID(mid), mi.SectorSize, pin, db, parts[1])
|
lp := fakelm.NewLMRPCProvider(si, fapi, maddr, abi.ActorID(mid), mi.SectorSize, pin, db, parts[1])
|
||||||
|
|
||||||
ast := api.StorageMinerStruct{}
|
ast := api.StorageMinerStruct{}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ import (
|
|||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||||
"github.com/filecoin-project/go-state-types/big"
|
"github.com/filecoin-project/go-state-types/big"
|
||||||
|
"github.com/filecoin-project/lotus/chain/types"
|
||||||
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
"github.com/filecoin-project/lotus/lib/harmony/harmonydb"
|
||||||
"github.com/filecoin-project/lotus/node/config"
|
"github.com/filecoin-project/lotus/node/config"
|
||||||
"github.com/gbrlsnchs/jwt/v3"
|
"github.com/gbrlsnchs/jwt/v3"
|
||||||
@ -26,7 +27,8 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type LMRPCProvider struct {
|
type LMRPCProvider struct {
|
||||||
si paths.SectorIndex
|
si paths.SectorIndex
|
||||||
|
full api.FullNode
|
||||||
|
|
||||||
maddr address.Address // lotus-miner RPC is single-actor
|
maddr address.Address // lotus-miner RPC is single-actor
|
||||||
minerID abi.ActorID
|
minerID abi.ActorID
|
||||||
@ -38,9 +40,10 @@ type LMRPCProvider struct {
|
|||||||
confLayer string
|
confLayer string
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewLMRPCProvider(si paths.SectorIndex, maddr address.Address, minerID abi.ActorID, ssize abi.SectorSize, pi lpmarket.Ingester, db *harmonydb.DB, confLayer string) *LMRPCProvider {
|
func NewLMRPCProvider(si paths.SectorIndex, full api.FullNode, maddr address.Address, minerID abi.ActorID, ssize abi.SectorSize, pi lpmarket.Ingester, db *harmonydb.DB, confLayer string) *LMRPCProvider {
|
||||||
return &LMRPCProvider{
|
return &LMRPCProvider{
|
||||||
si: si,
|
si: si,
|
||||||
|
full: full,
|
||||||
maddr: maddr,
|
maddr: maddr,
|
||||||
minerID: minerID,
|
minerID: minerID,
|
||||||
ssize: ssize,
|
ssize: ssize,
|
||||||
@ -65,14 +68,47 @@ func (l *LMRPCProvider) SectorsStatus(ctx context.Context, sid abi.SectorNumber,
|
|||||||
return api.SectorInfo{}, err
|
return api.SectorInfo{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var ssip []struct {
|
||||||
|
PieceCID *string `db:"piece_cid"`
|
||||||
|
DealID *int64 `db:"f05_deal_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
err = l.db.Select(ctx, &ssip, "select ssip.piece_cid, ssip.f05_deal_id from sectors_sdr_pipeline p left join sectors_sdr_initial_pieces ssip on p.sp_id = ssip.sp_id and p.sector_number = ssip.sector_number where p.sp_id = $1 and p.sector_number = $2", l.minerID, sid)
|
||||||
|
if err != nil {
|
||||||
|
return api.SectorInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
var deals []abi.DealID
|
||||||
|
if len(ssip) > 0 {
|
||||||
|
for _, d := range ssip {
|
||||||
|
if d.DealID != nil {
|
||||||
|
deals = append(deals, abi.DealID(*d.DealID))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
osi, err := l.full.StateSectorGetInfo(ctx, l.maddr, sid, types.EmptyTSK)
|
||||||
|
if err != nil {
|
||||||
|
return api.SectorInfo{}, err
|
||||||
|
}
|
||||||
|
|
||||||
|
if osi != nil {
|
||||||
|
deals = osi.DealIDs
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if len(si) == 0 {
|
if len(si) == 0 {
|
||||||
|
state := api.SectorState(sealing.UndefinedSectorState)
|
||||||
|
if len(ssip) > 0 {
|
||||||
|
state = api.SectorState(sealing.PreCommit1)
|
||||||
|
}
|
||||||
|
|
||||||
return api.SectorInfo{
|
return api.SectorInfo{
|
||||||
SectorID: sid,
|
SectorID: sid,
|
||||||
State: api.SectorState(sealing.UndefinedSectorState),
|
State: state,
|
||||||
CommD: nil,
|
CommD: nil,
|
||||||
CommR: nil,
|
CommR: nil,
|
||||||
Proof: nil,
|
Proof: nil,
|
||||||
Deals: nil,
|
Deals: deals,
|
||||||
Pieces: nil,
|
Pieces: nil,
|
||||||
Ticket: api.SealTicket{},
|
Ticket: api.SealTicket{},
|
||||||
Seed: api.SealSeed{},
|
Seed: api.SealSeed{},
|
||||||
@ -94,9 +130,9 @@ func (l *LMRPCProvider) SectorsStatus(ctx context.Context, sid abi.SectorNumber,
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var state api.SectorState = api.SectorState(sealing.Proving)
|
var state = api.SectorState(sealing.Proving)
|
||||||
if !si[0].CanStore {
|
if !si[0].CanStore {
|
||||||
state = api.SectorState(sealing.PreCommit1)
|
state = api.SectorState(sealing.PreCommit2)
|
||||||
}
|
}
|
||||||
|
|
||||||
// todo improve this with on-chain info
|
// todo improve this with on-chain info
|
||||||
@ -106,7 +142,7 @@ func (l *LMRPCProvider) SectorsStatus(ctx context.Context, sid abi.SectorNumber,
|
|||||||
CommD: nil,
|
CommD: nil,
|
||||||
CommR: nil,
|
CommR: nil,
|
||||||
Proof: nil,
|
Proof: nil,
|
||||||
Deals: nil,
|
Deals: deals,
|
||||||
Pieces: nil,
|
Pieces: nil,
|
||||||
Ticket: api.SealTicket{},
|
Ticket: api.SealTicket{},
|
||||||
Seed: api.SealSeed{},
|
Seed: api.SealSeed{},
|
||||||
|
Loading…
Reference in New Issue
Block a user