From 7e6c7ae068f2655bb01e49f9bf93b86f6e64ddfe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20S=C3=A1rai?= Date: Mon, 29 Jul 2024 14:49:28 +0200 Subject: [PATCH] feat(act): addgrantees with history address --- pkg/bee/api/act.go | 3 +++ pkg/bee/api/api.go | 11 ++++++----- pkg/check/act/act.go | 47 ++++++++++++++++++++++---------------------- 3 files changed, 33 insertions(+), 28 deletions(-) diff --git a/pkg/bee/api/act.go b/pkg/bee/api/act.go index 5b001bfdc..15f26a47d 100644 --- a/pkg/bee/api/act.go +++ b/pkg/bee/api/act.go @@ -44,6 +44,9 @@ func (a *ActService) AddGrantees(ctx context.Context, name string, data io.Reade var resp ActGranteesResponse h := http.Header{} h.Add("swarm-postage-batch-id", o.BatchID) + if o.ActHistoryAddress != nil { + h.Add("swarm-act-history-address", o.ActHistoryAddress.String()) + } err := a.client.requestWithHeader(ctx, http.MethodPost, "/"+apiVersion+"/grantee", h, data, &resp) return resp, err } diff --git a/pkg/bee/api/api.go b/pkg/bee/api/api.go index 7d5829a8c..e381ef4f4 100644 --- a/pkg/bee/api/api.go +++ b/pkg/bee/api/api.go @@ -313,11 +313,12 @@ func (f roundTripperFunc) RoundTrip(r *http.Request) (*http.Response, error) { } type UploadOptions struct { - Act bool - Pin bool - Tag uint64 - BatchID string - Direct bool + Act bool + Pin bool + Tag uint64 + BatchID string + Direct bool + ActHistoryAddress *swarm.Address } type DownloadOptions struct { diff --git a/pkg/check/act/act.go b/pkg/check/act/act.go index ff7c1f675..5dedda970 100644 --- a/pkg/check/act/act.go +++ b/pkg/check/act/act.go @@ -142,7 +142,8 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int ] }`))) - err = upClient.AddActGrantees(ctx, &gFile, api.UploadOptions{BatchID: batchID}) + fileHis := file.HistroryAddress() + err = upClient.AddActGrantees(ctx, &gFile, api.UploadOptions{BatchID: batchID, ActHistoryAddress: &fileHis}) if err != nil { return fmt.Errorf("node %s: add grantees error: %w", upNodeName, err) } @@ -175,28 +176,28 @@ func (c *Check) Run(ctx context.Context, cluster orchestration.Cluster, opts int "`+pubk3.String()+`" ] }`))) - - pErr := upClient.PatchActGrantees(ctx, &pFile, gFile.Address(), file.HistroryAddress(), batchID) - if pErr != nil { - return fmt.Errorf("node %s: PatchActGrantees: %w", upNodeName, pErr) - } - - c.logger.Info("ACT grantees patched") - c.logger.Infof("ACT file uploaded. patch History: %v", pFile.HistroryAddress()) - - // list grantees after patch - patchAddresses, patchErr := upClient.GetActGrantees(ctx, pFile.Address()) - if patchErr != nil { - return fmt.Errorf("node %s: GetActGrantees after patch: %w", upNodeName, patchErr) - } - if patchAddresses == nil { - return fmt.Errorf("node %s: GetActGrantees after patch: addresses is nil", upNodeName) - } - if len(patchAddresses) != 1 { - return fmt.Errorf("node %s: GetActGrantees after patch: addresses length is not 1", upNodeName) - } - c.logger.Info("ACT grantees listed after patch") - + /* + pErr := upClient.PatchActGrantees(ctx, &pFile, gFile.Address(), file.HistroryAddress(), batchID) + if pErr != nil { + return fmt.Errorf("node %s: PatchActGrantees: %w", upNodeName, pErr) + } + + c.logger.Info("ACT grantees patched") + c.logger.Infof("ACT file uploaded. patch History: %v", pFile.HistroryAddress()) + + // list grantees after patch + patchAddresses, patchErr := upClient.GetActGrantees(ctx, pFile.Address()) + if patchErr != nil { + return fmt.Errorf("node %s: GetActGrantees after patch: %w", upNodeName, patchErr) + } + if patchAddresses == nil { + return fmt.Errorf("node %s: GetActGrantees after patch: addresses is nil", upNodeName) + } + if len(patchAddresses) != 1 { + return fmt.Errorf("node %s: GetActGrantees after patch: addresses length is not 1", upNodeName) + } + c.logger.Info("ACT grantees listed after patch") + */ // download act file his := pFile.HistroryAddress() c.logger.Infof("ref: %v, act: %v, pubk: %v, history: %v", fileAddress, act, publisher, his)