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
}
Current Storage interface is designed as below
In the history network, we just need
contentIdto get or store data.But in the beacon network, we must know the
contentKeyto store or get data. So we can change the interface as belowbecause 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
toContentIdmethod