Skip to content

Commit

Permalink
swarm/storage/mru: Renamed all identifiers to Feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
jpeletier committed Oct 3, 2018
1 parent bd1f7eb commit f1e86ad
Show file tree
Hide file tree
Showing 24 changed files with 236 additions and 236 deletions.
4 changes: 2 additions & 2 deletions cmd/swarm/mru.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 resource allows the user to create and update signed mutable resource updates
// Command resource allows the user to create and update signed Swarm Feeds
package main

import (
Expand Down Expand Up @@ -66,7 +66,7 @@ func resourceCreate(ctx *cli.Context) {
)

newResourceRequest := mru.NewFirstRequest(getTopic(ctx))
newResourceRequest.View.User = resourceGetUser(ctx)
newResourceRequest.Feed.User = resourceGetUser(ctx)

manifestAddress, err := client.CreateResource(newResourceRequest)
if err != nil {
Expand Down
6 changes: 3 additions & 3 deletions cmd/swarm/mru_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestCLIResourceUpdate(t *testing.T) {
}

// View configures whose updates we will be looking up.
view := mru.View{
view := mru.Feed{
Topic: topic,
User: address,
}
Expand Down Expand Up @@ -146,8 +146,8 @@ func TestCLIResourceUpdate(t *testing.T) {
}

// make sure the retrieved view is the same
if request.View != view {
t.Fatalf("Expected view to be: %s, got %s", view, request.View)
if request.Feed != view {
t.Fatalf("Expected view to be: %s, got %s", view, request.Feed)
}

// test publishing a manifest
Expand Down
14 changes: 7 additions & 7 deletions swarm/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -956,22 +956,22 @@ func (a *API) BuildDirectoryTree(ctx context.Context, mhash string, nameresolver
return addr, manifestEntryMap, nil
}

// ResourceLookup finds mutable resource updates at specific periods and versions
// ResourceLookup finds Swarm Feeds at specific periods and versions
func (a *API) ResourceLookup(ctx context.Context, query *mru.Query) ([]byte, error) {
_, err := a.resource.Lookup(ctx, query)
if err != nil {
return nil, err
}
var data []byte
_, data, err = a.resource.GetContent(&query.View)
_, data, err = a.resource.GetContent(&query.Feed)
if err != nil {
return nil, err
}
return data, nil
}

// ResourceNewRequest creates a Request object to update a specific mutable resource
func (a *API) ResourceNewRequest(ctx context.Context, view *mru.View) (*mru.Request, error) {
func (a *API) ResourceNewRequest(ctx context.Context, view *mru.Feed) (*mru.Request, error) {
return a.resource.NewRequest(ctx, view)
}

Expand All @@ -993,7 +993,7 @@ var ErrCannotLoadResourceManifest = errors.New("Cannot load resource manifest")
var ErrNotAResourceManifest = errors.New("Not a resource manifest")

// ResolveResourceManifest retrieves the Mutable Resource manifest for the given address, and returns the Resource's view ID.
func (a *API) ResolveResourceManifest(ctx context.Context, addr storage.Address) (*mru.View, error) {
func (a *API) ResolveResourceManifest(ctx context.Context, addr storage.Address) (*mru.Feed, error) {
trie, err := loadManifest(ctx, a.fileStore, addr, nil, NOOPDecrypt)
if err != nil {
return nil, ErrCannotLoadResourceManifest
Expand All @@ -1016,8 +1016,8 @@ var ErrCannotResolveResourceView = errors.New("Cannot resolve resource view")

// ResolveResourceView attempts to extract View information out of the manifest, if provided
// If not, it attempts to extract the View out of a set of key-value pairs
func (a *API) ResolveResourceView(ctx context.Context, uri *URI, values mru.Values) (*mru.View, error) {
var view *mru.View
func (a *API) ResolveResourceView(ctx context.Context, uri *URI, values mru.Values) (*mru.Feed, error) {
var view *mru.Feed
var err error
if uri.Addr != "" {
// resolve the content key.
Expand All @@ -1036,7 +1036,7 @@ func (a *API) ResolveResourceView(ctx context.Context, uri *URI, values mru.Valu
}
log.Debug("handle.get.resource: resolved", "manifestkey", manifestAddr, "view", view.Hex())
} else {
var v mru.View
var v mru.Feed
if err := v.FromValues(values); err != nil {
return nil, ErrCannotResolveResourceView

Expand Down
2 changes: 1 addition & 1 deletion swarm/api/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ func TestClientCreateUpdateResource(t *testing.T) {

// now try retrieving resource without a manifest

view := &mru.View{
view := &mru.Feed{
Topic: topic,
User: signer.Address(),
}
Expand Down
8 changes: 4 additions & 4 deletions swarm/api/http/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ func (s *Server) HandlePostResource(w http.ResponseWriter, r *http.Request) {
}

var updateRequest mru.Request
updateRequest.View = *view
updateRequest.Feed = *view
query := r.URL.Query()

if err := updateRequest.FromValues(query, body); err != nil { // decodes request from query parameters
Expand All @@ -544,7 +544,7 @@ func (s *Server) HandlePostResource(w http.ResponseWriter, r *http.Request) {
// we create a manifest so we can retrieve the resource with bzz:// later
// this manifest has a special "resource type" manifest, and saves the
// resource view ID used to retrieve the resource later
m, err := s.api.NewResourceManifest(r.Context(), &updateRequest.View)
m, err := s.api.NewResourceManifest(r.Context(), &updateRequest.Feed)
if err != nil {
RespondError(w, r, fmt.Sprintf("failed to create resource manifest: %v", err), http.StatusInternalServerError)
return
Expand All @@ -563,7 +563,7 @@ func (s *Server) HandlePostResource(w http.ResponseWriter, r *http.Request) {
}
}

// Retrieve mutable resource updates:
// Retrieve Swarm Feeds:
// bzz-resource://<id> - get latest update
// bzz-resource://<id>/?period=n - get latest update on period n
// bzz-resource://<id>/?period=n&version=m - get update version m of period n
Expand Down Expand Up @@ -606,7 +606,7 @@ func (s *Server) HandleGetResource(w http.ResponseWriter, r *http.Request) {
return
}

lookupParams := &mru.Query{View: *view}
lookupParams := &mru.Query{Feed: *view}
if err = lookupParams.FromValues(r.URL.Query()); err != nil { // parse period, version
RespondError(w, r, fmt.Sprintf("invalid mutable resource request:%s", err), http.StatusBadRequest)
return
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 @@ -206,7 +206,7 @@ func TestBzzResourceMultihash(t *testing.T) {
}
}

// Test resource updates using the raw update methods
// Test Swarm Feeds using the raw update methods
func TestBzzResource(t *testing.T) {
srv := testutil.NewTestSwarmServer(t, serverFunc, nil)
signer, _ := newTestSigner()
Expand Down Expand Up @@ -406,7 +406,7 @@ func TestBzzResource(t *testing.T) {

// test manifest-less queries
log.Info("get first update in update1Timestamp via direct query")
query := mru.NewQuery(&updateRequest.View, update1Timestamp, lookup.NoClue)
query := mru.NewQuery(&updateRequest.Feed, update1Timestamp, lookup.NoClue)

urlq, err := url.Parse(fmt.Sprintf("%s/bzz-resource:/", srv.URL))
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions swarm/api/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ type ManifestEntry struct {
ModTime time.Time `json:"mod_time,omitempty"`
Status int `json:"status,omitempty"`
Access *AccessEntry `json:"access,omitempty"`
ResourceView *mru.View `json:"resourceView,omitempty"`
ResourceView *mru.Feed `json:"resourceView,omitempty"`
}

// ManifestList represents the result of listing files in a manifest
Expand All @@ -82,7 +82,7 @@ func (a *API) NewManifest(ctx context.Context, toEncrypt bool) (storage.Address,

// Manifest hack for supporting Mutable Resource Updates from the bzz: scheme
// see swarm/api/api.go:API.Get() for more information
func (a *API) NewResourceManifest(ctx context.Context, view *mru.View) (storage.Address, error) {
func (a *API) NewResourceManifest(ctx context.Context, view *mru.Feed) (storage.Address, error) {
var manifest Manifest
entry := ManifestEntry{
ResourceView: view,
Expand Down
2 changes: 1 addition & 1 deletion 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
* mutable resource updates streams
* Swarm Feeds streams
* receipting for finger pointing

## Syncing
Expand Down
8 changes: 4 additions & 4 deletions swarm/storage/mru/cacheentry.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ import (

const (
hasherCount = 8
resourceHashAlgorithm = storage.SHA3Hash
feedsHashAlgorithm = storage.SHA3Hash
defaultRetrieveTimeout = 100 * time.Millisecond
)

// cacheEntry caches resource data and the metadata of its root chunk.
type cacheEntry struct {
ResourceUpdate
Update
*bytes.Reader
lastKey storage.Address
}

// implements storage.LazySectionReader
func (r *cacheEntry) Size(ctx context.Context, _ chan bool) (int64, error) {
return int64(len(r.ResourceUpdate.data)), nil
return int64(len(r.Update.data)), nil
}

//returns the resource's topic
func (r *cacheEntry) Topic() Topic {
return r.View.Topic
return r.Feed.Topic
}
2 changes: 1 addition & 1 deletion swarm/storage/mru/doc.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
Package mru defines Mutable resource updates.
Package feeds defines Swarm Feeds.
A Mutable Resource is an entity which allows updates to a resource
without resorting to ENS on each update.
Expand Down
Loading

0 comments on commit f1e86ad

Please sign in to comment.