From 936748d3f5ec7c46dd27baf9b9af21fe35710fd4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 30 Mar 2021 16:04:17 +0200 Subject: [PATCH] Support .srs for proof aggregation --- paramfetch.go | 12 +++++++++++- paramfetch/paramfetch.go | 6 +++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/paramfetch.go b/paramfetch.go index 4950dbc..44b9ee6 100644 --- a/paramfetch.go +++ b/paramfetch.go @@ -50,7 +50,7 @@ func getParamDir() string { return os.Getenv(dirEnv) } -func GetParams(ctx context.Context, paramBytes []byte, storageSize uint64) error { +func GetParams(ctx context.Context, paramBytes []byte, srsBytes []byte, storageSize uint64) error { if err := os.Mkdir(getParamDir(), 0755); err != nil && !os.IsExist(err) { return err } @@ -71,6 +71,16 @@ func GetParams(ctx context.Context, paramBytes []byte, storageSize uint64) error ft.maybeFetchAsync(ctx, name, info) } + var srs map[string]paramFile + + if err := json.Unmarshal(srsBytes, &srs); err != nil { + return err + } + + for name, info := range srs { + ft.maybeFetchAsync(ctx, name, info) + } + return ft.wait(ctx) } diff --git a/paramfetch/paramfetch.go b/paramfetch/paramfetch.go index d9c9e08..717b127 100644 --- a/paramfetch/paramfetch.go +++ b/paramfetch/paramfetch.go @@ -33,6 +33,7 @@ func cancelOnSignal(ctx context.Context, sig ...os.Signal) context.Context { func main() { sectorSize := os.Args[1] paramsJsonPath := os.Args[2] + srsJsonPath := os.Args[2] n, err := strconv.ParseUint(sectorSize, 10, 64) check(err) @@ -40,8 +41,11 @@ func main() { dat, err := ioutil.ReadFile(paramsJsonPath) check(err) + datSrs, err := ioutil.ReadFile(srsJsonPath) + check(err) + ctx := cancelOnSignal(context.TODO(), syscall.SIGTERM, syscall.SIGINT, syscall.SIGHUP) - err = build.GetParams(ctx, dat, n) + err = build.GetParams(ctx, dat, datSrs, n) check(err) }