unit test and code comments

This commit is contained in:
Andrew Jackson (Ajax) 2023-11-15 10:04:04 -06:00
parent f80a5bcebf
commit ac2306beef
4 changed files with 20 additions and 15 deletions

View File

@ -69,7 +69,6 @@ It will not send any messages to the chain. Since it can compute any deadline, o
if err != nil {
return err
}
defer deps.fullCloser()
wdPostTask, wdPoStSubmitTask, derlareRecoverTask, err := provider.WindowPostScheduler(ctx, deps.cfg.Fees, deps.cfg.Proving, deps.full, deps.verif, deps.lw,
deps.as, deps.maddrs, deps.db, deps.stor, deps.si, deps.cfg.Subsystems.WindowPostMaxTasks)

View File

@ -23,7 +23,6 @@ import (
"golang.org/x/xerrors"
"github.com/filecoin-project/go-address"
"github.com/filecoin-project/go-jsonrpc"
"github.com/filecoin-project/go-jsonrpc/auth"
"github.com/filecoin-project/go-statestore"
@ -116,6 +115,12 @@ var runCmd = &cli.Command{
tag.Insert(metrics.Commit, build.CurrentCommit),
tag.Insert(metrics.NodeType, "provider"),
)
shutdownChan := make(chan struct{})
ctx, ctxclose := context.WithCancel(ctx)
go func() {
<-shutdownChan
ctxclose()
}()
// Register all metric views
/*
if err := view.Register(
@ -133,14 +138,12 @@ var runCmd = &cli.Command{
}
}
shutdownChan := make(chan struct{})
deps, err := getDeps(ctx, cctx)
if err != nil {
return err
}
cfg, db, full, verif, lw, as, maddrs, stor, si, localStore := deps.cfg, deps.db, deps.full, deps.verif, deps.lw, deps.as, deps.maddrs, deps.stor, deps.si, deps.localStore
defer deps.fullCloser()
///////////////////////////////////////////////////////////////////////
///// Task Selection
@ -206,7 +209,6 @@ var runCmd = &cli.Command{
//node.ShutdownHandler{Component: "provider", StopFunc: stop},
<-finishCh
return nil
},
}
@ -256,7 +258,6 @@ type Deps struct {
cfg *config.LotusProviderConfig
db *harmonydb.DB
full api.FullNode
fullCloser jsonrpc.ClientCloser
verif storiface.Verifier
lw *sealer.LocalWorker
as *ctladdr.AddressSelector
@ -319,14 +320,19 @@ func getDeps(ctx context.Context, cctx *cli.Context) (*Deps, error) {
if err != nil {
return nil, err
}
defer func() { _ = j.Close() }()
full, fullCloser, err := cliutil.GetFullNodeAPIV1LotusProvider(cctx, cfg.Apis.ChainApiInfo)
if err != nil {
return nil, err
}
defer fullCloser()
go func() {
select {
case <-ctx.Done():
fullCloser()
_ = j.Close()
}
}()
sa, err := StorageAuth(cfg.Apis.StorageRPCSecret)
if err != nil {
return nil, xerrors.Errorf(`'%w' while parsing the config toml's
@ -380,7 +386,6 @@ Get it with: jq .PrivateKey ~/.lotus-miner/keystore/MF2XI2BNNJ3XILLQOJUXMYLUMU`,
cfg,
db,
full,
fullCloser,
verif,
lw,
as,

View File

@ -3,6 +3,7 @@ package resources
import (
"bytes"
"context"
"fmt"
"os/exec"
"regexp"
"runtime"
@ -94,8 +95,8 @@ func Register(db *harmonydb.DB, hostnameAndPort string) (*Reg, error) {
func CleanupMachines(ctx context.Context, db *harmonydb.DB) int {
ct, err := db.Exec(ctx,
`DELETE FROM harmony_machines WHERE last_contact < CURRENT_TIMESTAMP - INTERVAL $1 MILLISECONDS`,
LOOKS_DEAD_TIMEOUT.Milliseconds()) // ms enables unit testing to change timeout.
`DELETE FROM harmony_machines WHERE last_contact < CURRENT_TIMESTAMP - INTERVAL $1 `,
fmt.Sprintf("%d MILLISECOND", LOOKS_DEAD_TIMEOUT.Milliseconds())) // ms enables unit testing to change timeout.
if err != nil {
logger.Warn("unable to delete old machines: ", err)
}

View File

@ -74,10 +74,10 @@ type WdPostTask struct {
}
type wdTaskIdentity struct {
SpID uint64
ProvingPeriodStart abi.ChainEpoch
DeadlineIndex uint64
PartitionIndex uint64
SpID uint64 `db:"sp_id"`
ProvingPeriodStart abi.ChainEpoch `db:"proving_period_start"`
DeadlineIndex uint64 `db:"deadline_index"`
PartitionIndex uint64 `db:"partition_index"`
}
func NewWdPostTask(db *harmonydb.DB,