Skip to content

Commit

Permalink
swarm/storage/feeds: removed capital Feed throughout
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeletier committed Oct 3, 2018
1 parent 68b8088 commit 58c0879
Show file tree
Hide file tree
Showing 20 changed files with 60 additions and 60 deletions.
2 changes: 1 addition & 1 deletion cmd/swarm/feeds.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.

// Command feed allows the user to create and update signed Swarm Feeds
// Command feed allows the user to create and update signed Swarm feeds
package main

import (
Expand Down
2 changes: 1 addition & 1 deletion cmd/swarm/feeds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func TestCLIFeedUpdate(t *testing.T) {
t.Fatal(err)
}

// make sure the retrieved Feed is the same
// make sure the retrieved feed is the same
if request.Feed != feed {
t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed)
}
Expand Down
8 changes: 4 additions & 4 deletions cmd/swarm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,8 +355,8 @@ func init() {
Action: feedCreateManifest,
CustomHelpTemplate: helpTemplate,
Name: "create",
Usage: "creates and publishes a new Feed manifest",
Description: `creates and publishes a new Feed manifest pointing to a specified user's updates about a particular topic.
Usage: "creates and publishes a new feed manifest",
Description: `creates and publishes a new feed manifest pointing to a specified user's updates about a particular topic.
The feed topic can be built in the following ways:
* use --topic to set the topic to an arbitrary binary hex string.
* use --name to set the topic to a human-readable name.
Expand Down Expand Up @@ -392,8 +392,8 @@ func init() {
Action: feedInfo,
CustomHelpTemplate: helpTemplate,
Name: "info",
Usage: "obtains information about an existing Swarm Feed",
Description: `obtains information about an existing Swarm Feed
Usage: "obtains information about an existing Swarm feed",
Description: `obtains information about an existing Swarm feed
The topic can be specified directly with the --topic flag as an hex string
If no topic is specified, the default topic (zero) will be used
The --name flag can be used to specify subtopics with a specific name.
Expand Down
22 changes: 11 additions & 11 deletions swarm/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func (a *API) Get(ctx context.Context, decrypt DecryptFunc, manifestAddr storage
return a.Get(ctx, decrypt, adr, entry.Path)
}

// we need to do some extra work if this is a Feed manifest
// we need to do some extra work if this is a Swarm feed manifest
if entry.ContentType == FeedContentType {
if entry.Feed == nil {
return reader, mimeType, status, nil, fmt.Errorf("Cannot decode Feed in manifest")
Expand Down Expand Up @@ -957,7 +957,7 @@ func (a *API) BuildDirectoryTree(ctx context.Context, mhash string, nameresolver
return addr, manifestEntryMap, nil
}

// FeedsLookup finds Swarm Feeds Updates at specific points in time, or the latest update
// FeedsLookup finds Swarm feeds updates at specific points in time, or the latest update
func (a *API) FeedsLookup(ctx context.Context, query *feeds.Query) ([]byte, error) {
_, err := a.feeds.Lookup(ctx, query)
if err != nil {
Expand All @@ -971,17 +971,17 @@ func (a *API) FeedsLookup(ctx context.Context, query *feeds.Query) ([]byte, erro
return data, nil
}

// FeedsNewRequest creates a Request object to update a specific Feed
// FeedsNewRequest creates a Request object to update a specific feed
func (a *API) FeedsNewRequest(ctx context.Context, feed *feeds.Feed) (*feeds.Request, error) {
return a.feeds.NewRequest(ctx, feed)
}

// FeedsUpdate publishes a new update on the given Feed
// FeedsUpdate publishes a new update on the given feed
func (a *API) FeedsUpdate(ctx context.Context, request *feeds.Request) (storage.Address, error) {
return a.feeds.Update(ctx, request)
}

// FeedsHashSize returned the size of the digest produced by Swarm Feeds' hashing function
// FeedsHashSize returned the size of the digest produced by Swarm feeds' hashing function
func (a *API) FeedsHashSize() int {
return a.feeds.HashSize
}
Expand All @@ -992,7 +992,7 @@ var ErrCannotLoadFeedManifest = errors.New("Cannot load feed manifest")
// ErrNotAFeedManifest is returned when the address provided returned something other than a valid manifest
var ErrNotAFeedManifest = errors.New("Not a feed manifest")

// ResolveFeedManifest retrieves the Feed manifest for the given address, and returns the referenced Feed.
// ResolveFeedManifest retrieves the Swarm feed manifest for the given address, and returns the referenced Feed.
func (a *API) ResolveFeedManifest(ctx context.Context, addr storage.Address) (*feeds.Feed, error) {
trie, err := loadManifest(ctx, a.fileStore, addr, nil, NOOPDecrypt)
if err != nil {
Expand All @@ -1007,15 +1007,15 @@ func (a *API) ResolveFeedManifest(ctx context.Context, addr storage.Address) (*f
return entry.Feed, nil
}

// ErrCannotResolveFeedURI is returned when the ENS resolver is not able to translate a name to a Feed
// ErrCannotResolveFeedURI is returned when the ENS resolver is not able to translate a name to a Swarm feed
var ErrCannotResolveFeedURI = errors.New("Cannot resolve Feed URI")

// ErrCannotResolveFeed is returned when values provided are not enough or invalid to recreate a
// Feed out of them.
// feed out of them.
var ErrCannotResolveFeed = errors.New("Cannot resolve Feed")

// ResolveFeed attempts to extract Feed information out of the manifest, if provided
// If not, it attempts to extract the Feed out of a set of key-value pairs
// ResolveFeed attempts to extract feed information out of the manifest, if provided
// If not, it attempts to extract the feed out of a set of key-value pairs
func (a *API) ResolveFeed(ctx context.Context, uri *URI, values feeds.Values) (*feeds.Feed, error) {
var feed *feeds.Feed
var err error
Expand All @@ -1029,7 +1029,7 @@ func (a *API) ResolveFeed(ctx context.Context, uri *URI, values feeds.Values) (*
}
}

// get the Feed from the manifest
// get the Swarm feed from the manifest
feed, err = a.ResolveFeedManifest(ctx, manifestAddr)
if err != nil {
return nil, err
Expand Down
8 changes: 4 additions & 4 deletions swarm/api/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -604,9 +604,9 @@ func (c *Client) MultipartUpload(hash string, uploader Uploader) (string, error)
// ErrNoFeedUpdatesFound is returned when Swarm cannot find updates of the given feed
var ErrNoFeedUpdatesFound = errors.New("No updates found for this feed")

// CreateFeedWithManifest creates a Feed Manifest, initializing it with the provided
// CreateFeedWithManifest creates a feed manifest, initializing it with the provided
// data
// Returns the resulting Feed Manifest address that you can use to include in an ENS Resolver (setContent)
// Returns the resulting feed manifest address that you can use to include in an ENS Resolver (setContent)
// or reference future updates (Client.UpdateFeed)
func (c *Client) CreateFeedWithManifest(request *feeds.Request) (string, error) {
responseStream, err := c.updateFeed(request, true)
Expand Down Expand Up @@ -669,7 +669,7 @@ func (c *Client) QueryFeed(query *feeds.Query, manifestAddressOrDomain string) (
// queryFeed returns a byte stream with the raw content of the feed update
// manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver
// points to that address
// meta set to true will instruct the node return Feed metainformation instead
// meta set to true will instruct the node return feed metainformation instead
func (c *Client) queryFeed(query *feeds.Query, manifestAddressOrDomain string, meta bool) (io.ReadCloser, error) {
URL, err := url.Parse(c.Gateway)
if err != nil {
Expand Down Expand Up @@ -706,7 +706,7 @@ func (c *Client) queryFeed(query *feeds.Query, manifestAddressOrDomain string, m
return res.Body, nil
}

// GetFeedRequest returns a structure that describes the referenced Feed status
// GetFeedRequest returns a structure that describes the referenced feed status
// manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver
// points to that address
func (c *Client) GetFeedRequest(query *feeds.Query, manifestAddressOrDomain string) (*feeds.Request, error) {
Expand Down
4 changes: 2 additions & 2 deletions swarm/api/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) {
return
}
// the key to the manifest will be passed back to the client
// the client can access the Feed directly through its Feed member
// the client can access the feed directly through its Feed member
// the manifest key can be set as content in the resolver of the ENS name
outdata, err := json.Marshal(m)
if err != nil {
Expand All @@ -531,7 +531,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) {
}
}

// HandleGetFeed retrieves Swarm Feeds updates:
// HandleGetFeed retrieves Swarm feeds updates:
// bzz-feed://<manifest address or ENS name> - get latest feed update, given a manifest address
// - or -
// specify user + topic (optional), subtopic name (optional) directly, without manifest:
Expand Down
4 changes: 2 additions & 2 deletions swarm/api/http/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func TestBzzFeedMultihash(t *testing.T) {
}
}

// Test Swarm Feeds using the raw update methods
// Test Swarm feeds using the raw update methods
func TestBzzFeed(t *testing.T) {
srv := testutil.NewTestSwarmServer(t, serverFunc, nil)
signer, _ := newTestSigner()
Expand Down Expand Up @@ -305,7 +305,7 @@ func TestBzzFeed(t *testing.T) {
srv.CurrentTime++
log.Info("update 2")

// 1.- get metadata about this Feed
// 1.- get metadata about this feed
testBzzResUrl = fmt.Sprintf("%s/bzz-feed:/%s/", srv.URL, correctManifestAddrHex)
resp, err = http.Get(testBzzResUrl + "?meta=1")
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion swarm/api/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ func (a *API) NewManifest(ctx context.Context, toEncrypt bool) (storage.Address,
return addr, err
}

// Manifest hack for supporting Feeds from the bzz: scheme
// Manifest hack for supporting Swarm feeds from the bzz: scheme
// see swarm/api/api.go:API.Get() for more information
func (a *API) NewFeedManifest(ctx context.Context, feed *feeds.Feed) (storage.Address, error) {
var manifest Manifest
Expand Down
4 changes: 2 additions & 2 deletions swarm/network/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Using the streamer logic, various stream types are easy to implement:
* live session syncing
* historical syncing
* simple retrieve requests and deliveries
* Swarm Feeds streams
* swarm feeds streams
* receipting for finger pointing

## Syncing
Expand All @@ -57,7 +57,7 @@ receipts for a deleted chunk easily to refute their challenge.
- syncing should be resilient to cut connections, metadata should be persisted that
keep track of syncing state across sessions, historical syncing state should survive restart
- extra data structures to support syncing should be kept at minimum
- syncing is organized separately for chunk types (Swarm Feed Updates v regular content chunk)
- syncing is not organized separately for chunk types (Swarm feed updates v regular content chunk)
- various types of streams should have common logic abstracted

Syncing is now entirely mediated by the localstore, ie., no processes or memory leaks due to network contention.
Expand Down
4 changes: 2 additions & 2 deletions swarm/storage/feeds/cacheentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ const (
defaultRetrieveTimeout = 100 * time.Millisecond
)

// cacheEntry caches the last known update of a specific Feed.
// cacheEntry caches the last known update of a specific Swarm feed.
type cacheEntry struct {
Update
*bytes.Reader
Expand All @@ -42,7 +42,7 @@ func (r *cacheEntry) Size(ctx context.Context, _ chan bool) (int64, error) {
return int64(len(r.Update.data)), nil
}

//returns the Feed's topic
//returns the feed's topic
func (r *cacheEntry) Topic() Topic {
return r.Feed.Topic
}
4 changes: 2 additions & 2 deletions swarm/storage/feeds/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const (
ErrCnt
)

// Error is a the typed error object used for Swarm Feeds
// Error is a the typed error object used for Swarm feeds
type Error struct {
code int
err string
Expand All @@ -52,7 +52,7 @@ func (e *Error) Code() int {
return e.code
}

// NewError creates a new Swarm Feeds Error object with the specified code and custom error message
// NewError creates a new Swarm feeds Error object with the specified code and custom error message
func NewError(code int, s string) error {
if code < 0 || code >= ErrCnt {
panic("no such error code!")
Expand Down
10 changes: 5 additions & 5 deletions swarm/storage/feeds/feed.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/storage"
)

// Feed represents a particular user's stream of updates on a Topic
// Feed represents a particular user's stream of updates on a topic
type Feed struct {
Topic Topic `json:"topic"`
User common.Address `json:"user"`
Expand All @@ -48,10 +48,10 @@ func (f *Feed) mapKey() uint64 {
return *(*uint64)(unsafe.Pointer(&hash[0]))
}

// binaryPut serializes this Feed instance into the provided slice
// binaryPut serializes this feed instance into the provided slice
func (f *Feed) binaryPut(serializedData []byte) error {
if len(serializedData) != feedLength {
return NewErrorf(ErrInvalidValue, "Incorrect slice size to serialize Feed. Expected %d, got %d", feedLength, len(serializedData))
return NewErrorf(ErrInvalidValue, "Incorrect slice size to serialize feed. Expected %d, got %d", feedLength, len(serializedData))
}
var cursor int
copy(serializedData[cursor:cursor+TopicLength], f.Topic[:TopicLength])
Expand All @@ -71,7 +71,7 @@ func (f *Feed) binaryLength() int {
// binaryGet restores the current instance from the information contained in the passed slice
func (f *Feed) binaryGet(serializedData []byte) error {
if len(serializedData) != feedLength {
return NewErrorf(ErrInvalidValue, "Incorrect slice size to read Feed. Expected %d, got %d", feedLength, len(serializedData))
return NewErrorf(ErrInvalidValue, "Incorrect slice size to read feed. Expected %d, got %d", feedLength, len(serializedData))
}

var cursor int
Expand All @@ -84,7 +84,7 @@ func (f *Feed) binaryGet(serializedData []byte) error {
return nil
}

// Hex serializes the Feed to a hex string
// Hex serializes the feed to a hex string
func (f *Feed) Hex() string {
serializedData := make([]byte, feedLength)
f.binaryPut(serializedData)
Expand Down
12 changes: 6 additions & 6 deletions swarm/storage/feeds/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.

// Handler is the API for Feeds
// Handler is the API for feeds
// It enables creating, updating, syncing and retrieving feed updates and their data
package feeds

Expand Down Expand Up @@ -57,7 +57,7 @@ func init() {
}
}

// NewHandler creates a new Swarm Feeds API
// NewHandler creates a new Swarm feeds API
func NewHandler(params *HandlerParams) *Handler {
fh := &Handler{
cache: make(map[uint64]*cacheEntry),
Expand All @@ -74,7 +74,7 @@ func NewHandler(params *HandlerParams) *Handler {
return fh
}

// SetStore sets the store backend for the Swarm Feeds API
// SetStore sets the store backend for the Swarm feeds API
func (h *Handler) SetStore(store *storage.NetStore) {
h.chunkStore = store
}
Expand Down Expand Up @@ -110,7 +110,7 @@ func (h *Handler) Validate(chunkAddr storage.Address, data []byte) bool {
return true
}

// GetContent retrieves the data payload of the last synced update of the Feed
// GetContent retrieves the data payload of the last synced update of the feed
func (h *Handler) GetContent(feed *Feed) (storage.Address, []byte, error) {
if feed == nil {
return nil, nil, NewError(ErrInvalidValue, "feed is nil")
Expand Down Expand Up @@ -240,7 +240,7 @@ func (h *Handler) updateCache(request *Request) (*cacheEntry, error) {
}

// Update publishes a feed update
// Note that a Feed update cannot span chunks, and thus has a MAX NET LENGTH 4096, INCLUDING update header data and signature.
// Note that a feed update cannot span chunks, and thus has a MAX NET LENGTH 4096, INCLUDING update header data and signature.
// This results in a max payload of `maxUpdateDataLength` (check update.go for more details)
// An error will be returned if the total length of the chunk payload will exceed this limit.
// Update can only check if the caller is trying to overwrite the very last known version, otherwise it just puts the update
Expand Down Expand Up @@ -286,7 +286,7 @@ func (h *Handler) get(feed *Feed) *cacheEntry {
return feedUpdate
}

// Sets the feed update cache value for the given Feed
// Sets the feed update cache value for the given feed
func (h *Handler) set(feed *Feed, feedUpdate *cacheEntry) {
mapKey := feed.mapKey()
h.cacheLock.Lock()
Expand Down
14 changes: 7 additions & 7 deletions swarm/storage/feeds/handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,11 @@ func TestFeedsHandler(t *testing.T) {
}
defer teardownTest()

// create a new Feed
// create a new feed
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

topic, _ := NewTopic("Mess with Swarm Feeds code and see what ghost catches you", nil)
topic, _ := NewTopic("Mess with Swarm feeds code and see what ghost catches you", nil)
feed := Feed{
Topic: topic,
User: signer.Address(),
Expand Down Expand Up @@ -266,7 +266,7 @@ func TestSparseUpdates(t *testing.T) {
defer teardownTest()
defer os.RemoveAll(datadir)

// create a new Feed
// create a new feed
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
topic, _ := NewTopic("Very slow updates", nil)
Expand Down Expand Up @@ -348,7 +348,7 @@ func TestValidator(t *testing.T) {
}
defer teardownTest()

// create new Feed
// create new feed
topic, _ := NewTopic(subtopicName, nil)
feed := Feed{
Topic: topic,
Expand Down Expand Up @@ -382,7 +382,7 @@ func TestValidator(t *testing.T) {
}

// tests that the content address validator correctly checks the data
// tests that Feed update chunks are passed through content address validator
// tests that feed update chunks are passed through content address validator
// there is some redundancy in this test as it also tests content addressed chunks,
// which should be evaluated as invalid chunks by this validator
func TestValidatorInStore(t *testing.T) {
Expand All @@ -409,7 +409,7 @@ func TestValidatorInStore(t *testing.T) {
t.Fatal(err)
}

// set up Swarm Feeds handler and add is as a validator to the localstore
// set up Swarm feeds handler and add is as a validator to the localstore
fhParams := &HandlerParams{}
fh := NewHandler(fhParams)
store.Validators = append(store.Validators, fh)
Expand Down Expand Up @@ -463,7 +463,7 @@ func TestValidatorInStore(t *testing.T) {
}
}

// create rpc and Feeds Handler
// create rpc and feeds Handler
func setupTest(timeProvider timestampProvider, signer Signer) (fh *TestHandler, datadir string, teardown func(), err error) {

var fsClean func()
Expand Down
Loading

0 comments on commit 58c0879

Please sign in to comment.