go-ethereum/portalnetwork/storage/content_storage.go
Chen Kai d099f17214 feat:add ForkedLightClientBootstrap
Signed-off-by: Chen Kai <281165273grape@gmail.com>
2024-04-03 17:13:50 +08:00

32 lines
631 B
Go

package storage
import "fmt"
var ErrContentNotFound = fmt.Errorf("content not found")
type ContentType byte
type ContentKey struct {
selector ContentType
data []byte
}
func NewContentKey(selector ContentType, hash []byte) *ContentKey {
return &ContentKey{
selector: selector,
data: hash,
}
}
func (c *ContentKey) Encode() []byte {
res := make([]byte, 0, len(c.data)+1)
res = append(res, byte(c.selector))
res = append(res, c.data...)
return res
}
type ContentStorage interface {
Get(contentKey []byte, contentId []byte) ([]byte, error)
Put(contentKey []byte, contentId []byte, content []byte) error
}