From e0292f7c07489bdfb4977683edeb11bfd8cc0686 Mon Sep 17 00:00:00 2001 From: Andras Aranyi Date: Thu, 16 May 2024 16:34:50 +0400 Subject: [PATCH] refactor(act): add docs, fixed typos, removed import aliases --- pkg/api/bytes.go | 5 ++--- pkg/api/bzz.go | 9 ++++----- pkg/api/dynamicaccess.go | 6 ++++-- pkg/api/feed.go | 4 ++-- pkg/dynamicaccess/accesslogic_test.go | 2 +- pkg/dynamicaccess/controller.go | 7 ++++--- 6 files changed, 17 insertions(+), 16 deletions(-) diff --git a/pkg/api/bytes.go b/pkg/api/bytes.go index 2afb1db99c0..0eefb581c1b 100644 --- a/pkg/api/bytes.go +++ b/pkg/api/bytes.go @@ -15,7 +15,7 @@ import ( "github.com/ethersphere/bee/v2/pkg/file/redundancy" "github.com/ethersphere/bee/v2/pkg/jsonhttp" "github.com/ethersphere/bee/v2/pkg/postage" - storage "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storage" "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/ethersphere/bee/v2/pkg/tracing" "github.com/gorilla/mux" @@ -124,8 +124,7 @@ func (s *Service) bytesUploadHandler(w http.ResponseWriter, r *http.Request) { return } } - // TODO: what should be the root_address ? (eref vs ref) - span.SetTag("root_address", reference) + span.SetTag("root_address", encryptedReference) err = putter.Done(reference) if err != nil { diff --git a/pkg/api/bzz.go b/pkg/api/bzz.go index b49bc89baea..dc26b26667a 100644 --- a/pkg/api/bzz.go +++ b/pkg/api/bzz.go @@ -30,8 +30,8 @@ import ( "github.com/ethersphere/bee/v2/pkg/log" "github.com/ethersphere/bee/v2/pkg/manifest" "github.com/ethersphere/bee/v2/pkg/postage" - storage "github.com/ethersphere/bee/v2/pkg/storage" - storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer" "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/ethersphere/bee/v2/pkg/topology" "github.com/ethersphere/bee/v2/pkg/tracing" @@ -281,9 +281,8 @@ func (s *Service) fileUploadHandler( ext.LogError(span, err, olog.String("action", "putter.Done")) return } - // TODO: what should be the root_address ? (eref vs ref) span.LogFields(olog.Bool("success", true)) - span.SetTag("root_address", manifestReference) + span.SetTag("root_address", encryptedReference) if tagID != 0 { w.Header().Set(SwarmTagHeader, fmt.Sprint(tagID)) @@ -291,7 +290,7 @@ func (s *Service) fileUploadHandler( } w.Header().Set(ETagHeader, fmt.Sprintf("%q", encryptedReference.String())) w.Header().Set("Access-Control-Expose-Headers", SwarmTagHeader) - // TODO: do we need to return reference as well ? + jsonhttp.Created(w, bzzUploadResponse{ Reference: encryptedReference, }) diff --git a/pkg/api/dynamicaccess.go b/pkg/api/dynamicaccess.go index 0a434f7776a..b0be09fbcfa 100644 --- a/pkg/api/dynamicaccess.go +++ b/pkg/api/dynamicaccess.go @@ -199,7 +199,8 @@ func (s *Service) actListGranteesHandler(w http.ResponseWriter, r *http.Request) jsonhttp.OK(w, granteeSlice) } -// TODO: actGrantRevokeHandler doc. +// actGrantRevokeHandler is a middleware that makes updates to the list of grantees, +// only the publisher is authorized to perform this action func (s *Service) actGrantRevokeHandler(w http.ResponseWriter, r *http.Request) { logger := s.logger.WithName("act_grant_revoke_handler").Build() @@ -363,7 +364,8 @@ func (s *Service) actGrantRevokeHandler(w http.ResponseWriter, r *http.Request) }) } -// TODO: actCreateGranteesHandler doc. +// actCreateGranteesHandler is a middleware that creates a new list of grantees, +// only the publisher is authorized to perform this action func (s *Service) actCreateGranteesHandler(w http.ResponseWriter, r *http.Request) { logger := s.logger.WithName("acthandler").Build() diff --git a/pkg/api/feed.go b/pkg/api/feed.go index 3d43d3d148e..552cd03ffa4 100644 --- a/pkg/api/feed.go +++ b/pkg/api/feed.go @@ -21,8 +21,8 @@ import ( "github.com/ethersphere/bee/v2/pkg/manifest/simple" "github.com/ethersphere/bee/v2/pkg/postage" "github.com/ethersphere/bee/v2/pkg/soc" - storage "github.com/ethersphere/bee/v2/pkg/storage" - storer "github.com/ethersphere/bee/v2/pkg/storer" + "github.com/ethersphere/bee/v2/pkg/storage" + "github.com/ethersphere/bee/v2/pkg/storer" "github.com/ethersphere/bee/v2/pkg/swarm" "github.com/gorilla/mux" ) diff --git a/pkg/dynamicaccess/accesslogic_test.go b/pkg/dynamicaccess/accesslogic_test.go index 095718e171d..a894c90e25f 100644 --- a/pkg/dynamicaccess/accesslogic_test.go +++ b/pkg/dynamicaccess/accesslogic_test.go @@ -169,7 +169,7 @@ func TestAddPublisher(t *testing.T) { decodedEncryptedAccessKey := hex.EncodeToString(encryptedAccessKey) - // A random value is returned so it is only possibly to check the length of the returned value + // A random value is returned, so it is only possible to check the length of the returned value // We know the lookup key because the generated private key is fixed if len(decodedEncryptedAccessKey) != 64 { t.Errorf("AddPublisher: expected encrypted access key length 64, got %d", len(decodedEncryptedAccessKey)) diff --git a/pkg/dynamicaccess/controller.go b/pkg/dynamicaccess/controller.go index 806600c7981..911c59f3f27 100644 --- a/pkg/dynamicaccess/controller.go +++ b/pkg/dynamicaccess/controller.go @@ -17,7 +17,8 @@ import ( ) type GranteeManager interface { - // TODO: doc + // HandleGrantees manages the grantees for the given publisher, updating the list based on provided public keys to add or remove. + // Only the publisher can make changes to the grantee list. HandleGrantees(ctx context.Context, ls file.LoadSaver, gls file.LoadSaver, granteeref swarm.Address, historyref swarm.Address, publisher *ecdsa.PublicKey, addList, removeList []*ecdsa.PublicKey) (swarm.Address, swarm.Address, swarm.Address, swarm.Address, error) // GetGrantees returns the list of grantees for the given publisher. // The list is accessible only by the publisher. @@ -66,7 +67,7 @@ func (c *ControllerStruct) DownloadHandler( func (c *ControllerStruct) UploadHandler( ctx context.Context, ls file.LoadSaver, - refrefence swarm.Address, + reference swarm.Address, publisher *ecdsa.PublicKey, historyRootHash swarm.Address, ) (swarm.Address, swarm.Address, swarm.Address, error) { @@ -117,7 +118,7 @@ func (c *ControllerStruct) UploadHandler( } } - encryptedRef, err := c.accessLogic.EncryptRef(ctx, storage, publisher, refrefence) + encryptedRef, err := c.accessLogic.EncryptRef(ctx, storage, publisher, reference) return actRef, historyRef, encryptedRef, err }