Merge pull request #491 from filecoin-project/feat/bg-store-garbage
Run store-garbage in background
This commit is contained in:
commit
6d594bab67
@ -159,7 +159,7 @@ type StorageMiner interface {
|
||||
ActorAddress(context.Context) (address.Address, error)
|
||||
|
||||
// Temp api for testing
|
||||
StoreGarbageData(context.Context) (uint64, error)
|
||||
StoreGarbageData(context.Context) error
|
||||
|
||||
// Get the status of a given sector by ID
|
||||
SectorsStatus(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error)
|
||||
|
@ -127,7 +127,7 @@ type StorageMinerStruct struct {
|
||||
Internal struct {
|
||||
ActorAddress func(context.Context) (address.Address, error) `perm:"read"`
|
||||
|
||||
StoreGarbageData func(context.Context) (uint64, error) `perm:"write"`
|
||||
StoreGarbageData func(context.Context) error `perm:"write"`
|
||||
|
||||
SectorsStatus func(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error) `perm:"read"`
|
||||
SectorsList func(context.Context) ([]uint64, error) `perm:"read"`
|
||||
@ -461,7 +461,7 @@ func (c *StorageMinerStruct) ActorAddress(ctx context.Context) (address.Address,
|
||||
return c.Internal.ActorAddress(ctx)
|
||||
}
|
||||
|
||||
func (c *StorageMinerStruct) StoreGarbageData(ctx context.Context) (uint64, error) {
|
||||
func (c *StorageMinerStruct) StoreGarbageData(ctx context.Context) error {
|
||||
return c.Internal.StoreGarbageData(ctx)
|
||||
}
|
||||
|
||||
|
@ -20,13 +20,7 @@ var storeGarbageCmd = &cli.Command{
|
||||
defer closer()
|
||||
ctx := lcli.ReqContext(cctx)
|
||||
|
||||
sectorId, err := nodeApi.StoreGarbageData(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Println(sectorId)
|
||||
return nil
|
||||
return nodeApi.StoreGarbageData(ctx)
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -31,25 +31,29 @@ func (sm *StorageMinerAPI) ActorAddress(context.Context) (address.Address, error
|
||||
return sm.SectorBuilderConfig.Miner, nil
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) StoreGarbageData(ctx context.Context) (uint64, error) {
|
||||
func (sm *StorageMinerAPI) StoreGarbageData(ctx context.Context) error {
|
||||
ssize, err := sm.Miner.SectorSize(ctx)
|
||||
if err != nil {
|
||||
return 0, xerrors.Errorf("failed to get miner sector size: %w", err)
|
||||
return xerrors.Errorf("failed to get miner sector size: %w", err)
|
||||
}
|
||||
size := sectorbuilder.UserBytesForSectorSize(ssize)
|
||||
go func() {
|
||||
size := sectorbuilder.UserBytesForSectorSize(ssize)
|
||||
|
||||
// TODO: create a deal
|
||||
name := fmt.Sprintf("fake-file-%d", rand.Intn(100000000))
|
||||
sectorId, err := sm.Sectors.AddPiece(name, size, io.LimitReader(rand.New(rand.NewSource(42)), int64(size)))
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
// TODO: create a deal
|
||||
name := fmt.Sprintf("fake-file-%d", rand.Intn(100000000))
|
||||
sectorId, err := sm.Sectors.AddPiece(name, size, io.LimitReader(rand.New(rand.NewSource(42)), int64(size)))
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
|
||||
if err := sm.Sectors.SealSector(ctx, sectorId); err != nil {
|
||||
return sectorId, err
|
||||
}
|
||||
if err := sm.Sectors.SealSector(ctx, sectorId); err != nil {
|
||||
log.Error(err)
|
||||
return
|
||||
}
|
||||
}()
|
||||
|
||||
return sectorId, err
|
||||
return err
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (sectorbuilder.SectorSealingStatus, error) {
|
||||
|
Loading…
Reference in New Issue
Block a user