Documentation ¶
Index ¶
- Constants
- Variables
- func NewError(code int, s string) error
- func NewErrorf(code int, format string, args ...interface{}) error
- type API
- func (a *API) CreateFeed(topic []byte, user utils.Address, data []byte, encryptionPassword []byte) ([]byte, error)
- func (a *API) CreateFeedFromTopic(topic []byte, user utils.Address, data []byte) ([]byte, error)
- func (a *API) DeleteFeed(topic []byte, user utils.Address) error
- func (a *API) DeleteFeedFromTopic(topic []byte, user utils.Address) error
- func (a *API) GetFeedData(topic []byte, user utils.Address, encryptionPassword []byte) ([]byte, []byte, error)
- func (a *API) GetFeedDataFromTopic(topic []byte, user utils.Address) ([]byte, []byte, error)
- func (a *API) GetSOCFromAddress(address []byte) ([]byte, error)
- func (a *API) IsReadOnlyFeed() bool
- func (a *API) UpdateFeed(topic []byte, user utils.Address, data []byte, encryptionPassword []byte) ([]byte, error)
- type CacheEntry
- type DefaultTimestampProvider
- type Error
- type Feed
- type Handler
- type ID
- type Query
- type Signature
- type Timestamp
- type Topic
- type Update
Constants ¶
const TopicLength = 32
TopicLength establishes the max length of a topic string
Variables ¶
var ( // ErrInvalidTopicSize is returned when a topic is not equal to TopicLength ErrInvalidTopicSize = fmt.Errorf("topic is not equal to %d", TopicLength) // ErrInvalidPayloadSize is returned when the payload is greater than the chunk size ErrInvalidPayloadSize = fmt.Errorf("payload size is too large. maximum payload size is %d bytes", utils.MaxChunkLength) // ErrReadOnlyFeed is returned when a feed is read only for a user ErrReadOnlyFeed = fmt.Errorf("read only feed") )
var TimestampProvider timestampProvider = NewDefaultTimestampProvider()
TimestampProvider sets the time source of the feeds package
Functions ¶
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API handles feed operations
func (*API) CreateFeed ¶
func (a *API) CreateFeed(topic []byte, user utils.Address, data []byte, encryptionPassword []byte) ([]byte, error)
CreateFeed creates a feed by constructing a single owner chunk. This chunk can only be accessed if the pod address is known. Also, no one else can spoof this chunk since this is signed by the pod.
func (*API) CreateFeedFromTopic ¶ added in v0.9.1
CreateFeedFromTopic creates a soc with the topic as identifier
func (*API) DeleteFeed ¶
DeleteFeed deleted the feed by updating with no data inside the SOC chunk.
func (*API) DeleteFeedFromTopic ¶ added in v0.9.1
DeleteFeedFromTopic deleted the feed by updating with no data inside the SOC chunk.
func (*API) GetFeedData ¶
func (a *API) GetFeedData(topic []byte, user utils.Address, encryptionPassword []byte) ([]byte, []byte, error)
GetFeedData looks up feed from swarm
func (*API) GetFeedDataFromTopic ¶ added in v0.9.1
GetFeedDataFromTopic will generate keccak256 reference of the topic+address and download soc
func (*API) GetSOCFromAddress ¶ added in v0.9.1
GetSOCFromAddress will download the soc chunk for the given reference
func (*API) IsReadOnlyFeed ¶
IsReadOnlyFeed if a public pod is imported, the feed can only be read. this function check the feed is read only. skipcq: TCV-001
type CacheEntry ¶
CacheEntry caches the last known update of a specific Swarm feed.
func (*CacheEntry) Topic ¶
func (r *CacheEntry) Topic() Topic
Topic returns the feed's topic skipcq: TCV-001
type DefaultTimestampProvider ¶
type DefaultTimestampProvider struct { }
DefaultTimestampProvider is a TimestampProvider that uses system time as time source
func NewDefaultTimestampProvider ¶
func NewDefaultTimestampProvider() *DefaultTimestampProvider
NewDefaultTimestampProvider creates a system clock based timestamp provider
func (*DefaultTimestampProvider) Now ¶
func (*DefaultTimestampProvider) Now() Timestamp
Now returns the current time according to this provider
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is a the typed error object used for Swarm feeds
type Handler ¶
type Handler struct { HashSize int // contains filtered or unexported fields }
func NewHandler ¶
func NewHandler(accountInfo *account.Info, client blockstore.Client, hasherPool *bmtlegacy.TreePool) *Handler
NewHandler the main handler object that handles all the feed related functions.
func (*Handler) GetContent ¶
GetContent retrieves the data payload of the last synced update of the feed
func (*Handler) Lookup ¶
Lookup retrieves a specific or latest feed update Lookup works differently depending on the configuration of `query` See the `query` documentation and helper functions: `NewQueryLatest` and `NewQuery`
func (*Handler) NewRequest ¶
NewRequest prepares a request structure with all the necessary information to just add the desired data and sign it. The resulting structure can then be signed and passed to Handler.Update to be verified and sent
type Query ¶
Query is used to specify constraints when performing an update lookup TimeLimit indicates an upper bound for the search. Set to 0 for "now"
type Signature ¶
type Signature [signatureLength]byte
Signature is an alias for a assets byte array with the size of a signature
type Timestamp ¶
type Timestamp struct {
Time uint64 `json:"time"` // Unix epoch timestamp, in seconds
}
Timestamp encodes a point in time as a Unix epoch
func (*Timestamp) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface skipcq: TCV-001
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaller interface skipcq: TCV-001