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

change the Storage interface #62

Closed
fearlessfe opened this issue Mar 20, 2024 · 0 comments · Fixed by #65
Closed

change the Storage interface #62

fearlessfe opened this issue Mar 20, 2024 · 0 comments · Fixed by #65

Comments

@fearlessfe
Copy link

Current Storage interface is designed as below

type ContentStorage interface {
	Get(contentId []byte) ([]byte, error)
	Put(contentId []byte, content []byte) error
}

In the history network, we just need contentId to get or store data.

But in the beacon network, we must know the contentKey to store or get data. So we can change the interface as below

type ContentStorage interface {
	Get(contentKey []byte, contentId []byte) ([]byte, error)
	Put(contentKey []byte, contentId []byte, content []byte) error
}

because the contentKey is []byte, when we use it, it should be decode to the relevant types。

there is another choice, which contentKey is an interface, which impl the toContentId method

type Something interface {
        toContentId() []byte
}

type ContentStorage interface {
	Get(contentKey Something ) ([]byte, error)
	Put(contentKey Something , content []byte) error
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant