Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

api, manifest: abstract saver/loader functionality #939

Merged
merged 4 commits into from
Dec 4, 2020
Merged

Conversation

acud
Copy link
Member

@acud acud commented Nov 11, 2020

this is needed so we don't need to pass crypto.Signer and batch IDs to the manifest package as part of the storage incentives effort

needed for #873

@acud acud self-assigned this Nov 11, 2020
@acud acud added the in progress ongoing development , hold out with review label Nov 11, 2020
@acud acud added ready for review The PR is ready to be reviewed and removed in progress ongoing development , hold out with review labels Nov 11, 2020
@acud acud requested review from zbiljic, janos and zelig and removed request for zbiljic November 11, 2020 14:35
@@ -36,7 +35,7 @@ type Interface interface {
// HasPrefix tests whether the specified prefix path exists.
HasPrefix(string) (bool, error)
// Store stores the manifest, returning the resulting address.
Store(context.Context, storage.ModePut) (swarm.Address, error)
Store() (swarm.Address, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the context.Context should be left here.

pkg/file/io.go Outdated

type Loader interface {
// Load a reference in byte slice representation and return all content associated with the reference.
Load([]byte) ([]byte, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this is in Bee project, I think that Load/Save functions should return swarm.Address directly.

And maybe allow passing context to both operations.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this interface was made to be compatible with manifest.Loader in the manifest package. have a closer look that i am injecting this interface directly into the mantaray dependency on load and save. if you want it as an address then we need to change the interface in mantaray first

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am fully aware this was the reason. My comment is that we should not force external interface into this project.

The interface in "manatary" project was created to be independent from some external project. That interface is how it is, and should not be changed.
I would rather we have another level of indirection instead of having something like this. Especially since some other parts of Bee project might want to use this package.

Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets revisit this when this is merged ethersphere/manifest#16

pkg/api/dirs.go Outdated Show resolved Hide resolved
pkg/api/dirs_test.go Outdated Show resolved Hide resolved
pkg/api/dirs.go Outdated Show resolved Hide resolved
pkg/api/dirs.go Outdated Show resolved Hide resolved
pkg/api/dirs.go Outdated Show resolved Hide resolved
pkg/manifest/manifest.go Outdated Show resolved Hide resolved
@janos
Copy link
Member

janos commented Nov 12, 2020

@acud
Copy link
Member Author

acud commented Nov 12, 2020

@janos errors are intentional. waiting for viktor's PR to be merged to the manifest project

@acud acud added in progress ongoing development , hold out with review and removed ready for review The PR is ready to be reviewed labels Nov 12, 2020
@acud acud requested review from zbiljic and zelig December 2, 2020 13:49
@acud acud added ready for review The PR is ready to be reviewed and removed in progress ongoing development , hold out with review labels Dec 2, 2020
@@ -107,3 +107,18 @@ func SplitWriteAll(ctx context.Context, s Splitter, r io.Reader, l int64, toEncr
}
return addr, nil
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these interfaces are defined twice. we should use only one and have it in storage package maybe

Copy link
Member Author

@acud acud Dec 3, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these interfaces provide functionalities which are wrapping components in the file package. that's why I put them here. it belongs here more than in storage, which relates more to localstore and the likes

pkg/traversal/traversal_test.go Outdated Show resolved Hide resolved
pkg/api/api.go Outdated Show resolved Hide resolved
pkg/api/api.go Outdated Show resolved Hide resolved
pkg/api/dirs.go Outdated Show resolved Hide resolved
pkg/api/dirs.go Outdated Show resolved Hide resolved
pkg/api/file.go Outdated Show resolved Hide resolved
@acud acud requested a review from zelig December 3, 2020 11:11
Copy link
Member

@zelig zelig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@zbiljic zbiljic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only things I think should be changed is LoadSaver function signatures, to use swarm.Address. That way package may be usable for other things in the future.


type Loader interface {
// Load a reference in byte slice representation and return all content associated with the reference.
Load(context.Context, []byte) ([]byte, error)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think since we are in the bee project, the Load and Save function should work directly with swarm.Address, instead of using []byte.

This may require having some proxy implementation for manifest, where we have implementation with byte slice, which translates to swarm.Address.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but then it means I need an extra abstraction that would use this one. I'm not sure why this is necessary. I only created this implementation to be compatible with the manta ray interfaces. I think that once other components need to use similar functionality we can generalize, but I'm not sure why to do so prematurely

Copy link
Contributor

@zbiljic zbiljic Dec 4, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I just do not think application should cater to library completely.

It can be seen that references are already used, but the simple manifest implementation.

}

// NewSimpleManifest creates a new simple manifest.
func NewSimpleManifest(
encrypted bool,
storer storage.Storer,
ls file.LoadSaver,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function signature may be collapsed now (it should be enough shorter).

@acud acud merged commit 0b337f6 into master Dec 4, 2020
@acud acud deleted the manifest-saver branch December 4, 2020 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pull-request ready for review The PR is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants