diff options
author | Javier Peletier <jm@epiclabs.io> | 2018-09-30 15:51:11 +0800 |
---|---|---|
committer | Javier Peletier <jm@epiclabs.io> | 2018-10-03 15:12:06 +0800 |
commit | b6ccc06cdaac80d09da17c25b2f450cd1f1b7914 (patch) | |
tree | 2413da1a2025e901eecf253399fe4bfebbdd1925 /swarm | |
parent | 83705ef6aa3645a6305a400fa175e44904a929f7 (diff) | |
download | dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.gz dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.zst dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.zip |
swarm/storage/feeds: Final package rename and moved files
Diffstat (limited to 'swarm')
-rw-r--r-- | swarm/OWNERS | 2 | ||||
-rw-r--r-- | swarm/api/api.go | 27 | ||||
-rw-r--r-- | swarm/api/client/client.go | 18 | ||||
-rw-r--r-- | swarm/api/client/client_test.go | 22 | ||||
-rw-r--r-- | swarm/api/http/server.go | 10 | ||||
-rw-r--r-- | swarm/api/http/server_test.go | 20 | ||||
-rw-r--r-- | swarm/api/manifest.go | 6 | ||||
-rw-r--r-- | swarm/pss/notify/notify.go | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/binaryserializer.go (renamed from swarm/storage/mru/binaryserializer.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/binaryserializer_test.go (renamed from swarm/storage/mru/binaryserializer_test.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/cacheentry.go (renamed from swarm/storage/mru/cacheentry.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/doc.go (renamed from swarm/storage/mru/doc.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/error.go (renamed from swarm/storage/mru/error.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/feed.go (renamed from swarm/storage/mru/view.go) | 38 | ||||
-rw-r--r-- | swarm/storage/feeds/feed_test.go (renamed from swarm/storage/mru/view_test.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/handler.go (renamed from swarm/storage/mru/handler.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/handler_test.go (renamed from swarm/storage/mru/handler_test.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/id.go (renamed from swarm/storage/mru/id.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/id_test.go (renamed from swarm/storage/mru/id_test.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/lookup/epoch.go (renamed from swarm/storage/mru/lookup/epoch.go) | 0 | ||||
-rw-r--r-- | swarm/storage/feeds/lookup/epoch_test.go (renamed from swarm/storage/mru/lookup/epoch_test.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/lookup/lookup.go (renamed from swarm/storage/mru/lookup/lookup.go) | 0 | ||||
-rw-r--r-- | swarm/storage/feeds/lookup/lookup_test.go (renamed from swarm/storage/mru/lookup/lookup_test.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/query.go (renamed from swarm/storage/mru/query.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/query_test.go (renamed from swarm/storage/mru/query_test.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/request.go (renamed from swarm/storage/mru/request.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/request_test.go (renamed from swarm/storage/mru/request_test.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/sign.go (renamed from swarm/storage/mru/sign.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/testutil.go (renamed from swarm/storage/mru/testutil.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/timestampprovider.go (renamed from swarm/storage/mru/timestampprovider.go) | 4 | ||||
-rw-r--r-- | swarm/storage/feeds/topic.go (renamed from swarm/storage/mru/topic.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/topic_test.go (renamed from swarm/storage/mru/topic_test.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/update.go (renamed from swarm/storage/mru/update.go) | 2 | ||||
-rw-r--r-- | swarm/storage/feeds/update_test.go (renamed from swarm/storage/mru/update_test.go) | 2 | ||||
-rw-r--r-- | swarm/swarm.go | 8 | ||||
-rw-r--r-- | swarm/testutil/http.go | 12 |
36 files changed, 115 insertions, 114 deletions
diff --git a/swarm/OWNERS b/swarm/OWNERS index 774cd7db9..4681ed5ef 100644 --- a/swarm/OWNERS +++ b/swarm/OWNERS @@ -22,5 +22,5 @@ swarm ├── storage ─────────────── ethersphere │ ├── encryption ──────── @gbalint, @zelig, @nagydani │ ├── mock ────────────── @janos -│ └── mru ─────────────── @nolash +│ └── feeds ───────────── @nolash └── testutil ────────────── @lmars
\ No newline at end of file diff --git a/swarm/api/api.go b/swarm/api/api.go index 9b4571bee..c61bd8064 100644 --- a/swarm/api/api.go +++ b/swarm/api/api.go @@ -45,9 +45,10 @@ import ( "github.com/ethereum/go-ethereum/swarm/multihash" "github.com/ethereum/go-ethereum/swarm/spancontext" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" - "github.com/opentracing/opentracing-go" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" + + opentracing "github.com/opentracing/opentracing-go" ) var ( @@ -235,14 +236,14 @@ on top of the FileStore it is the public interface of the FileStore which is included in the ethereum stack */ type API struct { - feeds *mru.Handler + feeds *feeds.Handler fileStore *storage.FileStore dns Resolver Decryptor func(context.Context, string) DecryptFunc } // NewAPI the api constructor initialises a new API instance. -func NewAPI(fileStore *storage.FileStore, dns Resolver, feedsHandler *mru.Handler, pk *ecdsa.PrivateKey) (self *API) { +func NewAPI(fileStore *storage.FileStore, dns Resolver, feedsHandler *feeds.Handler, pk *ecdsa.PrivateKey) (self *API) { self = &API{ fileStore: fileStore, dns: dns, @@ -408,7 +409,7 @@ func (a *API) Get(ctx context.Context, decrypt DecryptFunc, manifestAddr storage if entry.Feed == nil { return reader, mimeType, status, nil, fmt.Errorf("Cannot decode Feed in manifest") } - _, err := a.feeds.Lookup(ctx, mru.NewQueryLatest(entry.Feed, lookup.NoClue)) + _, err := a.feeds.Lookup(ctx, feeds.NewQueryLatest(entry.Feed, lookup.NoClue)) if err != nil { apiGetNotFound.Inc(1) status = http.StatusNotFound @@ -957,7 +958,7 @@ func (a *API) BuildDirectoryTree(ctx context.Context, mhash string, nameresolver } // FeedsLookup finds Swarm Feeds Updates at specific points in time, or the latest update -func (a *API) FeedsLookup(ctx context.Context, query *mru.Query) ([]byte, error) { +func (a *API) FeedsLookup(ctx context.Context, query *feeds.Query) ([]byte, error) { _, err := a.feeds.Lookup(ctx, query) if err != nil { return nil, err @@ -971,12 +972,12 @@ func (a *API) FeedsLookup(ctx context.Context, query *mru.Query) ([]byte, error) } // FeedsNewRequest creates a Request object to update a specific Feed -func (a *API) FeedsNewRequest(ctx context.Context, feed *mru.Feed) (*mru.Request, error) { +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 -func (a *API) FeedsUpdate(ctx context.Context, request *mru.Request) (storage.Address, error) { +func (a *API) FeedsUpdate(ctx context.Context, request *feeds.Request) (storage.Address, error) { return a.feeds.Update(ctx, request) } @@ -992,7 +993,7 @@ var ErrCannotLoadFeedManifest = errors.New("Cannot load feed manifest") var ErrNotAFeedManifest = errors.New("Not a feed manifest") // ResolveFeedManifest retrieves the Feed manifest for the given address, and returns the referenced Feed. -func (a *API) ResolveFeedManifest(ctx context.Context, addr storage.Address) (*mru.Feed, error) { +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 { return nil, ErrCannotLoadFeedManifest @@ -1015,8 +1016,8 @@ 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 -func (a *API) ResolveFeed(ctx context.Context, uri *URI, values mru.Values) (*mru.Feed, error) { - var feed *mru.Feed +func (a *API) ResolveFeed(ctx context.Context, uri *URI, values feeds.Values) (*feeds.Feed, error) { + var feed *feeds.Feed var err error if uri.Addr != "" { // resolve the content key. @@ -1035,7 +1036,7 @@ func (a *API) ResolveFeed(ctx context.Context, uri *URI, values mru.Values) (*mr } log.Debug("handle.get.feed: resolved", "manifestkey", manifestAddr, "feed", feed.Hex()) } else { - var v mru.Feed + var v feeds.Feed if err := v.FromValues(values); err != nil { return nil, ErrCannotResolveFeed diff --git a/swarm/api/client/client.go b/swarm/api/client/client.go index 76ada1297..6b4614581 100644 --- a/swarm/api/client/client.go +++ b/swarm/api/client/client.go @@ -35,7 +35,7 @@ import ( "strings" "github.com/ethereum/go-ethereum/swarm/api" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" ) var ( @@ -608,7 +608,7 @@ var ErrNoFeedUpdatesFound = errors.New("No updates found for this feed") // data // 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 *mru.Request) (string, error) { +func (c *Client) CreateFeedWithManifest(request *feeds.Request) (string, error) { responseStream, err := c.updateFeed(request, true) if err != nil { return "", err @@ -628,12 +628,12 @@ func (c *Client) CreateFeedWithManifest(request *mru.Request) (string, error) { } // UpdateFeed allows you to set a new version of your content -func (c *Client) UpdateFeed(request *mru.Request) error { +func (c *Client) UpdateFeed(request *feeds.Request) error { _, err := c.updateFeed(request, false) return err } -func (c *Client) updateFeed(request *mru.Request, createManifest bool) (io.ReadCloser, error) { +func (c *Client) updateFeed(request *feeds.Request, createManifest bool) (io.ReadCloser, error) { URL, err := url.Parse(c.Gateway) if err != nil { return nil, err @@ -662,7 +662,7 @@ func (c *Client) updateFeed(request *mru.Request, createManifest bool) (io.ReadC // 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 -func (c *Client) QueryFeed(query *mru.Query, manifestAddressOrDomain string) (io.ReadCloser, error) { +func (c *Client) QueryFeed(query *feeds.Query, manifestAddressOrDomain string) (io.ReadCloser, error) { return c.queryFeed(query, manifestAddressOrDomain, false) } @@ -670,7 +670,7 @@ func (c *Client) QueryFeed(query *mru.Query, manifestAddressOrDomain string) (io // 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 -func (c *Client) queryFeed(query *mru.Query, manifestAddressOrDomain string, meta bool) (io.ReadCloser, error) { +func (c *Client) queryFeed(query *feeds.Query, manifestAddressOrDomain string, meta bool) (io.ReadCloser, error) { URL, err := url.Parse(c.Gateway) if err != nil { return nil, err @@ -706,10 +706,10 @@ func (c *Client) queryFeed(query *mru.Query, manifestAddressOrDomain string, met return res.Body, nil } -// GetFeedMetadata 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) GetFeedMetadata(query *mru.Query, manifestAddressOrDomain string) (*mru.Request, error) { +func (c *Client) GetFeedRequest(query *feeds.Query, manifestAddressOrDomain string) (*feeds.Request, error) { responseStream, err := c.queryFeed(query, manifestAddressOrDomain, true) if err != nil { @@ -722,7 +722,7 @@ func (c *Client) GetFeedMetadata(query *mru.Query, manifestAddressOrDomain strin return nil, err } - var metadata mru.Request + var metadata feeds.Request if err := metadata.UnmarshalJSON(body); err != nil { return nil, err } diff --git a/swarm/api/client/client_test.go b/swarm/api/client/client_test.go index fbc49a6e1..4fad7fbc7 100644 --- a/swarm/api/client/client_test.go +++ b/swarm/api/client/client_test.go @@ -25,14 +25,14 @@ import ( "sort" "testing" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/swarm/api" swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http" "github.com/ethereum/go-ethereum/swarm/multihash" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" "github.com/ethereum/go-ethereum/swarm/testutil" ) @@ -361,12 +361,12 @@ func TestClientMultipartUpload(t *testing.T) { } } -func newTestSigner() (*mru.GenericSigner, error) { +func newTestSigner() (*feeds.GenericSigner, error) { privKey, err := crypto.HexToECDSA("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef") if err != nil { return nil, err } - return mru.NewGenericSigner(privKey), nil + return feeds.NewGenericSigner(privKey), nil } // test the transparent resolving of multihash feed updates with bzz:// scheme @@ -394,9 +394,9 @@ func TestClientCreateFeedMultihash(t *testing.T) { mh := multihash.ToMultihash(s) // our feed topic - topic, _ := mru.NewTopic("foo.eth", nil) + topic, _ := feeds.NewTopic("foo.eth", nil) - createRequest := mru.NewFirstRequest(topic) + createRequest := feeds.NewFirstRequest(topic) createRequest.SetData(mh) if err := createRequest.Sign(signer); err != nil { @@ -448,8 +448,8 @@ func TestClientCreateUpdateFeed(t *testing.T) { databytes := []byte("En un lugar de La Mancha, de cuyo nombre no quiero acordarme...") // our feed topic name - topic, _ := mru.NewTopic("El Quijote", nil) - createRequest := mru.NewFirstRequest(topic) + topic, _ := feeds.NewTopic("El Quijote", nil) + createRequest := feeds.NewFirstRequest(topic) createRequest.SetData(databytes) if err := createRequest.Sign(signer); err != nil { @@ -479,7 +479,7 @@ func TestClientCreateUpdateFeed(t *testing.T) { // define different data databytes = []byte("... no ha mucho tiempo que vivía un hidalgo de los de lanza en astillero ...") - updateRequest, err := client.GetFeedMetadata(nil, correctManifestAddrHex) + updateRequest, err := client.GetFeedRequest(nil, correctManifestAddrHex) if err != nil { t.Fatalf("Error retrieving update request template: %s", err) } @@ -508,12 +508,12 @@ func TestClientCreateUpdateFeed(t *testing.T) { // now try retrieving feed updates without a manifest - feed := &mru.Feed{ + feed := &feeds.Feed{ Topic: topic, User: signer.Address(), } - lookupParams := mru.NewQueryLatest(feed, lookup.NoClue) + lookupParams := feeds.NewQueryLatest(feed, lookup.NoClue) reader, err = client.QueryFeed(lookupParams, "") if err != nil { t.Fatalf("Error retrieving feed updates: %s", err) diff --git a/swarm/api/http/server.go b/swarm/api/http/server.go index c5b3b564c..84e06d09f 100644 --- a/swarm/api/http/server.go +++ b/swarm/api/http/server.go @@ -40,7 +40,7 @@ import ( "github.com/ethereum/go-ethereum/swarm/api" "github.com/ethereum/go-ethereum/swarm/log" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" "github.com/rs/cors" ) @@ -466,7 +466,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) { log.Debug("handle.post.feed", "ruid", ruid) var err error - // Creation and update must send mru.updateRequestJSON JSON structure + // Creation and update must send feeds.updateRequestJSON JSON structure body, err := ioutil.ReadAll(r.Body) if err != nil { RespondError(w, r, err.Error(), http.StatusInternalServerError) @@ -484,7 +484,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) { return } - var updateRequest mru.Request + var updateRequest feeds.Request updateRequest.Feed = *feed query := r.URL.Query() @@ -582,7 +582,7 @@ func (s *Server) HandleGetFeed(w http.ResponseWriter, r *http.Request) { return } - lookupParams := &mru.Query{Feed: *feed} + lookupParams := &feeds.Query{Feed: *feed} if err = lookupParams.FromValues(r.URL.Query()); err != nil { // parse period, version RespondError(w, r, fmt.Sprintf("invalid feed update request:%s", err), http.StatusBadRequest) return @@ -606,7 +606,7 @@ func (s *Server) HandleGetFeed(w http.ResponseWriter, r *http.Request) { func (s *Server) translateFeedError(w http.ResponseWriter, r *http.Request, supErr string, err error) (int, error) { code := 0 defaultErr := fmt.Errorf("%s: %v", supErr, err) - rsrcErr, ok := err.(*mru.Error) + rsrcErr, ok := err.(*feeds.Error) if !ok && rsrcErr != nil { code = rsrcErr.Code() } diff --git a/swarm/api/http/server_test.go b/swarm/api/http/server_test.go index a7c7e3003..16813cab5 100644 --- a/swarm/api/http/server_test.go +++ b/swarm/api/http/server_test.go @@ -38,7 +38,7 @@ import ( "testing" "time" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" @@ -48,7 +48,7 @@ import ( swarm "github.com/ethereum/go-ethereum/swarm/api/client" "github.com/ethereum/go-ethereum/swarm/multihash" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" "github.com/ethereum/go-ethereum/swarm/testutil" ) @@ -62,12 +62,12 @@ func serverFunc(api *api.API) testutil.TestServer { return NewServer(api, "") } -func newTestSigner() (*mru.GenericSigner, error) { +func newTestSigner() (*feeds.GenericSigner, error) { privKey, err := crypto.HexToECDSA("deadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef") if err != nil { return nil, err } - return mru.NewGenericSigner(privKey), nil + return feeds.NewGenericSigner(privKey), nil } // test the transparent resolving of multihash-containing feed updates with bzz:// scheme @@ -103,8 +103,8 @@ func TestBzzFeedMultihash(t *testing.T) { log.Info("added data", "manifest", string(b), "data", common.ToHex(mh)) - topic, _ := mru.NewTopic("foo.eth", nil) - updateRequest := mru.NewFirstRequest(topic) + topic, _ := feeds.NewTopic("foo.eth", nil) + updateRequest := feeds.NewFirstRequest(topic) updateRequest.SetData(mh) @@ -182,8 +182,8 @@ func TestBzzFeed(t *testing.T) { //data for update 2 update2Data := []byte("foo") - topic, _ := mru.NewTopic("foo.eth", nil) - updateRequest := mru.NewFirstRequest(topic) + topic, _ := feeds.NewTopic("foo.eth", nil) + updateRequest := feeds.NewFirstRequest(topic) if err != nil { t.Fatal(err) } @@ -319,7 +319,7 @@ func TestBzzFeed(t *testing.T) { if err != nil { t.Fatal(err) } - updateRequest = &mru.Request{} + updateRequest = &feeds.Request{} if err = updateRequest.UnmarshalJSON(b); err != nil { t.Fatalf("Error decoding feed metadata: %s", err) } @@ -365,7 +365,7 @@ func TestBzzFeed(t *testing.T) { // test manifest-less queries log.Info("get first update in update1Timestamp via direct query") - query := mru.NewQuery(&updateRequest.Feed, update1Timestamp, lookup.NoClue) + query := feeds.NewQuery(&updateRequest.Feed, update1Timestamp, lookup.NoClue) urlq, err := url.Parse(fmt.Sprintf("%s/bzz-feed:/", srv.URL)) if err != nil { diff --git a/swarm/api/manifest.go b/swarm/api/manifest.go index f41a823bd..9ac3214a5 100644 --- a/swarm/api/manifest.go +++ b/swarm/api/manifest.go @@ -27,7 +27,7 @@ import ( "strings" "time" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/swarm/log" @@ -56,7 +56,7 @@ type ManifestEntry struct { ModTime time.Time `json:"mod_time,omitempty"` Status int `json:"status,omitempty"` Access *AccessEntry `json:"access,omitempty"` - Feed *mru.Feed `json:"feed,omitempty"` + Feed *feeds.Feed `json:"feed,omitempty"` } // ManifestList represents the result of listing files in a manifest @@ -82,7 +82,7 @@ func (a *API) NewManifest(ctx context.Context, toEncrypt bool) (storage.Address, // Manifest hack for supporting Feeds from the bzz: scheme // see swarm/api/api.go:API.Get() for more information -func (a *API) NewFeedManifest(ctx context.Context, feed *mru.Feed) (storage.Address, error) { +func (a *API) NewFeedManifest(ctx context.Context, feed *feeds.Feed) (storage.Address, error) { var manifest Manifest entry := ManifestEntry{ Feed: feed, diff --git a/swarm/pss/notify/notify.go b/swarm/pss/notify/notify.go index 723092c32..01ecb4ff9 100644 --- a/swarm/pss/notify/notify.go +++ b/swarm/pss/notify/notify.go @@ -317,7 +317,7 @@ func (c *Controller) handleStartMsg(msg *Msg, keyid string) (err error) { return err } - // TODO this is set to zero-length byte pending decision on protocol for initial message, whether it should include message or not, and how to trigger the initial message so that current state of MRU is sent upon subscription + // TODO this is set to zero-length byte pending decision on protocol for initial message, whether it should include message or not, and how to trigger the initial message so that current state of Swarm Feed is sent upon subscription notify := []byte{} replyMsg := NewMsg(MsgCodeNotifyWithKey, msg.namestring, make([]byte, len(notify)+symKeyLength)) copy(replyMsg.Payload, notify) diff --git a/swarm/storage/mru/binaryserializer.go b/swarm/storage/feeds/binaryserializer.go index 3123a82ee..ce146571b 100644 --- a/swarm/storage/mru/binaryserializer.go +++ b/swarm/storage/feeds/binaryserializer.go @@ -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/>. -package mru +package feeds import "github.com/ethereum/go-ethereum/common/hexutil" diff --git a/swarm/storage/mru/binaryserializer_test.go b/swarm/storage/feeds/binaryserializer_test.go index f524157d6..0c81e7f18 100644 --- a/swarm/storage/mru/binaryserializer_test.go +++ b/swarm/storage/feeds/binaryserializer_test.go @@ -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/>. -package mru +package feeds import ( "encoding/json" diff --git a/swarm/storage/mru/cacheentry.go b/swarm/storage/feeds/cacheentry.go index f6ed72818..7a2f87b56 100644 --- a/swarm/storage/mru/cacheentry.go +++ b/swarm/storage/feeds/cacheentry.go @@ -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/>. -package mru +package feeds import ( "bytes" diff --git a/swarm/storage/mru/doc.go b/swarm/storage/feeds/doc.go index 7ffd4a3c6..d1edf5d6d 100644 --- a/swarm/storage/mru/doc.go +++ b/swarm/storage/feeds/doc.go @@ -40,4 +40,4 @@ Request: Feed Update with signature Epoch: time slot where the update is stored */ -package mru +package feeds diff --git a/swarm/storage/mru/error.go b/swarm/storage/feeds/error.go index 452cc80f0..13266b900 100644 --- a/swarm/storage/mru/error.go +++ b/swarm/storage/feeds/error.go @@ -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/>. -package mru +package feeds import ( "fmt" @@ -47,7 +47,7 @@ func (e *Error) Error() string { } // Code returns the error code -// Error codes are enumerated in the error.go file within the mru package +// Error codes are enumerated in the error.go file within the feeds package func (e *Error) Code() int { return e.code } diff --git a/swarm/storage/mru/view.go b/swarm/storage/feeds/feed.go index 8d21ef7a4..8a807d506 100644 --- a/swarm/storage/mru/view.go +++ b/swarm/storage/feeds/feed.go @@ -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/>. -package mru +package feeds import ( "hash" @@ -37,9 +37,9 @@ type Feed struct { const feedLength = TopicLength + common.AddressLength // mapKey calculates a unique id for this feed. Used by the cache map in `Handler` -func (u *Feed) mapKey() uint64 { +func (f *Feed) mapKey() uint64 { serializedData := make([]byte, feedLength) - u.binaryPut(serializedData) + f.binaryPut(serializedData) hasher := hashPool.Get().(hash.Hash) defer hashPool.Put(hasher) hasher.Reset() @@ -49,54 +49,54 @@ func (u *Feed) mapKey() uint64 { } // binaryPut serializes this Feed instance into the provided slice -func (u *Feed) binaryPut(serializedData []byte) error { +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)) } var cursor int - copy(serializedData[cursor:cursor+TopicLength], u.Topic[:TopicLength]) + copy(serializedData[cursor:cursor+TopicLength], f.Topic[:TopicLength]) cursor += TopicLength - copy(serializedData[cursor:cursor+common.AddressLength], u.User[:]) + copy(serializedData[cursor:cursor+common.AddressLength], f.User[:]) cursor += common.AddressLength return nil } // binaryLength returns the expected size of this structure when serialized -func (u *Feed) binaryLength() int { +func (f *Feed) binaryLength() int { return feedLength } // binaryGet restores the current instance from the information contained in the passed slice -func (u *Feed) binaryGet(serializedData []byte) error { +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)) } var cursor int - copy(u.Topic[:], serializedData[cursor:cursor+TopicLength]) + copy(f.Topic[:], serializedData[cursor:cursor+TopicLength]) cursor += TopicLength - copy(u.User[:], serializedData[cursor:cursor+common.AddressLength]) + copy(f.User[:], serializedData[cursor:cursor+common.AddressLength]) cursor += common.AddressLength return nil } // Hex serializes the Feed to a hex string -func (u *Feed) Hex() string { +func (f *Feed) Hex() string { serializedData := make([]byte, feedLength) - u.binaryPut(serializedData) + f.binaryPut(serializedData) return hexutil.Encode(serializedData) } // FromValues deserializes this instance from a string key-value store // useful to parse query strings -func (u *Feed) FromValues(values Values) (err error) { +func (f *Feed) FromValues(values Values) (err error) { topic := values.Get("topic") if topic != "" { - if err := u.Topic.FromHex(values.Get("topic")); err != nil { + if err := f.Topic.FromHex(values.Get("topic")); err != nil { return err } } else { // see if the user set name and relatedcontent @@ -108,18 +108,18 @@ func (u *Feed) FromValues(values Values) (err error) { } relatedContent = relatedContent[:storage.AddressLength] } - u.Topic, err = NewTopic(name, relatedContent) + f.Topic, err = NewTopic(name, relatedContent) if err != nil { return err } } - u.User = common.HexToAddress(values.Get("user")) + f.User = common.HexToAddress(values.Get("user")) return nil } // AppendValues serializes this structure into the provided string key-value store // useful to build query strings -func (u *Feed) AppendValues(values Values) { - values.Set("topic", u.Topic.Hex()) - values.Set("user", u.User.Hex()) +func (f *Feed) AppendValues(values Values) { + values.Set("topic", f.Topic.Hex()) + values.Set("user", f.User.Hex()) } diff --git a/swarm/storage/mru/view_test.go b/swarm/storage/feeds/feed_test.go index e2f4d6b30..7806e0ad7 100644 --- a/swarm/storage/mru/view_test.go +++ b/swarm/storage/feeds/feed_test.go @@ -13,7 +13,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/>. -package mru +package feeds import ( "testing" diff --git a/swarm/storage/mru/handler.go b/swarm/storage/feeds/handler.go index cc0da7df9..9c69fd1b4 100644 --- a/swarm/storage/mru/handler.go +++ b/swarm/storage/feeds/handler.go @@ -16,7 +16,7 @@ // Handler is the API for Feeds // It enables creating, updating, syncing and retrieving feed updates and their data -package mru +package feeds import ( "bytes" @@ -25,7 +25,7 @@ import ( "sync" "time" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" "github.com/ethereum/go-ethereum/swarm/log" "github.com/ethereum/go-ethereum/swarm/storage" diff --git a/swarm/storage/mru/handler_test.go b/swarm/storage/feeds/handler_test.go index b66ff0c80..8331980ca 100644 --- a/swarm/storage/mru/handler_test.go +++ b/swarm/storage/feeds/handler_test.go @@ -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/>. -package mru +package feeds import ( "bytes" @@ -31,7 +31,7 @@ import ( "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/swarm/chunk" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) var ( diff --git a/swarm/storage/mru/id.go b/swarm/storage/feeds/id.go index dcc88ac2a..dd813ae89 100644 --- a/swarm/storage/mru/id.go +++ b/swarm/storage/feeds/id.go @@ -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/>. -package mru +package feeds import ( "fmt" @@ -22,7 +22,7 @@ import ( "strconv" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" "github.com/ethereum/go-ethereum/swarm/storage" ) diff --git a/swarm/storage/mru/id_test.go b/swarm/storage/feeds/id_test.go index 767b3c159..2ef12e891 100644 --- a/swarm/storage/mru/id_test.go +++ b/swarm/storage/feeds/id_test.go @@ -1,9 +1,9 @@ -package mru +package feeds import ( "testing" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) func getTestID() *ID { diff --git a/swarm/storage/mru/lookup/epoch.go b/swarm/storage/feeds/lookup/epoch.go index bafe95477..bafe95477 100644 --- a/swarm/storage/mru/lookup/epoch.go +++ b/swarm/storage/feeds/lookup/epoch.go diff --git a/swarm/storage/mru/lookup/epoch_test.go b/swarm/storage/feeds/lookup/epoch_test.go index 62cf5523d..70bfd836a 100644 --- a/swarm/storage/mru/lookup/epoch_test.go +++ b/swarm/storage/feeds/lookup/epoch_test.go @@ -3,7 +3,7 @@ package lookup_test import ( "testing" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) func TestMarshallers(t *testing.T) { diff --git a/swarm/storage/mru/lookup/lookup.go b/swarm/storage/feeds/lookup/lookup.go index a5154d261..a5154d261 100644 --- a/swarm/storage/mru/lookup/lookup.go +++ b/swarm/storage/feeds/lookup/lookup.go diff --git a/swarm/storage/mru/lookup/lookup_test.go b/swarm/storage/feeds/lookup/lookup_test.go index 34bcb61f0..7d5014608 100644 --- a/swarm/storage/mru/lookup/lookup_test.go +++ b/swarm/storage/feeds/lookup/lookup_test.go @@ -22,7 +22,7 @@ import ( "testing" "github.com/ethereum/go-ethereum/swarm/log" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) type Data struct { diff --git a/swarm/storage/mru/query.go b/swarm/storage/feeds/query.go index a0b358bfd..7bd2800a8 100644 --- a/swarm/storage/mru/query.go +++ b/swarm/storage/feeds/query.go @@ -14,14 +14,14 @@ // 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/>. -package mru +package feeds import ( "fmt" "strconv" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) // Query is used to specify constraints when performing an update lookup diff --git a/swarm/storage/mru/query_test.go b/swarm/storage/feeds/query_test.go index 4cfc597b2..1420c69ae 100644 --- a/swarm/storage/mru/query_test.go +++ b/swarm/storage/feeds/query_test.go @@ -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/>. -package mru +package feeds import ( "testing" diff --git a/swarm/storage/mru/request.go b/swarm/storage/feeds/request.go index ca88adda1..719d8fba8 100644 --- a/swarm/storage/mru/request.go +++ b/swarm/storage/feeds/request.go @@ -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/>. -package mru +package feeds import ( "bytes" @@ -24,7 +24,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) // Request represents a request to sign or signed Feed Update message diff --git a/swarm/storage/mru/request_test.go b/swarm/storage/feeds/request_test.go index 515de651c..2e3783834 100644 --- a/swarm/storage/mru/request_test.go +++ b/swarm/storage/feeds/request_test.go @@ -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/>. -package mru +package feeds import ( "bytes" @@ -26,7 +26,7 @@ import ( "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru/lookup" + "github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup" ) func areEqualJSON(s1, s2 string) (bool, error) { diff --git a/swarm/storage/mru/sign.go b/swarm/storage/feeds/sign.go index 03b0fa2b6..a69942f2b 100644 --- a/swarm/storage/mru/sign.go +++ b/swarm/storage/feeds/sign.go @@ -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/>. -package mru +package feeds import ( "crypto/ecdsa" diff --git a/swarm/storage/mru/testutil.go b/swarm/storage/feeds/testutil.go index 80e0d4cf0..879f73348 100644 --- a/swarm/storage/mru/testutil.go +++ b/swarm/storage/feeds/testutil.go @@ -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/>. -package mru +package feeds import ( "context" diff --git a/swarm/storage/mru/timestampprovider.go b/swarm/storage/feeds/timestampprovider.go index 6ac153213..f6aa0775c 100644 --- a/swarm/storage/mru/timestampprovider.go +++ b/swarm/storage/feeds/timestampprovider.go @@ -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/>. -package mru +package feeds import ( "encoding/binary" @@ -22,7 +22,7 @@ import ( "time" ) -// TimestampProvider sets the time source of the mru package +// TimestampProvider sets the time source of the feeds package var TimestampProvider timestampProvider = NewDefaultTimestampProvider() // Timestamp encodes a point in time as a Unix epoch diff --git a/swarm/storage/mru/topic.go b/swarm/storage/feeds/topic.go index b6adb4cd7..2dc8c18cd 100644 --- a/swarm/storage/mru/topic.go +++ b/swarm/storage/feeds/topic.go @@ -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/>. -package mru +package feeds import ( "bytes" diff --git a/swarm/storage/mru/topic_test.go b/swarm/storage/feeds/topic_test.go index dad7c7ddc..8994002d7 100644 --- a/swarm/storage/mru/topic_test.go +++ b/swarm/storage/feeds/topic_test.go @@ -1,4 +1,4 @@ -package mru +package feeds import ( "testing" diff --git a/swarm/storage/mru/update.go b/swarm/storage/feeds/update.go index f6e70b4d8..02bd37522 100644 --- a/swarm/storage/mru/update.go +++ b/swarm/storage/feeds/update.go @@ -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/>. -package mru +package feeds import ( "fmt" diff --git a/swarm/storage/mru/update_test.go b/swarm/storage/feeds/update_test.go index 62c401f3f..7763da0c8 100644 --- a/swarm/storage/mru/update_test.go +++ b/swarm/storage/feeds/update_test.go @@ -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/>. -package mru +package feeds import ( "testing" diff --git a/swarm/swarm.go b/swarm/swarm.go index 4d9bf724f..74c53dece 100644 --- a/swarm/swarm.go +++ b/swarm/swarm.go @@ -50,7 +50,7 @@ import ( "github.com/ethereum/go-ethereum/swarm/state" "github.com/ethereum/go-ethereum/swarm/storage" "github.com/ethereum/go-ethereum/swarm/storage/mock" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" "github.com/ethereum/go-ethereum/swarm/tracing" ) @@ -186,10 +186,10 @@ func NewSwarm(config *api.Config, mockStore *mock.NodeStore) (self *Swarm, err e // Swarm Hash Merklised Chunking for Arbitrary-length Document/File storage self.fileStore = storage.NewFileStore(self.netStore, self.config.FileStoreParams) - var feedsHandler *mru.Handler - fhParams := &mru.HandlerParams{} + var feedsHandler *feeds.Handler + fhParams := &feeds.HandlerParams{} - feedsHandler = mru.NewHandler(fhParams) + feedsHandler = feeds.NewHandler(fhParams) feedsHandler.SetStore(self.netStore) lstore.Validators = []storage.ChunkValidator{ diff --git a/swarm/testutil/http.go b/swarm/testutil/http.go index 2162da880..05b7c52e0 100644 --- a/swarm/testutil/http.go +++ b/swarm/testutil/http.go @@ -25,7 +25,7 @@ import ( "github.com/ethereum/go-ethereum/swarm/api" "github.com/ethereum/go-ethereum/swarm/storage" - "github.com/ethereum/go-ethereum/swarm/storage/mru" + "github.com/ethereum/go-ethereum/swarm/storage/feeds" ) type TestServer interface { @@ -54,8 +54,8 @@ func NewTestSwarmServer(t *testing.T, serverFunc func(*api.API) TestServer, reso t.Fatal(err) } - rhparams := &mru.HandlerParams{} - rh, err := mru.NewTestHandler(feedsDir, rhparams) + rhparams := &feeds.HandlerParams{} + rh, err := feeds.NewTestHandler(feedsDir, rhparams) if err != nil { t.Fatal(err) } @@ -75,7 +75,7 @@ func NewTestSwarmServer(t *testing.T, serverFunc func(*api.API) TestServer, reso }, CurrentTime: 42, } - mru.TimestampProvider = tss + feeds.TimestampProvider = tss return tss } @@ -92,6 +92,6 @@ func (t *TestSwarmServer) Close() { t.cleanup() } -func (t *TestSwarmServer) Now() mru.Timestamp { - return mru.Timestamp{Time: t.CurrentTime} +func (t *TestSwarmServer) Now() feeds.Timestamp { + return feeds.Timestamp{Time: t.CurrentTime} } |