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