Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
58c0879c
Commit
58c0879c
authored
Oct 02, 2018
by
Javier Peletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
swarm/storage/feeds: removed capital Feed throughout
parent
68b8088c
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
60 additions
and
60 deletions
+60
-60
feeds.go
cmd/swarm/feeds.go
+1
-1
feeds_test.go
cmd/swarm/feeds_test.go
+1
-1
main.go
cmd/swarm/main.go
+4
-4
api.go
swarm/api/api.go
+11
-11
client.go
swarm/api/client/client.go
+4
-4
server.go
swarm/api/http/server.go
+2
-2
server_test.go
swarm/api/http/server_test.go
+2
-2
manifest.go
swarm/api/manifest.go
+1
-1
README.md
swarm/network/README.md
+2
-2
cacheentry.go
swarm/storage/feeds/cacheentry.go
+2
-2
error.go
swarm/storage/feeds/error.go
+2
-2
feed.go
swarm/storage/feeds/feed.go
+5
-5
handler.go
swarm/storage/feeds/handler.go
+6
-6
handler_test.go
swarm/storage/feeds/handler_test.go
+7
-7
lookup.go
swarm/storage/feeds/lookup/lookup.go
+1
-1
request.go
swarm/storage/feeds/request.go
+1
-1
request_test.go
swarm/storage/feeds/request_test.go
+4
-4
sign.go
swarm/storage/feeds/sign.go
+2
-2
localstore_test.go
swarm/storage/localstore_test.go
+1
-1
http.go
swarm/testutil/http.go
+1
-1
No files found.
cmd/swarm/feeds.go
View file @
58c0879c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// You should have received a copy of the GNU General Public License
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
// Command feed allows the user to create and update signed Swarm
F
eeds
// Command feed allows the user to create and update signed Swarm
f
eeds
package
main
package
main
import
(
import
(
...
...
cmd/swarm/feeds_test.go
View file @
58c0879c
...
@@ -145,7 +145,7 @@ func TestCLIFeedUpdate(t *testing.T) {
...
@@ -145,7 +145,7 @@ func TestCLIFeedUpdate(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// make sure the retrieved
F
eed is the same
// make sure the retrieved
f
eed is the same
if
request
.
Feed
!=
feed
{
if
request
.
Feed
!=
feed
{
t
.
Fatalf
(
"Expected feed to be: %s, got %s"
,
feed
,
request
.
Feed
)
t
.
Fatalf
(
"Expected feed to be: %s, got %s"
,
feed
,
request
.
Feed
)
}
}
...
...
cmd/swarm/main.go
View file @
58c0879c
...
@@ -355,8 +355,8 @@ func init() {
...
@@ -355,8 +355,8 @@ func init() {
Action
:
feedCreateManifest
,
Action
:
feedCreateManifest
,
CustomHelpTemplate
:
helpTemplate
,
CustomHelpTemplate
:
helpTemplate
,
Name
:
"create"
,
Name
:
"create"
,
Usage
:
"creates and publishes a new
F
eed manifest"
,
Usage
:
"creates and publishes a new
f
eed manifest"
,
Description
:
`creates and publishes a new
F
eed manifest pointing to a specified user's updates about a particular topic.
Description
:
`creates and publishes a new
f
eed manifest pointing to a specified user's updates about a particular topic.
The feed topic can be built in the following ways:
The feed topic can be built in the following ways:
* use --topic to set the topic to an arbitrary binary hex string.
* use --topic to set the topic to an arbitrary binary hex string.
* use --name to set the topic to a human-readable name.
* use --name to set the topic to a human-readable name.
...
@@ -392,8 +392,8 @@ func init() {
...
@@ -392,8 +392,8 @@ func init() {
Action
:
feedInfo
,
Action
:
feedInfo
,
CustomHelpTemplate
:
helpTemplate
,
CustomHelpTemplate
:
helpTemplate
,
Name
:
"info"
,
Name
:
"info"
,
Usage
:
"obtains information about an existing Swarm
F
eed"
,
Usage
:
"obtains information about an existing Swarm
f
eed"
,
Description
:
`obtains information about an existing Swarm
F
eed
Description
:
`obtains information about an existing Swarm
f
eed
The topic can be specified directly with the --topic flag as an hex string
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
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.
The --name flag can be used to specify subtopics with a specific name.
...
...
swarm/api/api.go
View file @
58c0879c
...
@@ -404,7 +404,7 @@ func (a *API) Get(ctx context.Context, decrypt DecryptFunc, manifestAddr storage
...
@@ -404,7 +404,7 @@ func (a *API) Get(ctx context.Context, decrypt DecryptFunc, manifestAddr storage
return
a
.
Get
(
ctx
,
decrypt
,
adr
,
entry
.
Path
)
return
a
.
Get
(
ctx
,
decrypt
,
adr
,
entry
.
Path
)
}
}
// we need to do some extra work if this is a
F
eed manifest
// we need to do some extra work if this is a
Swarm f
eed manifest
if
entry
.
ContentType
==
FeedContentType
{
if
entry
.
ContentType
==
FeedContentType
{
if
entry
.
Feed
==
nil
{
if
entry
.
Feed
==
nil
{
return
reader
,
mimeType
,
status
,
nil
,
fmt
.
Errorf
(
"Cannot decode Feed in manifest"
)
return
reader
,
mimeType
,
status
,
nil
,
fmt
.
Errorf
(
"Cannot decode Feed in manifest"
)
...
@@ -957,7 +957,7 @@ func (a *API) BuildDirectoryTree(ctx context.Context, mhash string, nameresolver
...
@@ -957,7 +957,7 @@ func (a *API) BuildDirectoryTree(ctx context.Context, mhash string, nameresolver
return
addr
,
manifestEntryMap
,
nil
return
addr
,
manifestEntryMap
,
nil
}
}
// FeedsLookup finds Swarm
Feeds U
pdates at specific points in time, or the latest update
// FeedsLookup finds Swarm
feeds u
pdates at specific points in time, or the latest update
func
(
a
*
API
)
FeedsLookup
(
ctx
context
.
Context
,
query
*
feeds
.
Query
)
([]
byte
,
error
)
{
func
(
a
*
API
)
FeedsLookup
(
ctx
context
.
Context
,
query
*
feeds
.
Query
)
([]
byte
,
error
)
{
_
,
err
:=
a
.
feeds
.
Lookup
(
ctx
,
query
)
_
,
err
:=
a
.
feeds
.
Lookup
(
ctx
,
query
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -971,17 +971,17 @@ func (a *API) FeedsLookup(ctx context.Context, query *feeds.Query) ([]byte, erro
...
@@ -971,17 +971,17 @@ func (a *API) FeedsLookup(ctx context.Context, query *feeds.Query) ([]byte, erro
return
data
,
nil
return
data
,
nil
}
}
// FeedsNewRequest creates a Request object to update a specific
F
eed
// FeedsNewRequest creates a Request object to update a specific
f
eed
func
(
a
*
API
)
FeedsNewRequest
(
ctx
context
.
Context
,
feed
*
feeds
.
Feed
)
(
*
feeds
.
Request
,
error
)
{
func
(
a
*
API
)
FeedsNewRequest
(
ctx
context
.
Context
,
feed
*
feeds
.
Feed
)
(
*
feeds
.
Request
,
error
)
{
return
a
.
feeds
.
NewRequest
(
ctx
,
feed
)
return
a
.
feeds
.
NewRequest
(
ctx
,
feed
)
}
}
// FeedsUpdate publishes a new update on the given
F
eed
// FeedsUpdate publishes a new update on the given
f
eed
func
(
a
*
API
)
FeedsUpdate
(
ctx
context
.
Context
,
request
*
feeds
.
Request
)
(
storage
.
Address
,
error
)
{
func
(
a
*
API
)
FeedsUpdate
(
ctx
context
.
Context
,
request
*
feeds
.
Request
)
(
storage
.
Address
,
error
)
{
return
a
.
feeds
.
Update
(
ctx
,
request
)
return
a
.
feeds
.
Update
(
ctx
,
request
)
}
}
// FeedsHashSize returned the size of the digest produced by Swarm
F
eeds' hashing function
// FeedsHashSize returned the size of the digest produced by Swarm
f
eeds' hashing function
func
(
a
*
API
)
FeedsHashSize
()
int
{
func
(
a
*
API
)
FeedsHashSize
()
int
{
return
a
.
feeds
.
HashSize
return
a
.
feeds
.
HashSize
}
}
...
@@ -992,7 +992,7 @@ var ErrCannotLoadFeedManifest = errors.New("Cannot load feed manifest")
...
@@ -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
// ErrNotAFeedManifest is returned when the address provided returned something other than a valid manifest
var
ErrNotAFeedManifest
=
errors
.
New
(
"Not a feed manifest"
)
var
ErrNotAFeedManifest
=
errors
.
New
(
"Not a feed manifest"
)
// ResolveFeedManifest retrieves the
F
eed manifest for the given address, and returns the referenced Feed.
// ResolveFeedManifest retrieves the
Swarm f
eed manifest for the given address, and returns the referenced Feed.
func
(
a
*
API
)
ResolveFeedManifest
(
ctx
context
.
Context
,
addr
storage
.
Address
)
(
*
feeds
.
Feed
,
error
)
{
func
(
a
*
API
)
ResolveFeedManifest
(
ctx
context
.
Context
,
addr
storage
.
Address
)
(
*
feeds
.
Feed
,
error
)
{
trie
,
err
:=
loadManifest
(
ctx
,
a
.
fileStore
,
addr
,
nil
,
NOOPDecrypt
)
trie
,
err
:=
loadManifest
(
ctx
,
a
.
fileStore
,
addr
,
nil
,
NOOPDecrypt
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -1007,15 +1007,15 @@ func (a *API) ResolveFeedManifest(ctx context.Context, addr storage.Address) (*f
...
@@ -1007,15 +1007,15 @@ func (a *API) ResolveFeedManifest(ctx context.Context, addr storage.Address) (*f
return
entry
.
Feed
,
nil
return
entry
.
Feed
,
nil
}
}
// ErrCannotResolveFeedURI is returned when the ENS resolver is not able to translate a name to a
F
eed
// ErrCannotResolveFeedURI is returned when the ENS resolver is not able to translate a name to a
Swarm f
eed
var
ErrCannotResolveFeedURI
=
errors
.
New
(
"Cannot resolve Feed URI"
)
var
ErrCannotResolveFeedURI
=
errors
.
New
(
"Cannot resolve Feed URI"
)
// ErrCannotResolveFeed is returned when values provided are not enough or invalid to recreate a
// ErrCannotResolveFeed is returned when values provided are not enough or invalid to recreate a
//
F
eed out of them.
//
f
eed out of them.
var
ErrCannotResolveFeed
=
errors
.
New
(
"Cannot resolve Feed"
)
var
ErrCannotResolveFeed
=
errors
.
New
(
"Cannot resolve Feed"
)
// ResolveFeed attempts to extract
F
eed information out of the manifest, if provided
// ResolveFeed attempts to extract
f
eed information out of the manifest, if provided
// If not, it attempts to extract the
F
eed out of a set of key-value pairs
// If not, it attempts to extract the
f
eed out of a set of key-value pairs
func
(
a
*
API
)
ResolveFeed
(
ctx
context
.
Context
,
uri
*
URI
,
values
feeds
.
Values
)
(
*
feeds
.
Feed
,
error
)
{
func
(
a
*
API
)
ResolveFeed
(
ctx
context
.
Context
,
uri
*
URI
,
values
feeds
.
Values
)
(
*
feeds
.
Feed
,
error
)
{
var
feed
*
feeds
.
Feed
var
feed
*
feeds
.
Feed
var
err
error
var
err
error
...
@@ -1029,7 +1029,7 @@ func (a *API) ResolveFeed(ctx context.Context, uri *URI, values feeds.Values) (*
...
@@ -1029,7 +1029,7 @@ func (a *API) ResolveFeed(ctx context.Context, uri *URI, values feeds.Values) (*
}
}
}
}
// get the
F
eed from the manifest
// get the
Swarm f
eed from the manifest
feed
,
err
=
a
.
ResolveFeedManifest
(
ctx
,
manifestAddr
)
feed
,
err
=
a
.
ResolveFeedManifest
(
ctx
,
manifestAddr
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
...
...
swarm/api/client/client.go
View file @
58c0879c
...
@@ -604,9 +604,9 @@ func (c *Client) MultipartUpload(hash string, uploader Uploader) (string, error)
...
@@ -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
// ErrNoFeedUpdatesFound is returned when Swarm cannot find updates of the given feed
var
ErrNoFeedUpdatesFound
=
errors
.
New
(
"No updates found for this feed"
)
var
ErrNoFeedUpdatesFound
=
errors
.
New
(
"No updates found for this feed"
)
// CreateFeedWithManifest creates a
Feed M
anifest, initializing it with the provided
// CreateFeedWithManifest creates a
feed m
anifest, initializing it with the provided
// data
// data
// Returns the resulting
Feed M
anifest address that you can use to include in an ENS Resolver (setContent)
// Returns the resulting
feed m
anifest address that you can use to include in an ENS Resolver (setContent)
// or reference future updates (Client.UpdateFeed)
// or reference future updates (Client.UpdateFeed)
func
(
c
*
Client
)
CreateFeedWithManifest
(
request
*
feeds
.
Request
)
(
string
,
error
)
{
func
(
c
*
Client
)
CreateFeedWithManifest
(
request
*
feeds
.
Request
)
(
string
,
error
)
{
responseStream
,
err
:=
c
.
updateFeed
(
request
,
true
)
responseStream
,
err
:=
c
.
updateFeed
(
request
,
true
)
...
@@ -669,7 +669,7 @@ func (c *Client) QueryFeed(query *feeds.Query, manifestAddressOrDomain string) (
...
@@ -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
// 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
// manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver
// points to that address
// points to that address
// meta set to true will instruct the node return
F
eed metainformation instead
// meta set to true will instruct the node return
f
eed metainformation instead
func
(
c
*
Client
)
queryFeed
(
query
*
feeds
.
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
)
URL
,
err
:=
url
.
Parse
(
c
.
Gateway
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -706,7 +706,7 @@ func (c *Client) queryFeed(query *feeds.Query, manifestAddressOrDomain string, m
...
@@ -706,7 +706,7 @@ func (c *Client) queryFeed(query *feeds.Query, manifestAddressOrDomain string, m
return
res
.
Body
,
nil
return
res
.
Body
,
nil
}
}
// GetFeedRequest returns a structure that describes the referenced
F
eed status
// GetFeedRequest returns a structure that describes the referenced
f
eed status
// manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver
// manifestAddressOrDomain is the address you obtained in CreateFeedWithManifest or an ENS domain whose Resolver
// points to that address
// points to that address
func
(
c
*
Client
)
GetFeedRequest
(
query
*
feeds
.
Query
,
manifestAddressOrDomain
string
)
(
*
feeds
.
Request
,
error
)
{
func
(
c
*
Client
)
GetFeedRequest
(
query
*
feeds
.
Query
,
manifestAddressOrDomain
string
)
(
*
feeds
.
Request
,
error
)
{
...
...
swarm/api/http/server.go
View file @
58c0879c
...
@@ -518,7 +518,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) {
...
@@ -518,7 +518,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) {
return
return
}
}
// the key to the manifest will be passed back to the client
// the key to the manifest will be passed back to the client
// the client can access the
F
eed directly through its Feed member
// the client can access the
f
eed directly through its Feed member
// the manifest key can be set as content in the resolver of the ENS name
// the manifest key can be set as content in the resolver of the ENS name
outdata
,
err
:=
json
.
Marshal
(
m
)
outdata
,
err
:=
json
.
Marshal
(
m
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -531,7 +531,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) {
...
@@ -531,7 +531,7 @@ func (s *Server) HandlePostFeed(w http.ResponseWriter, r *http.Request) {
}
}
}
}
// HandleGetFeed retrieves Swarm
F
eeds updates:
// HandleGetFeed retrieves Swarm
f
eeds updates:
// bzz-feed://<manifest address or ENS name> - get latest feed update, given a manifest address
// bzz-feed://<manifest address or ENS name> - get latest feed update, given a manifest address
// - or -
// - or -
// specify user + topic (optional), subtopic name (optional) directly, without manifest:
// specify user + topic (optional), subtopic name (optional) directly, without manifest:
...
...
swarm/api/http/server_test.go
View file @
58c0879c
...
@@ -165,7 +165,7 @@ func TestBzzFeedMultihash(t *testing.T) {
...
@@ -165,7 +165,7 @@ func TestBzzFeedMultihash(t *testing.T) {
}
}
}
}
// Test Swarm
F
eeds using the raw update methods
// Test Swarm
f
eeds using the raw update methods
func
TestBzzFeed
(
t
*
testing
.
T
)
{
func
TestBzzFeed
(
t
*
testing
.
T
)
{
srv
:=
testutil
.
NewTestSwarmServer
(
t
,
serverFunc
,
nil
)
srv
:=
testutil
.
NewTestSwarmServer
(
t
,
serverFunc
,
nil
)
signer
,
_
:=
newTestSigner
()
signer
,
_
:=
newTestSigner
()
...
@@ -305,7 +305,7 @@ func TestBzzFeed(t *testing.T) {
...
@@ -305,7 +305,7 @@ func TestBzzFeed(t *testing.T) {
srv
.
CurrentTime
++
srv
.
CurrentTime
++
log
.
Info
(
"update 2"
)
log
.
Info
(
"update 2"
)
// 1.- get metadata about this
F
eed
// 1.- get metadata about this
f
eed
testBzzResUrl
=
fmt
.
Sprintf
(
"%s/bzz-feed:/%s/"
,
srv
.
URL
,
correctManifestAddrHex
)
testBzzResUrl
=
fmt
.
Sprintf
(
"%s/bzz-feed:/%s/"
,
srv
.
URL
,
correctManifestAddrHex
)
resp
,
err
=
http
.
Get
(
testBzzResUrl
+
"?meta=1"
)
resp
,
err
=
http
.
Get
(
testBzzResUrl
+
"?meta=1"
)
if
err
!=
nil
{
if
err
!=
nil
{
...
...
swarm/api/manifest.go
View file @
58c0879c
...
@@ -80,7 +80,7 @@ func (a *API) NewManifest(ctx context.Context, toEncrypt bool) (storage.Address,
...
@@ -80,7 +80,7 @@ func (a *API) NewManifest(ctx context.Context, toEncrypt bool) (storage.Address,
return
addr
,
err
return
addr
,
err
}
}
// Manifest hack for supporting
F
eeds from the bzz: scheme
// Manifest hack for supporting
Swarm f
eeds from the bzz: scheme
// see swarm/api/api.go:API.Get() for more information
// see swarm/api/api.go:API.Get() for more information
func
(
a
*
API
)
NewFeedManifest
(
ctx
context
.
Context
,
feed
*
feeds
.
Feed
)
(
storage
.
Address
,
error
)
{
func
(
a
*
API
)
NewFeedManifest
(
ctx
context
.
Context
,
feed
*
feeds
.
Feed
)
(
storage
.
Address
,
error
)
{
var
manifest
Manifest
var
manifest
Manifest
...
...
swarm/network/README.md
View file @
58c0879c
...
@@ -37,7 +37,7 @@ Using the streamer logic, various stream types are easy to implement:
...
@@ -37,7 +37,7 @@ Using the streamer logic, various stream types are easy to implement:
*
live session syncing
*
live session syncing
*
historical syncing
*
historical syncing
*
simple retrieve requests and deliveries
*
simple retrieve requests and deliveries
*
Swarm F
eeds streams
*
swarm f
eeds streams
*
receipting for finger pointing
*
receipting for finger pointing
## Syncing
## Syncing
...
@@ -57,7 +57,7 @@ receipts for a deleted chunk easily to refute their challenge.
...
@@ -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
-
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
keep track of syncing state across sessions, historical syncing state should survive restart
-
extra data structures to support syncing should be kept at minimum
-
extra data structures to support syncing should be kept at minimum
-
syncing is
organized separately for chunk types (Swarm Feed U
pdates v regular content chunk)
-
syncing is
not organized separately for chunk types (Swarm feed u
pdates v regular content chunk)
-
various types of streams should have common logic abstracted
-
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.
Syncing is now entirely mediated by the localstore, ie., no processes or memory leaks due to network contention.
...
...
swarm/storage/feeds/cacheentry.go
View file @
58c0879c
...
@@ -30,7 +30,7 @@ const (
...
@@ -30,7 +30,7 @@ const (
defaultRetrieveTimeout
=
100
*
time
.
Millisecond
defaultRetrieveTimeout
=
100
*
time
.
Millisecond
)
)
// cacheEntry caches the last known update of a specific
F
eed.
// cacheEntry caches the last known update of a specific
Swarm f
eed.
type
cacheEntry
struct
{
type
cacheEntry
struct
{
Update
Update
*
bytes
.
Reader
*
bytes
.
Reader
...
@@ -42,7 +42,7 @@ func (r *cacheEntry) Size(ctx context.Context, _ chan bool) (int64, error) {
...
@@ -42,7 +42,7 @@ func (r *cacheEntry) Size(ctx context.Context, _ chan bool) (int64, error) {
return
int64
(
len
(
r
.
Update
.
data
)),
nil
return
int64
(
len
(
r
.
Update
.
data
)),
nil
}
}
//returns the
F
eed's topic
//returns the
f
eed's topic
func
(
r
*
cacheEntry
)
Topic
()
Topic
{
func
(
r
*
cacheEntry
)
Topic
()
Topic
{
return
r
.
Feed
.
Topic
return
r
.
Feed
.
Topic
}
}
swarm/storage/feeds/error.go
View file @
58c0879c
...
@@ -35,7 +35,7 @@ const (
...
@@ -35,7 +35,7 @@ const (
ErrCnt
ErrCnt
)
)
// Error is a the typed error object used for Swarm
F
eeds
// Error is a the typed error object used for Swarm
f
eeds
type
Error
struct
{
type
Error
struct
{
code
int
code
int
err
string
err
string
...
@@ -52,7 +52,7 @@ func (e *Error) Code() int {
...
@@ -52,7 +52,7 @@ func (e *Error) Code() int {
return
e
.
code
return
e
.
code
}
}
// NewError creates a new Swarm
F
eeds Error object with the specified code and custom error message
// NewError creates a new Swarm
f
eeds Error object with the specified code and custom error message
func
NewError
(
code
int
,
s
string
)
error
{
func
NewError
(
code
int
,
s
string
)
error
{
if
code
<
0
||
code
>=
ErrCnt
{
if
code
<
0
||
code
>=
ErrCnt
{
panic
(
"no such error code!"
)
panic
(
"no such error code!"
)
...
...
swarm/storage/feeds/feed.go
View file @
58c0879c
...
@@ -25,7 +25,7 @@ import (
...
@@ -25,7 +25,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/storage"
"github.com/ethereum/go-ethereum/swarm/storage"
)
)
// Feed represents a particular user's stream of updates on a
T
opic
// Feed represents a particular user's stream of updates on a
t
opic
type
Feed
struct
{
type
Feed
struct
{
Topic
Topic
`json:"topic"`
Topic
Topic
`json:"topic"`
User
common
.
Address
`json:"user"`
User
common
.
Address
`json:"user"`
...
@@ -48,10 +48,10 @@ func (f *Feed) mapKey() uint64 {
...
@@ -48,10 +48,10 @@ func (f *Feed) mapKey() uint64 {
return
*
(
*
uint64
)(
unsafe
.
Pointer
(
&
hash
[
0
]))
return
*
(
*
uint64
)(
unsafe
.
Pointer
(
&
hash
[
0
]))
}
}
// binaryPut serializes this
F
eed instance into the provided slice
// binaryPut serializes this
f
eed instance into the provided slice
func
(
f
*
Feed
)
binaryPut
(
serializedData
[]
byte
)
error
{
func
(
f
*
Feed
)
binaryPut
(
serializedData
[]
byte
)
error
{
if
len
(
serializedData
)
!=
feedLength
{
if
len
(
serializedData
)
!=
feedLength
{
return
NewErrorf
(
ErrInvalidValue
,
"Incorrect slice size to serialize
F
eed. Expected %d, got %d"
,
feedLength
,
len
(
serializedData
))
return
NewErrorf
(
ErrInvalidValue
,
"Incorrect slice size to serialize
f
eed. Expected %d, got %d"
,
feedLength
,
len
(
serializedData
))
}
}
var
cursor
int
var
cursor
int
copy
(
serializedData
[
cursor
:
cursor
+
TopicLength
],
f
.
Topic
[
:
TopicLength
])
copy
(
serializedData
[
cursor
:
cursor
+
TopicLength
],
f
.
Topic
[
:
TopicLength
])
...
@@ -71,7 +71,7 @@ func (f *Feed) binaryLength() int {
...
@@ -71,7 +71,7 @@ func (f *Feed) binaryLength() int {
// binaryGet restores the current instance from the information contained in the passed slice
// binaryGet restores the current instance from the information contained in the passed slice
func
(
f
*
Feed
)
binaryGet
(
serializedData
[]
byte
)
error
{
func
(
f
*
Feed
)
binaryGet
(
serializedData
[]
byte
)
error
{
if
len
(
serializedData
)
!=
feedLength
{
if
len
(
serializedData
)
!=
feedLength
{
return
NewErrorf
(
ErrInvalidValue
,
"Incorrect slice size to read
F
eed. Expected %d, got %d"
,
feedLength
,
len
(
serializedData
))
return
NewErrorf
(
ErrInvalidValue
,
"Incorrect slice size to read
f
eed. Expected %d, got %d"
,
feedLength
,
len
(
serializedData
))
}
}
var
cursor
int
var
cursor
int
...
@@ -84,7 +84,7 @@ func (f *Feed) binaryGet(serializedData []byte) error {
...
@@ -84,7 +84,7 @@ func (f *Feed) binaryGet(serializedData []byte) error {
return
nil
return
nil
}
}
// Hex serializes the
F
eed to a hex string
// Hex serializes the
f
eed to a hex string
func
(
f
*
Feed
)
Hex
()
string
{
func
(
f
*
Feed
)
Hex
()
string
{
serializedData
:=
make
([]
byte
,
feedLength
)
serializedData
:=
make
([]
byte
,
feedLength
)
f
.
binaryPut
(
serializedData
)
f
.
binaryPut
(
serializedData
)
...
...
swarm/storage/feeds/handler.go
View file @
58c0879c
...
@@ -14,7 +14,7 @@
...
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU Lesser General Public License
// 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/>.
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// Handler is the API for
F
eeds
// Handler is the API for
f
eeds
// It enables creating, updating, syncing and retrieving feed updates and their data
// It enables creating, updating, syncing and retrieving feed updates and their data
package
feeds
package
feeds
...
@@ -57,7 +57,7 @@ func init() {
...
@@ -57,7 +57,7 @@ func init() {
}
}
}
}
// NewHandler creates a new Swarm
F
eeds API
// NewHandler creates a new Swarm
f
eeds API
func
NewHandler
(
params
*
HandlerParams
)
*
Handler
{
func
NewHandler
(
params
*
HandlerParams
)
*
Handler
{
fh
:=
&
Handler
{
fh
:=
&
Handler
{
cache
:
make
(
map
[
uint64
]
*
cacheEntry
),
cache
:
make
(
map
[
uint64
]
*
cacheEntry
),
...
@@ -74,7 +74,7 @@ func NewHandler(params *HandlerParams) *Handler {
...
@@ -74,7 +74,7 @@ func NewHandler(params *HandlerParams) *Handler {
return
fh
return
fh
}
}
// SetStore sets the store backend for the Swarm
F
eeds API
// SetStore sets the store backend for the Swarm
f
eeds API
func
(
h
*
Handler
)
SetStore
(
store
*
storage
.
NetStore
)
{
func
(
h
*
Handler
)
SetStore
(
store
*
storage
.
NetStore
)
{
h
.
chunkStore
=
store
h
.
chunkStore
=
store
}
}
...
@@ -110,7 +110,7 @@ func (h *Handler) Validate(chunkAddr storage.Address, data []byte) bool {
...
@@ -110,7 +110,7 @@ func (h *Handler) Validate(chunkAddr storage.Address, data []byte) bool {
return
true
return
true
}
}
// GetContent retrieves the data payload of the last synced update of the
F
eed
// GetContent retrieves the data payload of the last synced update of the
f
eed
func
(
h
*
Handler
)
GetContent
(
feed
*
Feed
)
(
storage
.
Address
,
[]
byte
,
error
)
{
func
(
h
*
Handler
)
GetContent
(
feed
*
Feed
)
(
storage
.
Address
,
[]
byte
,
error
)
{
if
feed
==
nil
{
if
feed
==
nil
{
return
nil
,
nil
,
NewError
(
ErrInvalidValue
,
"feed is nil"
)
return
nil
,
nil
,
NewError
(
ErrInvalidValue
,
"feed is nil"
)
...
@@ -240,7 +240,7 @@ func (h *Handler) updateCache(request *Request) (*cacheEntry, error) {
...
@@ -240,7 +240,7 @@ func (h *Handler) updateCache(request *Request) (*cacheEntry, error) {
}
}
// Update publishes a feed update
// Update publishes a feed update
// Note that a
F
eed update cannot span chunks, and thus has a MAX NET LENGTH 4096, INCLUDING update header data and signature.
// Note that a
f
eed 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)
// 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.
// 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
// Update can only check if the caller is trying to overwrite the very last known version, otherwise it just puts the update
...
@@ -286,7 +286,7 @@ func (h *Handler) get(feed *Feed) *cacheEntry {
...
@@ -286,7 +286,7 @@ func (h *Handler) get(feed *Feed) *cacheEntry {
return
feedUpdate
return
feedUpdate
}
}
// Sets the feed update cache value for the given
F
eed
// Sets the feed update cache value for the given
f
eed
func
(
h
*
Handler
)
set
(
feed
*
Feed
,
feedUpdate
*
cacheEntry
)
{
func
(
h
*
Handler
)
set
(
feed
*
Feed
,
feedUpdate
*
cacheEntry
)
{
mapKey
:=
feed
.
mapKey
()
mapKey
:=
feed
.
mapKey
()
h
.
cacheLock
.
Lock
()
h
.
cacheLock
.
Lock
()
...
...
swarm/storage/feeds/handler_test.go
View file @
58c0879c
...
@@ -89,11 +89,11 @@ func TestFeedsHandler(t *testing.T) {
...
@@ -89,11 +89,11 @@ func TestFeedsHandler(t *testing.T) {
}
}
defer
teardownTest
()
defer
teardownTest
()
// create a new
F
eed
// create a new
f
eed
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
defer
cancel
()
topic
,
_
:=
NewTopic
(
"Mess with Swarm
F
eeds code and see what ghost catches you"
,
nil
)
topic
,
_
:=
NewTopic
(
"Mess with Swarm
f
eeds code and see what ghost catches you"
,
nil
)
feed
:=
Feed
{
feed
:=
Feed
{
Topic
:
topic
,
Topic
:
topic
,
User
:
signer
.
Address
(),
User
:
signer
.
Address
(),
...
@@ -266,7 +266,7 @@ func TestSparseUpdates(t *testing.T) {
...
@@ -266,7 +266,7 @@ func TestSparseUpdates(t *testing.T) {
defer
teardownTest
()
defer
teardownTest
()
defer
os
.
RemoveAll
(
datadir
)
defer
os
.
RemoveAll
(
datadir
)
// create a new
F
eed
// create a new
f
eed
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
ctx
,
cancel
:=
context
.
WithCancel
(
context
.
Background
())
defer
cancel
()
defer
cancel
()
topic
,
_
:=
NewTopic
(
"Very slow updates"
,
nil
)
topic
,
_
:=
NewTopic
(
"Very slow updates"
,
nil
)
...
@@ -348,7 +348,7 @@ func TestValidator(t *testing.T) {
...
@@ -348,7 +348,7 @@ func TestValidator(t *testing.T) {
}
}
defer
teardownTest
()
defer
teardownTest
()
// create new
F
eed
// create new
f
eed
topic
,
_
:=
NewTopic
(
subtopicName
,
nil
)
topic
,
_
:=
NewTopic
(
subtopicName
,
nil
)
feed
:=
Feed
{
feed
:=
Feed
{
Topic
:
topic
,
Topic
:
topic
,
...
@@ -382,7 +382,7 @@ func TestValidator(t *testing.T) {
...
@@ -382,7 +382,7 @@ func TestValidator(t *testing.T) {
}
}
// tests that the content address validator correctly checks the data
// tests that the content address validator correctly checks the data
// tests that
F
eed update chunks are passed through content address validator
// tests that
f
eed update chunks are passed through content address validator
// there is some redundancy in this test as it also tests content addressed chunks,
// there is some redundancy in this test as it also tests content addressed chunks,
// which should be evaluated as invalid chunks by this validator
// which should be evaluated as invalid chunks by this validator
func
TestValidatorInStore
(
t
*
testing
.
T
)
{
func
TestValidatorInStore
(
t
*
testing
.
T
)
{
...
@@ -409,7 +409,7 @@ func TestValidatorInStore(t *testing.T) {
...
@@ -409,7 +409,7 @@ func TestValidatorInStore(t *testing.T) {
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
}
}
// set up Swarm
F
eeds handler and add is as a validator to the localstore
// set up Swarm
f
eeds handler and add is as a validator to the localstore
fhParams
:=
&
HandlerParams
{}
fhParams
:=
&
HandlerParams
{}
fh
:=
NewHandler
(
fhParams
)
fh
:=
NewHandler
(
fhParams
)
store
.
Validators
=
append
(
store
.
Validators
,
fh
)
store
.
Validators
=
append
(
store
.
Validators
,
fh
)
...
@@ -463,7 +463,7 @@ func TestValidatorInStore(t *testing.T) {
...
@@ -463,7 +463,7 @@ func TestValidatorInStore(t *testing.T) {
}
}
}
}
// create rpc and
F
eeds Handler
// create rpc and
f
eeds Handler
func
setupTest
(
timeProvider
timestampProvider
,
signer
Signer
)
(
fh
*
TestHandler
,
datadir
string
,
teardown
func
(),
err
error
)
{
func
setupTest
(
timeProvider
timestampProvider
,
signer
Signer
)
(
fh
*
TestHandler
,
datadir
string
,
teardown
func
(),
err
error
)
{
var
fsClean
func
()
var
fsClean
func
()
...
...
swarm/storage/feeds/lookup/lookup.go
View file @
58c0879c
...
@@ -15,7 +15,7 @@
...
@@ -15,7 +15,7 @@
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
// along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
/*
/*
Package lookup defines
F
eed lookup algorithms and provides tools to place updates
Package lookup defines
f
eed lookup algorithms and provides tools to place updates
so they can be found
so they can be found
*/
*/
package
lookup
package
lookup
...
...
swarm/storage/feeds/request.go
View file @
58c0879c
...
@@ -27,7 +27,7 @@ import (
...
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
"github.com/ethereum/go-ethereum/swarm/storage/feeds/lookup"
)
)
// Request represents a request to sign or signed
Feed U
pdate message
// Request represents a request to sign or signed
feed u
pdate message
type
Request
struct
{
type
Request
struct
{
Update
// actual content that will be put on the chunk, less signature
Update
// actual content that will be put on the chunk, less signature
Signature
*
Signature
Signature
*
Signature
...
...
swarm/storage/feeds/request_test.go
View file @
58c0879c
...
@@ -47,7 +47,7 @@ func areEqualJSON(s1, s2 string) (bool, error) {
...
@@ -47,7 +47,7 @@ func areEqualJSON(s1, s2 string) (bool, error) {
}
}
// TestEncodingDecodingUpdateRequests ensures that requests are serialized properly
// TestEncodingDecodingUpdateRequests ensures that requests are serialized properly
// while also checking cryptographically that only the owner of a
F
eed can update it.
// while also checking cryptographically that only the owner of a
f
eed can update it.
func
TestEncodingDecodingUpdateRequests
(
t
*
testing
.
T
)
{
func
TestEncodingDecodingUpdateRequests
(
t
*
testing
.
T
)
{
charlie
:=
newCharlieSigner
()
//Charlie
charlie
:=
newCharlieSigner
()
//Charlie
...
@@ -136,7 +136,7 @@ func TestEncodingDecodingUpdateRequests(t *testing.T) {
...
@@ -136,7 +136,7 @@ func TestEncodingDecodingUpdateRequests(t *testing.T) {
t
.
Fatal
(
"Expected DecodeUpdateRequest to fail when trying to interpret a corrupt message with an invalid signature"
)
t
.
Fatal
(
"Expected DecodeUpdateRequest to fail when trying to interpret a corrupt message with an invalid signature"
)
}
}
// Now imagine Bob wants to create an update of his own about the same
F
eed,
// Now imagine Bob wants to create an update of his own about the same
f
eed,
// signing a message with his private key
// signing a message with his private key
if
err
:=
request
.
Sign
(
bob
);
err
!=
nil
{
if
err
:=
request
.
Sign
(
bob
);
err
!=
nil
{
t
.
Fatalf
(
"Error signing: %s"
,
err
)
t
.
Fatalf
(
"Error signing: %s"
,
err
)
...
@@ -228,7 +228,7 @@ func TestUpdateChunkSerializationErrorChecking(t *testing.T) {
...
@@ -228,7 +228,7 @@ func TestUpdateChunkSerializationErrorChecking(t *testing.T) {
var
recovered
Request
var
recovered
Request
recovered
.
fromChunk
(
chunk
.
Address
(),
chunk
.
Data
())
recovered
.
fromChunk
(
chunk
.
Address
(),
chunk
.
Data
())
if
!
reflect
.
DeepEqual
(
recovered
,
r
)
{
if
!
reflect
.
DeepEqual
(
recovered
,
r
)
{
t
.
Fatal
(
"Expected recovered
Request update
to equal the original one"
)
t
.
Fatal
(
"Expected recovered
feed update request
to equal the original one"
)
}
}
}
}
...
@@ -248,7 +248,7 @@ func TestReverse(t *testing.T) {
...
@@ -248,7 +248,7 @@ func TestReverse(t *testing.T) {
// signer containing private key
// signer containing private key
signer
:=
newAliceSigner
()
signer
:=
newAliceSigner
()
// set up rpc and create
F
eeds handler
// set up rpc and create
f
eeds handler
_
,
_
,
teardownTest
,
err
:=
setupTest
(
timeProvider
,
signer
)
_
,
_
,
teardownTest
,
err
:=
setupTest
(
timeProvider
,
signer
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
...
swarm/storage/feeds/sign.go
View file @
58c0879c
...
@@ -28,7 +28,7 @@ const signatureLength = 65
...
@@ -28,7 +28,7 @@ const signatureLength = 65
// Signature is an alias for a static byte array with the size of a signature
// Signature is an alias for a static byte array with the size of a signature
type
Signature
[
signatureLength
]
byte
type
Signature
[
signatureLength
]
byte
// Signer signs
F
eed update payloads
// Signer signs
f
eed update payloads
type
Signer
interface
{
type
Signer
interface
{
Sign
(
common
.
Hash
)
(
Signature
,
error
)
Sign
(
common
.
Hash
)
(
Signature
,
error
)
Address
()
common
.
Address
Address
()
common
.
Address
...
@@ -65,7 +65,7 @@ func (s *GenericSigner) Address() common.Address {
...
@@ -65,7 +65,7 @@ func (s *GenericSigner) Address() common.Address {
return
s
.
address
return
s
.
address
}
}
// getUserAddr extracts the address of the
F
eed update signer
// getUserAddr extracts the address of the
f
eed update signer
func
getUserAddr
(
digest
common
.
Hash
,
signature
Signature
)
(
common
.
Address
,
error
)
{
func
getUserAddr
(
digest
common
.
Hash
,
signature
Signature
)
(
common
.
Address
,
error
)
{
pub
,
err
:=
crypto
.
SigToPub
(
digest
.
Bytes
(),
signature
[
:
])
pub
,
err
:=
crypto
.
SigToPub
(
digest
.
Bytes
(),
signature
[
:
])
if
err
!=
nil
{
if
err
!=
nil
{
...
...
swarm/storage/localstore_test.go
View file @
58c0879c
...
@@ -30,7 +30,7 @@ var (
...
@@ -30,7 +30,7 @@ var (
)
)
// tests that the content address validator correctly checks the data
// tests that the content address validator correctly checks the data
// tests that
F
eed update chunks are passed through content address validator
// tests that
f
eed update chunks are passed through content address validator
// the test checking the resouce update validator internal correctness is found in storage/feeds/handler_test.go
// the test checking the resouce update validator internal correctness is found in storage/feeds/handler_test.go
func
TestValidator
(
t
*
testing
.
T
)
{
func
TestValidator
(
t
*
testing
.
T
)
{
// set up localstore
// set up localstore
...
...
swarm/testutil/http.go
View file @
58c0879c
...
@@ -48,7 +48,7 @@ func NewTestSwarmServer(t *testing.T, serverFunc func(*api.API) TestServer, reso
...
@@ -48,7 +48,7 @@ func NewTestSwarmServer(t *testing.T, serverFunc func(*api.API) TestServer, reso
}
}
fileStore
:=
storage
.
NewFileStore
(
localStore
,
storage
.
NewFileStoreParams
())
fileStore
:=
storage
.
NewFileStore
(
localStore
,
storage
.
NewFileStoreParams
())
// Swarm
F
eeds test setup
// Swarm
f
eeds test setup
feedsDir
,
err
:=
ioutil
.
TempDir
(
""
,
"swarm-feeds-test"
)
feedsDir
,
err
:=
ioutil
.
TempDir
(
""
,
"swarm-feeds-test"
)
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment