Merge remote-tracking branch 'origin/master' into feat/stateless-offline-dealflow
This commit is contained in:
+7
-7
@@ -8,7 +8,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-jsonrpc/auth"
|
||||
|
||||
"github.com/filecoin-project/lotus/api/apistruct"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
cliutil "github.com/filecoin-project/lotus/cli/util"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
@@ -47,18 +47,18 @@ var AuthCreateAdminToken = &cli.Command{
|
||||
|
||||
perm := cctx.String("perm")
|
||||
idx := 0
|
||||
for i, p := range apistruct.AllPermissions {
|
||||
for i, p := range api.AllPermissions {
|
||||
if auth.Permission(perm) == p {
|
||||
idx = i + 1
|
||||
}
|
||||
}
|
||||
|
||||
if idx == 0 {
|
||||
return fmt.Errorf("--perm flag has to be one of: %s", apistruct.AllPermissions)
|
||||
return fmt.Errorf("--perm flag has to be one of: %s", api.AllPermissions)
|
||||
}
|
||||
|
||||
// slice on [:idx] so for example: 'sign' gives you [read, write, sign]
|
||||
token, err := napi.AuthNew(ctx, apistruct.AllPermissions[:idx])
|
||||
token, err := napi.AuthNew(ctx, api.AllPermissions[:idx])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -95,18 +95,18 @@ var AuthApiInfoToken = &cli.Command{
|
||||
|
||||
perm := cctx.String("perm")
|
||||
idx := 0
|
||||
for i, p := range apistruct.AllPermissions {
|
||||
for i, p := range api.AllPermissions {
|
||||
if auth.Permission(perm) == p {
|
||||
idx = i + 1
|
||||
}
|
||||
}
|
||||
|
||||
if idx == 0 {
|
||||
return fmt.Errorf("--perm flag has to be one of: %s", apistruct.AllPermissions)
|
||||
return fmt.Errorf("--perm flag has to be one of: %s", api.AllPermissions)
|
||||
}
|
||||
|
||||
// slice on [:idx] so for example: 'sign' gives you [read, write, sign]
|
||||
token, err := napi.AuthNew(ctx, apistruct.AllPermissions[:idx])
|
||||
token, err := napi.AuthNew(ctx, api.AllPermissions[:idx])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
+5
-10
@@ -32,6 +32,7 @@ import (
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
@@ -722,12 +723,6 @@ var ChainGetCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if ts == nil {
|
||||
ts, err = api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
p = "/ipfs/" + ts.ParentState().String() + p
|
||||
if cctx.Bool("verbose") {
|
||||
fmt.Println(p)
|
||||
@@ -806,7 +801,7 @@ var ChainGetCmd = &cli.Command{
|
||||
|
||||
type apiIpldStore struct {
|
||||
ctx context.Context
|
||||
api lapi.FullNode
|
||||
api v0api.FullNode
|
||||
}
|
||||
|
||||
func (ht *apiIpldStore) Context() context.Context {
|
||||
@@ -834,7 +829,7 @@ func (ht *apiIpldStore) Put(ctx context.Context, v interface{}) (cid.Cid, error)
|
||||
panic("No mutations allowed")
|
||||
}
|
||||
|
||||
func handleAmt(ctx context.Context, api lapi.FullNode, r cid.Cid) error {
|
||||
func handleAmt(ctx context.Context, api v0api.FullNode, r cid.Cid) error {
|
||||
s := &apiIpldStore{ctx, api}
|
||||
mp, err := adt.AsArray(s, r)
|
||||
if err != nil {
|
||||
@@ -847,7 +842,7 @@ func handleAmt(ctx context.Context, api lapi.FullNode, r cid.Cid) error {
|
||||
})
|
||||
}
|
||||
|
||||
func handleHamtEpoch(ctx context.Context, api lapi.FullNode, r cid.Cid) error {
|
||||
func handleHamtEpoch(ctx context.Context, api v0api.FullNode, r cid.Cid) error {
|
||||
s := &apiIpldStore{ctx, api}
|
||||
mp, err := adt.AsMap(s, r)
|
||||
if err != nil {
|
||||
@@ -865,7 +860,7 @@ func handleHamtEpoch(ctx context.Context, api lapi.FullNode, r cid.Cid) error {
|
||||
})
|
||||
}
|
||||
|
||||
func handleHamtAddress(ctx context.Context, api lapi.FullNode, r cid.Cid) error {
|
||||
func handleHamtAddress(ctx context.Context, api v0api.FullNode, r cid.Cid) error {
|
||||
s := &apiIpldStore{ctx, api}
|
||||
mp, err := adt.AsMap(s, r)
|
||||
if err != nil {
|
||||
|
||||
+20
-10
@@ -40,6 +40,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
lapi "github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin/market"
|
||||
@@ -301,8 +302,16 @@ var clientLocalCmd = &cli.Command{
|
||||
}
|
||||
|
||||
var clientDealCmd = &cli.Command{
|
||||
Name: "deal",
|
||||
Usage: "Initialize storage deal with a miner",
|
||||
Name: "deal",
|
||||
Usage: "Initialize storage deal with a miner",
|
||||
Description: `Make a deal with a miner.
|
||||
dataCid comes from running 'lotus client import'.
|
||||
miner is the address of the miner you wish to make a deal with.
|
||||
price is measured in FIL/GB/Epoch. Miners usually don't accept a bid
|
||||
lower than their advertised ask. You can check a miners listed price
|
||||
with 'lotus client query-ask <miner address>'.
|
||||
duration is how long the miner should store the data for, in blocks.
|
||||
The minimum value is 518400 (6 months).`,
|
||||
ArgsUsage: "[dataCid miner price duration]",
|
||||
Flags: []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
@@ -1302,7 +1311,8 @@ var clientListAsksCmd = &cli.Command{
|
||||
Usage: "List asks for top miners",
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "by-ping",
|
||||
Name: "by-ping",
|
||||
Usage: "sort by ping",
|
||||
},
|
||||
&cli.StringFlag{
|
||||
Name: "output-format",
|
||||
@@ -1355,7 +1365,7 @@ type QueriedAsk struct {
|
||||
Ping time.Duration
|
||||
}
|
||||
|
||||
func GetAsks(ctx context.Context, api lapi.FullNode) ([]QueriedAsk, error) {
|
||||
func GetAsks(ctx context.Context, api v0api.FullNode) ([]QueriedAsk, error) {
|
||||
isTTY := true
|
||||
if fileInfo, _ := os.Stdout.Stat(); (fileInfo.Mode() & os.ModeCharDevice) == 0 {
|
||||
isTTY = false
|
||||
@@ -1457,17 +1467,17 @@ loop:
|
||||
}
|
||||
|
||||
rt := time.Now()
|
||||
|
||||
_, err = api.ClientQueryAsk(ctx, *mi.PeerId, miner)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
pingDuration := time.Now().Sub(rt)
|
||||
|
||||
atomic.AddInt64(&got, 1)
|
||||
lk.Lock()
|
||||
asks = append(asks, QueriedAsk{
|
||||
Ask: ask,
|
||||
Ping: time.Now().Sub(rt),
|
||||
Ping: pingDuration,
|
||||
})
|
||||
lk.Unlock()
|
||||
}(miner)
|
||||
@@ -1662,7 +1672,7 @@ var clientListDeals = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func dealFromDealInfo(ctx context.Context, full api.FullNode, head *types.TipSet, v api.DealInfo) deal {
|
||||
func dealFromDealInfo(ctx context.Context, full v0api.FullNode, head *types.TipSet, v api.DealInfo) deal {
|
||||
if v.DealID == 0 {
|
||||
return deal{
|
||||
LocalDeal: v,
|
||||
@@ -1681,7 +1691,7 @@ func dealFromDealInfo(ctx context.Context, full api.FullNode, head *types.TipSet
|
||||
}
|
||||
}
|
||||
|
||||
func outputStorageDeals(ctx context.Context, out io.Writer, full lapi.FullNode, localDeals []lapi.DealInfo, verbose bool, color bool, showFailed bool) error {
|
||||
func outputStorageDeals(ctx context.Context, out io.Writer, full v0api.FullNode, localDeals []lapi.DealInfo, verbose bool, color bool, showFailed bool) error {
|
||||
sort.Slice(localDeals, func(i, j int) bool {
|
||||
return localDeals[i].CreationTime.Before(localDeals[j].CreationTime)
|
||||
})
|
||||
@@ -2300,7 +2310,7 @@ func ellipsis(s string, length int) string {
|
||||
return s
|
||||
}
|
||||
|
||||
func inspectDealCmd(ctx context.Context, api lapi.FullNode, proposalCid string, dealId int) error {
|
||||
func inspectDealCmd(ctx context.Context, api v0api.FullNode, proposalCid string, dealId int) error {
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
defer cancel()
|
||||
|
||||
@@ -2353,7 +2363,7 @@ func renderDeal(di *lapi.DealInfo) {
|
||||
}
|
||||
|
||||
for _, stg := range di.DealStages.Stages {
|
||||
msg := fmt.Sprintf("%s %s: %s (%s)", color.BlueString("Stage:"), color.BlueString(strings.TrimPrefix(stg.Name, "StorageDeal")), stg.Description, color.GreenString(stg.ExpectedDuration))
|
||||
msg := fmt.Sprintf("%s %s: %s (expected duration: %s)", color.BlueString("Stage:"), color.BlueString(strings.TrimPrefix(stg.Name, "StorageDeal")), stg.Description, color.GreenString(stg.ExpectedDuration))
|
||||
if stg.UpdatedTime.Time().IsZero() {
|
||||
msg = color.YellowString(msg)
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ var DaemonContext = cliutil.DaemonContext
|
||||
var ReqContext = cliutil.ReqContext
|
||||
|
||||
var GetFullNodeAPI = cliutil.GetFullNodeAPI
|
||||
var GetFullNodeAPIV1 = cliutil.GetFullNodeAPIV1
|
||||
var GetGatewayAPI = cliutil.GetGatewayAPI
|
||||
|
||||
var GetStorageMinerAPI = cliutil.GetStorageMinerAPI
|
||||
|
||||
+4
-3
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
logging "github.com/ipfs/go-log/v2"
|
||||
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/chain/store"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
@@ -356,7 +357,7 @@ var disputerStartCmd = &cli.Command{
|
||||
|
||||
// for a given miner, index, and maxPostIndex, tries to dispute posts from 0...postsSnapshotted-1
|
||||
// returns a list of DisputeWindowedPoSt msgs that are expected to succeed if sent
|
||||
func makeDisputeWindowedPosts(ctx context.Context, api lapi.FullNode, dl minerDeadline, postsSnapshotted uint64, sender address.Address) ([]*types.Message, error) {
|
||||
func makeDisputeWindowedPosts(ctx context.Context, api v0api.FullNode, dl minerDeadline, postsSnapshotted uint64, sender address.Address) ([]*types.Message, error) {
|
||||
disputes := make([]*types.Message, 0)
|
||||
|
||||
for i := uint64(0); i < postsSnapshotted; i++ {
|
||||
@@ -388,7 +389,7 @@ func makeDisputeWindowedPosts(ctx context.Context, api lapi.FullNode, dl minerDe
|
||||
return disputes, nil
|
||||
}
|
||||
|
||||
func makeMinerDeadline(ctx context.Context, api lapi.FullNode, mAddr address.Address) (abi.ChainEpoch, *minerDeadline, error) {
|
||||
func makeMinerDeadline(ctx context.Context, api v0api.FullNode, mAddr address.Address) (abi.ChainEpoch, *minerDeadline, error) {
|
||||
dl, err := api.StateMinerProvingDeadline(ctx, mAddr, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return -1, nil, xerrors.Errorf("getting proving index list: %w", err)
|
||||
@@ -400,7 +401,7 @@ func makeMinerDeadline(ctx context.Context, api lapi.FullNode, mAddr address.Add
|
||||
}, nil
|
||||
}
|
||||
|
||||
func getSender(ctx context.Context, api lapi.FullNode, fromStr string) (address.Address, error) {
|
||||
func getSender(ctx context.Context, api v0api.FullNode, fromStr string) (address.Address, error) {
|
||||
if fromStr == "" {
|
||||
return api.WalletDefaultAddress(ctx)
|
||||
}
|
||||
|
||||
+5
-2
@@ -132,9 +132,11 @@ var MpoolPending = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
// Deprecated: MpoolClear is now available at `lotus-shed mpool clear`
|
||||
var MpoolClear = &cli.Command{
|
||||
Name: "clear",
|
||||
Usage: "Clear all pending messages from the mpool (USE WITH CARE)",
|
||||
Name: "clear",
|
||||
Usage: "Clear all pending messages from the mpool (USE WITH CARE) (DEPRECATED)",
|
||||
Hidden: true,
|
||||
Flags: []cli.Flag{
|
||||
&cli.BoolFlag{
|
||||
Name: "local",
|
||||
@@ -146,6 +148,7 @@ var MpoolClear = &cli.Command{
|
||||
},
|
||||
},
|
||||
Action: func(cctx *cli.Context) error {
|
||||
fmt.Println("DEPRECATED: This behavior is being moved to `lotus-shed mpool clear`")
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import (
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-jsonrpc"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/chain/stmgr"
|
||||
types "github.com/filecoin-project/lotus/chain/types"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
@@ -35,7 +35,7 @@ type ServicesAPI interface {
|
||||
}
|
||||
|
||||
type ServicesImpl struct {
|
||||
api api.FullNode
|
||||
api v0api.FullNode
|
||||
closer jsonrpc.ClientCloser
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/filecoin-project/go-state-types/big"
|
||||
"github.com/filecoin-project/go-state-types/crypto"
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/mocks"
|
||||
mocks "github.com/filecoin-project/lotus/api/v0api/v0mocks"
|
||||
types "github.com/filecoin-project/lotus/chain/types"
|
||||
gomock "github.com/golang/mock/gomock"
|
||||
cid "github.com/ipfs/go-cid"
|
||||
|
||||
+67
-40
@@ -15,6 +15,8 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
|
||||
"github.com/fatih/color"
|
||||
"github.com/filecoin-project/lotus/chain/actors/builtin"
|
||||
|
||||
@@ -73,6 +75,50 @@ var StateCmd = &cli.Command{
|
||||
StateMarketCmd,
|
||||
StateExecTraceCmd,
|
||||
StateNtwkVersionCmd,
|
||||
StateMinerProvingDeadlineCmd,
|
||||
},
|
||||
}
|
||||
|
||||
var StateMinerProvingDeadlineCmd = &cli.Command{
|
||||
Name: "miner-proving-deadline",
|
||||
Usage: "Retrieve information about a given miner's proving deadline",
|
||||
ArgsUsage: "[minerAddress]",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer closer()
|
||||
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
if !cctx.Args().Present() {
|
||||
return fmt.Errorf("must specify miner to get information for")
|
||||
}
|
||||
|
||||
addr, err := address.NewFromString(cctx.Args().First())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
cd, err := api.StateMinerProvingDeadline(ctx, addr, ts.Key())
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting miner info: %w", err)
|
||||
}
|
||||
|
||||
fmt.Printf("Period Start:\t%s\n", cd.PeriodStart)
|
||||
fmt.Printf("Index:\t\t%d\n", cd.Index)
|
||||
fmt.Printf("Open:\t\t%s\n", cd.Open)
|
||||
fmt.Printf("Close:\t\t%s\n", cd.Close)
|
||||
fmt.Printf("Challenge:\t%s\n", cd.Challenge)
|
||||
fmt.Printf("FaultCutoff:\t%s\n", cd.FaultCutoff)
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
||||
@@ -178,16 +224,19 @@ func ParseTipSetString(ts string) ([]cid.Cid, error) {
|
||||
return cids, nil
|
||||
}
|
||||
|
||||
func LoadTipSet(ctx context.Context, cctx *cli.Context, api api.FullNode) (*types.TipSet, error) {
|
||||
// LoadTipSet gets the tipset from the context, or the head from the API.
|
||||
//
|
||||
// It always gets the head from the API so commands use a consistent tipset even if time pases.
|
||||
func LoadTipSet(ctx context.Context, cctx *cli.Context, api v0api.FullNode) (*types.TipSet, error) {
|
||||
tss := cctx.String("tipset")
|
||||
if tss == "" {
|
||||
return nil, nil
|
||||
return api.ChainHead(ctx)
|
||||
}
|
||||
|
||||
return ParseTipSetRef(ctx, api, tss)
|
||||
}
|
||||
|
||||
func ParseTipSetRef(ctx context.Context, api api.FullNode, tss string) (*types.TipSet, error) {
|
||||
func ParseTipSetRef(ctx context.Context, api v0api.FullNode, tss string) (*types.TipSet, error) {
|
||||
if tss[0] == '@' {
|
||||
if tss == "@head" {
|
||||
return api.ChainHead(ctx)
|
||||
@@ -574,7 +623,7 @@ var StateListMinersCmd = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func getDealsCounts(ctx context.Context, lapi api.FullNode) (map[address.Address]int, error) {
|
||||
func getDealsCounts(ctx context.Context, lapi v0api.FullNode) (map[address.Address]int, error) {
|
||||
allDeals, err := lapi.StateMarketDeals(ctx, types.EmptyTSK)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -848,14 +897,6 @@ var StateListMessagesCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if ts == nil {
|
||||
head, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ts = head
|
||||
}
|
||||
|
||||
windowSize := abi.ChainEpoch(100)
|
||||
|
||||
cur := ts
|
||||
@@ -955,13 +996,6 @@ var StateComputeStateCmd = &cli.Command{
|
||||
}
|
||||
|
||||
h := abi.ChainEpoch(cctx.Uint64("vm-height"))
|
||||
if ts == nil {
|
||||
head, err := api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ts = head
|
||||
}
|
||||
if h == 0 {
|
||||
h = ts.Height()
|
||||
}
|
||||
@@ -1443,7 +1477,7 @@ var StateSearchMsgCmd = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message, r types.MessageReceipt) error {
|
||||
func printReceiptReturn(ctx context.Context, api v0api.FullNode, m *types.Message, r types.MessageReceipt) error {
|
||||
if len(r.Return) == 0 {
|
||||
return nil
|
||||
}
|
||||
@@ -1463,20 +1497,20 @@ func printReceiptReturn(ctx context.Context, api api.FullNode, m *types.Message,
|
||||
return nil
|
||||
}
|
||||
|
||||
func printMsg(ctx context.Context, api api.FullNode, msg cid.Cid, mw *lapi.MsgLookup, m *types.Message) error {
|
||||
if mw != nil {
|
||||
if mw.Message != msg {
|
||||
fmt.Printf("Message was replaced: %s\n", mw.Message)
|
||||
}
|
||||
|
||||
fmt.Printf("Executed in tipset: %s\n", mw.TipSet.Cids())
|
||||
fmt.Printf("Exit Code: %d\n", mw.Receipt.ExitCode)
|
||||
fmt.Printf("Gas Used: %d\n", mw.Receipt.GasUsed)
|
||||
fmt.Printf("Return: %x\n", mw.Receipt.Return)
|
||||
} else {
|
||||
func printMsg(ctx context.Context, api v0api.FullNode, msg cid.Cid, mw *lapi.MsgLookup, m *types.Message) error {
|
||||
if mw == nil {
|
||||
fmt.Println("message was not found on chain")
|
||||
return nil
|
||||
}
|
||||
|
||||
if mw.Message != msg {
|
||||
fmt.Printf("Message was replaced: %s\n", mw.Message)
|
||||
}
|
||||
|
||||
fmt.Printf("Executed in tipset: %s\n", mw.TipSet.Cids())
|
||||
fmt.Printf("Exit Code: %d\n", mw.Receipt.ExitCode)
|
||||
fmt.Printf("Gas Used: %d\n", mw.Receipt.GasUsed)
|
||||
fmt.Printf("Return: %x\n", mw.Receipt.Return)
|
||||
if err := printReceiptReturn(ctx, api, m, mw.Receipt); err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -1744,7 +1778,7 @@ var StateCircSupplyCmd = &cli.Command{
|
||||
var StateSectorCmd = &cli.Command{
|
||||
Name: "sector",
|
||||
Usage: "Get miner sector info",
|
||||
ArgsUsage: "[miner address] [sector number]",
|
||||
ArgsUsage: "[minerAddress] [sectorNumber]",
|
||||
Action: func(cctx *cli.Context) error {
|
||||
api, closer, err := GetFullNodeAPI(cctx)
|
||||
if err != nil {
|
||||
@@ -1755,7 +1789,7 @@ var StateSectorCmd = &cli.Command{
|
||||
ctx := ReqContext(cctx)
|
||||
|
||||
if cctx.Args().Len() != 2 {
|
||||
return xerrors.Errorf("expected 2 params")
|
||||
return xerrors.Errorf("expected 2 params: minerAddress and sectorNumber")
|
||||
}
|
||||
|
||||
ts, err := LoadTipSet(ctx, cctx, api)
|
||||
@@ -1763,13 +1797,6 @@ var StateSectorCmd = &cli.Command{
|
||||
return err
|
||||
}
|
||||
|
||||
if ts == nil {
|
||||
ts, err = api.ChainHead(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
maddr, err := address.NewFromString(cctx.Args().Get(0))
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
+2
-1
@@ -12,6 +12,7 @@ import (
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
)
|
||||
|
||||
@@ -240,7 +241,7 @@ var SyncCheckpointCmd = &cli.Command{
|
||||
},
|
||||
}
|
||||
|
||||
func SyncWait(ctx context.Context, napi api.FullNode, watch bool) error {
|
||||
func SyncWait(ctx context.Context, napi v0api.FullNode, watch bool) error {
|
||||
tick := time.Second / 4
|
||||
|
||||
lastLines := 0
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/build"
|
||||
"github.com/filecoin-project/lotus/chain/types"
|
||||
)
|
||||
|
||||
func parseTipSet(ctx context.Context, api api.FullNode, vals []string) (*types.TipSet, error) {
|
||||
func parseTipSet(ctx context.Context, api v0api.FullNode, vals []string) (*types.TipSet, error) {
|
||||
var headers []*types.BlockHeader
|
||||
for _, c := range vals {
|
||||
blkc, err := cid.Decode(c)
|
||||
|
||||
+38
-14
@@ -18,6 +18,8 @@ import (
|
||||
|
||||
"github.com/filecoin-project/lotus/api"
|
||||
"github.com/filecoin-project/lotus/api/client"
|
||||
"github.com/filecoin-project/lotus/api/v0api"
|
||||
"github.com/filecoin-project/lotus/api/v1api"
|
||||
"github.com/filecoin-project/lotus/node/repo"
|
||||
)
|
||||
|
||||
@@ -133,13 +135,13 @@ func GetAPIInfo(ctx *cli.Context, t repo.RepoType) (APIInfo, error) {
|
||||
}, nil
|
||||
}
|
||||
|
||||
func GetRawAPI(ctx *cli.Context, t repo.RepoType) (string, http.Header, error) {
|
||||
func GetRawAPI(ctx *cli.Context, t repo.RepoType, version string) (string, http.Header, error) {
|
||||
ainfo, err := GetAPIInfo(ctx, t)
|
||||
if err != nil {
|
||||
return "", nil, xerrors.Errorf("could not get API info: %w", err)
|
||||
}
|
||||
|
||||
addr, err := ainfo.DialArgs()
|
||||
addr, err := ainfo.DialArgs(version)
|
||||
if err != nil {
|
||||
return "", nil, xerrors.Errorf("could not get DialArgs: %w", err)
|
||||
}
|
||||
@@ -165,25 +167,38 @@ func GetAPI(ctx *cli.Context) (api.Common, jsonrpc.ClientCloser, error) {
|
||||
return tn.(api.FullNode), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, t)
|
||||
addr, headers, err := GetRawAPI(ctx, t, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewCommonRPC(ctx.Context, addr, headers)
|
||||
return client.NewCommonRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetFullNodeAPI(ctx *cli.Context) (api.FullNode, jsonrpc.ClientCloser, error) {
|
||||
func GetFullNodeAPI(ctx *cli.Context) (v0api.FullNode, jsonrpc.ClientCloser, error) {
|
||||
if tn, ok := ctx.App.Metadata["testnode-full"]; ok {
|
||||
return tn.(api.FullNode), func() {}, nil
|
||||
return &v0api.WrapperV1Full{FullNode: tn.(v1api.FullNode)}, func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode)
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewFullNodeRPC(ctx.Context, addr, headers)
|
||||
return client.NewFullNodeRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetFullNodeAPIV1(ctx *cli.Context) (v1api.FullNode, jsonrpc.ClientCloser, error) {
|
||||
if tn, ok := ctx.App.Metadata["testnode-full"]; ok {
|
||||
return tn.(v1api.FullNode), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewFullNodeRPCV1(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
type GetStorageMinerOptions struct {
|
||||
@@ -206,7 +221,7 @@ func GetStorageMinerAPI(ctx *cli.Context, opts ...GetStorageMinerOption) (api.St
|
||||
return tn.(api.StorageMiner), func() {}, nil
|
||||
}
|
||||
|
||||
addr, headers, err := GetRawAPI(ctx, repo.StorageMiner)
|
||||
addr, headers, err := GetRawAPI(ctx, repo.StorageMiner, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -227,25 +242,34 @@ func GetStorageMinerAPI(ctx *cli.Context, opts ...GetStorageMinerOption) (api.St
|
||||
addr = u.String()
|
||||
}
|
||||
|
||||
return client.NewStorageMinerRPC(ctx.Context, addr, headers)
|
||||
return client.NewStorageMinerRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetWorkerAPI(ctx *cli.Context) (api.Worker, jsonrpc.ClientCloser, error) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.Worker)
|
||||
addr, headers, err := GetRawAPI(ctx, repo.Worker, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewWorkerRPC(ctx.Context, addr, headers)
|
||||
return client.NewWorkerRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetGatewayAPI(ctx *cli.Context) (api.Gateway, jsonrpc.ClientCloser, error) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode)
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v1")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewGatewayRPC(ctx.Context, addr, headers)
|
||||
return client.NewGatewayRPCV1(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func GetGatewayAPIV0(ctx *cli.Context) (v0api.Gateway, jsonrpc.ClientCloser, error) {
|
||||
addr, headers, err := GetRawAPI(ctx, repo.FullNode, "v0")
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
return client.NewGatewayRPCV0(ctx.Context, addr, headers)
|
||||
}
|
||||
|
||||
func DaemonContext(cctx *cli.Context) context.Context {
|
||||
|
||||
+3
-3
@@ -36,7 +36,7 @@ func ParseApiInfo(s string) APIInfo {
|
||||
}
|
||||
}
|
||||
|
||||
func (a APIInfo) DialArgs() (string, error) {
|
||||
func (a APIInfo) DialArgs(version string) (string, error) {
|
||||
ma, err := multiaddr.NewMultiaddr(a.Addr)
|
||||
if err == nil {
|
||||
_, addr, err := manet.DialArgs(ma)
|
||||
@@ -44,14 +44,14 @@ func (a APIInfo) DialArgs() (string, error) {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return "ws://" + addr + "/rpc/v0", nil
|
||||
return "ws://" + addr + "/rpc/" + version, nil
|
||||
}
|
||||
|
||||
_, err = url.Parse(a.Addr)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
return a.Addr + "/rpc/v0", nil
|
||||
return a.Addr + "/rpc/" + version, nil
|
||||
}
|
||||
|
||||
func (a APIInfo) Host() (string, error) {
|
||||
|
||||
Reference in New Issue
Block a user