Skip to content

Commit

Permalink
feat: impl AddS3PieceStorage and
Browse files Browse the repository at this point in the history
RemoveS3PieceStorage of market node
  • Loading branch information
LinZexiao committed Jun 23, 2022
1 parent 162b94a commit faa1bee
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions api/impl/venus_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ type MarketNodeImpl struct {
GetExpectedSealDurationFunc config.GetExpectedSealDurationFunc
SetExpectedSealDurationFunc config.SetExpectedSealDurationFunc
AddFsPieceStorageFunc config.AddFsPieceStorageFunc
AddS3PieceStorageFunc config.AddS3PieceStorageFunc
RemoveFsPieceStorageFunc config.RemoveFsPieceStorageFunc
RemoveS3PieceStorageFunc config.RemoveS3PieceStorageFunc
}

func (m MarketNodeImpl) ActorList(ctx context.Context) ([]types.User, error) {
Expand Down Expand Up @@ -843,6 +845,19 @@ func (m MarketNodeImpl) AddFsPieceStorage(ctx context.Context, readonly bool, pa
return m.AddFsPieceStorageFunc(ifs)
}

func (m MarketNodeImpl) AddS3PieceStorage(ctx context.Context, readonly bool, endpoit string, accessKeyID string, secretAccessKey string, token string) error {
ifs := &config.S3PieceStorage{ReadOnly: readonly, EndPoint: endpoit, AccessKey: accessKeyID, SecretKey: secretAccessKey, Token: token}
s3ps, err := piecestorage.NewS3PieceStorage(ifs)
if err != nil {
return err
}
// add in memory
m.PieceStorageMgr.AddPieceStorage(s3ps)

// add to config
return m.AddS3PieceStorageFunc(ifs)
}

func (m MarketNodeImpl) ListPieceStorage(ctx context.Context) (string, error) {
storages := m.PieceStorageMgr.GetStorages()

Expand Down Expand Up @@ -882,10 +897,10 @@ func (m MarketNodeImpl) RemovePieceStorage(ctx context.Context, index int) error
return m.RemoveFsPieceStorageFunc(fscfg)

}
cfg, ok = cfg.(*config.S3PieceStorage)
s3cfg, ok := cfg.(*config.S3PieceStorage)
if ok {
log.Info("remove s3 piece storage")
return nil
return m.RemoveS3PieceStorageFunc(s3cfg)
}

return fmt.Errorf("piece storage config not found")
Expand Down

0 comments on commit faa1bee

Please sign in to comment.