Roturn SectorID from PledgeSector
This commit is contained in:
parent
f719765069
commit
fd90c03018
@ -36,7 +36,7 @@ type StorageMiner interface {
|
|||||||
MiningBase(context.Context) (*types.TipSet, error)
|
MiningBase(context.Context) (*types.TipSet, error)
|
||||||
|
|
||||||
// Temp api for testing
|
// Temp api for testing
|
||||||
PledgeSector(context.Context) error
|
PledgeSector(context.Context) (abi.SectorID, error)
|
||||||
|
|
||||||
// Get the status of a given sector by ID
|
// Get the status of a given sector by ID
|
||||||
SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (SectorInfo, error)
|
SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (SectorInfo, error)
|
||||||
|
@ -304,7 +304,7 @@ type StorageMinerStruct struct {
|
|||||||
MarketPendingDeals func(ctx context.Context) (api.PendingDealInfo, error) `perm:"write"`
|
MarketPendingDeals func(ctx context.Context) (api.PendingDealInfo, error) `perm:"write"`
|
||||||
MarketPublishPendingDeals func(ctx context.Context) error `perm:"admin"`
|
MarketPublishPendingDeals func(ctx context.Context) error `perm:"admin"`
|
||||||
|
|
||||||
PledgeSector func(context.Context) error `perm:"write"`
|
PledgeSector func(context.Context) (abi.SectorID, error) `perm:"write"`
|
||||||
|
|
||||||
SectorsStatus func(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) `perm:"read"`
|
SectorsStatus func(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) `perm:"read"`
|
||||||
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
SectorsList func(context.Context) ([]abi.SectorNumber, error) `perm:"read"`
|
||||||
@ -1274,7 +1274,7 @@ func (c *StorageMinerStruct) ActorAddressConfig(ctx context.Context) (api.Addres
|
|||||||
return c.Internal.ActorAddressConfig(ctx)
|
return c.Internal.ActorAddressConfig(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *StorageMinerStruct) PledgeSector(ctx context.Context) error {
|
func (c *StorageMinerStruct) PledgeSector(ctx context.Context) (abi.SectorID, error) {
|
||||||
return c.Internal.PledgeSector(ctx)
|
return c.Internal.PledgeSector(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,14 @@ var sectorsPledgeCmd = &cli.Command{
|
|||||||
defer closer()
|
defer closer()
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
return nodeApi.PledgeSector(ctx)
|
id, err := nodeApi.PledgeSector(ctx)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Println("Created CC sector: ", id.Number)
|
||||||
|
|
||||||
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1142,7 +1142,13 @@ Perms: write
|
|||||||
|
|
||||||
Inputs: `null`
|
Inputs: `null`
|
||||||
|
|
||||||
Response: `{}`
|
Response:
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"Miner": 1000,
|
||||||
|
"Number": 9
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
## Return
|
## Return
|
||||||
|
|
||||||
|
@ -121,10 +121,10 @@ func (sm *StorageMinerAPI) ActorSectorSize(ctx context.Context, addr address.Add
|
|||||||
return mi.SectorSize, nil
|
return mi.SectorSize, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) error {
|
func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) (abi.SectorID, error) {
|
||||||
sr, err := sm.Miner.PledgeSector(ctx)
|
sr, err := sm.Miner.PledgeSector(ctx)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return abi.SectorID{}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for the sector to enter the Packing state
|
// wait for the sector to enter the Packing state
|
||||||
@ -132,17 +132,17 @@ func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) error {
|
|||||||
for {
|
for {
|
||||||
info, err := sm.Miner.GetSectorInfo(sr.ID.Number)
|
info, err := sm.Miner.GetSectorInfo(sr.ID.Number)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return xerrors.Errorf("getting pledged sector info: %w", err)
|
return abi.SectorID{}, xerrors.Errorf("getting pledged sector info: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if info.State != sealing.UndefinedSectorState {
|
if info.State != sealing.UndefinedSectorState {
|
||||||
return nil
|
return sr.ID, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-time.After(10 * time.Millisecond):
|
case <-time.After(10 * time.Millisecond):
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return abi.SectorID{}, ctx.Err()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user