Skip to content

change the Storage interface #62

Description

@fearlessfe

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
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions