v1.27.0-a #10
@ -820,7 +820,13 @@ func StorageAuth(ctx helpers.MetricsCtx, ca v0api.Common) (sealer.StorageAuth, e
|
||||
return sealer.StorageAuth(headers), nil
|
||||
}
|
||||
|
||||
func StorageAuthWithURL(apiInfo string) func(ctx helpers.MetricsCtx, ca v0api.Common) (sealer.StorageAuth, error) {
|
||||
func StorageAuthWithURL(apiInfo string) interface{} {
|
||||
if strings.HasPrefix(apiInfo, "harmony:") {
|
||||
return func(ctx helpers.MetricsCtx, ca MinerStorageService) (sealer.StorageAuth, error) {
|
||||
return StorageAuth(ctx, ca)
|
||||
}
|
||||
}
|
||||
|
||||
return func(ctx helpers.MetricsCtx, ca v0api.Common) (sealer.StorageAuth, error) {
|
||||
s := strings.Split(apiInfo, ":")
|
||||
if len(s) != 2 {
|
||||
|
@ -30,9 +30,7 @@ type MinerStorageService api.StorageMiner
|
||||
|
||||
var _ sectorblocks.SectorBuilder = *new(MinerSealingService)
|
||||
|
||||
func connectHarmony(apiInfo string, fapi v1api.FullNode, mctx helpers.MetricsCtx, lc fx.Lifecycle) (api.StorageMiner, error) {
|
||||
log.Info("Connecting to harmonydb")
|
||||
|
||||
func harmonyApiInfoToConf(apiInfo string) (config.HarmonyDB, error) {
|
||||
hc := config.HarmonyDB{}
|
||||
|
||||
// apiInfo - harmony:maddr:user:pass:dbname:host:port
|
||||
@ -40,12 +38,7 @@ func connectHarmony(apiInfo string, fapi v1api.FullNode, mctx helpers.MetricsCtx
|
||||
parts := strings.Split(apiInfo, ":")
|
||||
|
||||
if len(parts) != 7 {
|
||||
return nil, xerrors.Errorf("invalid harmonydb info")
|
||||
}
|
||||
|
||||
maddr, err := address.NewFromString(parts[1])
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("parsing miner address: %w", err)
|
||||
return config.HarmonyDB{}, xerrors.Errorf("invalid harmonydb info '%s'", apiInfo)
|
||||
}
|
||||
|
||||
hc.Username = parts[2]
|
||||
@ -54,11 +47,28 @@ func connectHarmony(apiInfo string, fapi v1api.FullNode, mctx helpers.MetricsCtx
|
||||
hc.Hosts = []string{parts[5]}
|
||||
hc.Port = parts[6]
|
||||
|
||||
return hc, nil
|
||||
}
|
||||
|
||||
func connectHarmony(apiInfo string, fapi v1api.FullNode, mctx helpers.MetricsCtx, lc fx.Lifecycle) (api.StorageMiner, error) {
|
||||
log.Info("Connecting to harmonydb")
|
||||
|
||||
hc, err := harmonyApiInfoToConf(apiInfo)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
db, err := harmonydb.NewFromConfig(hc)
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("connecting to harmonydb: %w", err)
|
||||
}
|
||||
|
||||
parts := strings.Split(apiInfo, ":")
|
||||
maddr, err := address.NewFromString(parts[1])
|
||||
if err != nil {
|
||||
return nil, xerrors.Errorf("parsing miner address: %w", err)
|
||||
}
|
||||
|
||||
pin := lpmarket.NewPieceIngester(db, fapi)
|
||||
|
||||
si := paths.NewDBIndex(nil, db)
|
||||
|
Loading…
Reference in New Issue
Block a user