Run store-garbage in background
This commit is contained in:
parent
340e9177b2
commit
8e1a9a71e6
@ -159,7 +159,7 @@ type StorageMiner interface {
|
|||||||
ActorAddress(context.Context) (address.Address, error)
|
ActorAddress(context.Context) (address.Address, error)
|
||||||
|
|
||||||
// Temp api for testing
|
// Temp api for testing
|
||||||
StoreGarbageData(context.Context) (uint64, error)
|
StoreGarbageData(context.Context) error
|
||||||
|
|
||||||
// Get the status of a given sector by ID
|
// Get the status of a given sector by ID
|
||||||
SectorsStatus(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error)
|
SectorsStatus(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error)
|
||||||
|
@ -127,7 +127,7 @@ type StorageMinerStruct struct {
|
|||||||
Internal struct {
|
Internal struct {
|
||||||
ActorAddress func(context.Context) (address.Address, error) `perm:"read"`
|
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"`
|
SectorsStatus func(context.Context, uint64) (sectorbuilder.SectorSealingStatus, error) `perm:"read"`
|
||||||
SectorsList func(context.Context) ([]uint64, 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)
|
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)
|
return c.Internal.StoreGarbageData(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,13 +20,7 @@ var storeGarbageCmd = &cli.Command{
|
|||||||
defer closer()
|
defer closer()
|
||||||
ctx := lcli.ReqContext(cctx)
|
ctx := lcli.ReqContext(cctx)
|
||||||
|
|
||||||
sectorId, err := nodeApi.StoreGarbageData(ctx)
|
return nodeApi.StoreGarbageData(ctx)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt.Println(sectorId)
|
|
||||||
return nil
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -31,25 +31,29 @@ func (sm *StorageMinerAPI) ActorAddress(context.Context) (address.Address, error
|
|||||||
return sm.SectorBuilderConfig.Miner, nil
|
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)
|
ssize, err := sm.Miner.SectorSize(ctx)
|
||||||
if err != nil {
|
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
|
// TODO: create a deal
|
||||||
name := fmt.Sprintf("fake-file-%d", rand.Intn(100000000))
|
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)))
|
sectorId, err := sm.Sectors.AddPiece(name, size, io.LimitReader(rand.New(rand.NewSource(42)), int64(size)))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
log.Error(err)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if err := sm.Sectors.SealSector(ctx, sectorId); err != nil {
|
if err := sm.Sectors.SealSector(ctx, sectorId); err != nil {
|
||||||
return sectorId, err
|
log.Error(err)
|
||||||
}
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
return sectorId, err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (sectorbuilder.SectorSealingStatus, error) {
|
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid uint64) (sectorbuilder.SectorSealingStatus, error) {
|
||||||
|
Loading…
Reference in New Issue
Block a user