Skip to content

Commit

Permalink
refactor(act): add docs, fixed typos, removed import aliases
Browse files Browse the repository at this point in the history
  • Loading branch information
aranyia committed May 16, 2024
1 parent 5c5706c commit e0292f7
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
5 changes: 2 additions & 3 deletions pkg/api/bytes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 {
Expand Down
9 changes: 4 additions & 5 deletions pkg/api/bzz.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -281,17 +281,16 @@ 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))
span.SetTag("tagID", tagID)
}
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,
})
Expand Down
6 changes: 4 additions & 2 deletions pkg/api/dynamicaccess.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
4 changes: 2 additions & 2 deletions pkg/api/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion pkg/dynamicaccess/accesslogic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
7 changes: 4 additions & 3 deletions pkg/dynamicaccess/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit e0292f7

Please sign in to comment.