aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm
diff options
context:
space:
mode:
authorJavier Peletier <jm@epiclabs.io>2018-09-30 15:43:10 +0800
committerJavier Peletier <jm@epiclabs.io>2018-10-03 15:12:06 +0800
commit83705ef6aa3645a6305a400fa175e44904a929f7 (patch)
tree013c6594b7d275ab5eaa90b3969e77719787483f /cmd/swarm
parentb35622cf3c758d96874f287d137725946fc6341d (diff)
downloadgo-tangerine-83705ef6aa3645a6305a400fa175e44904a929f7.tar.gz
go-tangerine-83705ef6aa3645a6305a400fa175e44904a929f7.tar.zst
go-tangerine-83705ef6aa3645a6305a400fa175e44904a929f7.zip
swarm/storage/mru: Renamed rest of MRU references
Diffstat (limited to 'cmd/swarm')
-rw-r--r--cmd/swarm/main.go66
-rw-r--r--cmd/swarm/mru.go52
-rw-r--r--cmd/swarm/mru_test.go34
3 files changed, 76 insertions, 76 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index 5acf87c71..4c4dfceb7 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -207,25 +207,25 @@ var (
Name: "compressed",
Usage: "Prints encryption keys in compressed form",
}
- SwarmResourceNameFlag = cli.StringFlag{
+ SwarmFeedNameFlag = cli.StringFlag{
Name: "name",
- Usage: "User-defined name for the new resource, limited to 32 characters. If combined with topic, the resource will be a subtopic with this name",
+ Usage: "User-defined name for the new feed, limited to 32 characters. If combined with topic, it will refer to a subtopic with this name",
}
- SwarmResourceTopicFlag = cli.StringFlag{
+ SwarmFeedTopicFlag = cli.StringFlag{
Name: "topic",
- Usage: "User-defined topic this resource is tracking, hex encoded. Limited to 64 hexadecimal characters",
+ Usage: "User-defined topic this feed is tracking, hex encoded. Limited to 64 hexadecimal characters",
}
- SwarmResourceDataOnCreateFlag = cli.StringFlag{
+ SwarmFeedDataOnCreateFlag = cli.StringFlag{
Name: "data",
- Usage: "Initializes the resource with the given hex-encoded data. Data must be prefixed by 0x",
+ Usage: "Initializes the feed with the given hex-encoded data. Data must be prefixed by 0x",
}
- SwarmResourceManifestFlag = cli.StringFlag{
+ SwarmFeedManifestFlag = cli.StringFlag{
Name: "manifest",
- Usage: "Refers to the resource through a manifest",
+ Usage: "Refers to the feed through a manifest",
}
- SwarmResourceUserFlag = cli.StringFlag{
+ SwarmFeedUserFlag = cli.StringFlag{
Name: "user",
- Usage: "Indicates the user who updates the resource",
+ Usage: "Indicates the user who updates the feed",
}
)
@@ -346,62 +346,62 @@ func init() {
},
{
CustomHelpTemplate: helpTemplate,
- Name: "resource",
- Usage: "(Advanced) Create and update Mutable Resources",
+ Name: "feed",
+ Usage: "(Advanced) Create and update Swarm Feeds",
ArgsUsage: "<create|update|info>",
- Description: "Works with Mutable Resource Updates",
+ Description: "Works with Swarm Feeds",
Subcommands: []cli.Command{
{
- Action: resourceCreate,
+ Action: feedCreateManifest,
CustomHelpTemplate: helpTemplate,
Name: "create",
- Usage: "creates and publishes a new Mutable Resource manifest",
- Description: `creates and publishes a new Mutable Resource manifest pointing to a specified user's updates about a particular topic.
- The resource topic can be built in the following ways:
+ 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.
- For example --name could be set to "profile-picture", meaning this Mutable Resource allows to get this user's current profile picture.
+ For example --name could be set to "profile-picture", meaning this feed allows to get this user's current profile picture.
* use both --topic and --name to create named subtopics.
For example, --topic could be set to an Ethereum contract address and --name could be set to "comments", meaning
- the Mutable Resource tracks a discussion about that contract.
+ this feed tracks a discussion about that contract.
The --user flag allows to have this manifest refer to a user other than yourself. If not specified,
it will then default to your local account (--bzzaccount)`,
- Flags: []cli.Flag{SwarmResourceNameFlag, SwarmResourceTopicFlag, SwarmResourceUserFlag},
+ Flags: []cli.Flag{SwarmFeedNameFlag, SwarmFeedTopicFlag, SwarmFeedUserFlag},
},
{
- Action: resourceUpdate,
+ Action: feedUpdate,
CustomHelpTemplate: helpTemplate,
Name: "update",
- Usage: "updates the content of an existing Mutable Resource",
+ Usage: "updates the content of an existing Swarm Feed",
ArgsUsage: "<0x Hex data>",
Description: `publishes a new update on the specified topic
- The resource 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 --name to set the topic to a human-readable name.
- For example --name could be set to "profile-picture", meaning this Mutable Resource allows to get this user's current profile picture.
+ For example --name could be set to "profile-picture", meaning this feed allows to get this user's current profile picture.
* use both --topic and --name to create named subtopics.
For example, --topic could be set to an Ethereum contract address and --name could be set to "comments", meaning
- the Mutable Resource tracks a discussion about that contract.
+ this feed tracks a discussion about that contract.
- If you have a manifest, you can specify it with --manifest to refer to the resource,
+ If you have a manifest, you can specify it with --manifest to refer to the feed,
instead of using --topic / --name
`,
- Flags: []cli.Flag{SwarmResourceManifestFlag, SwarmResourceNameFlag, SwarmResourceTopicFlag},
+ Flags: []cli.Flag{SwarmFeedManifestFlag, SwarmFeedNameFlag, SwarmFeedTopicFlag},
},
{
- Action: resourceInfo,
+ Action: feedInfo,
CustomHelpTemplate: helpTemplate,
Name: "info",
- Usage: "obtains information about an existing Mutable Resource",
- Description: `obtains information about an existing Mutable Resource
+ 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.
The --user flag allows to refer to a user other than yourself. If not specified,
it will then default to your local account (--bzzaccount)
If you have a manifest, you can specify it with --manifest instead of --topic / --name / ---user
- to refer to the resource`,
- Flags: []cli.Flag{SwarmResourceManifestFlag, SwarmResourceNameFlag, SwarmResourceTopicFlag, SwarmResourceUserFlag},
+ to refer to the feed`,
+ Flags: []cli.Flag{SwarmFeedManifestFlag, SwarmFeedNameFlag, SwarmFeedTopicFlag, SwarmFeedUserFlag},
},
},
},
@@ -738,7 +738,7 @@ func getAccount(bzzaccount string, ctx *cli.Context, stack *node.Node) *ecdsa.Pr
}
// getPrivKey returns the private key of the specified bzzaccount
-// Used only by client commands, such as `resource`
+// Used only by client commands, such as `feed`
func getPrivKey(ctx *cli.Context) *ecdsa.PrivateKey {
// booting up the swarm node just as we do in bzzd action
bzzconfig, err := buildConfig(ctx)
diff --git a/cmd/swarm/mru.go b/cmd/swarm/mru.go
index afa73820f..6c6d44c0a 100644
--- a/cmd/swarm/mru.go
+++ b/cmd/swarm/mru.go
@@ -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 Swarm Feeds
+// Command feed allows the user to create and update signed Swarm Feeds
package main
import (
@@ -36,8 +36,8 @@ func NewGenericSigner(ctx *cli.Context) mru.Signer {
}
func getTopic(ctx *cli.Context) (topic mru.Topic) {
- var name = ctx.String(SwarmResourceNameFlag.Name)
- var relatedTopic = ctx.String(SwarmResourceTopicFlag.Name)
+ var name = ctx.String(SwarmFeedNameFlag.Name)
+ var relatedTopic = ctx.String(SwarmFeedTopicFlag.Name)
var relatedTopicBytes []byte
var err error
@@ -55,35 +55,35 @@ func getTopic(ctx *cli.Context) (topic mru.Topic) {
return topic
}
-// swarm resource create <frequency> [--name <name>] [--data <0x Hexdata> [--multihash=false]]
-// swarm resource update <Manifest Address or ENS domain> <0x Hexdata> [--multihash=false]
-// swarm resource info <Manifest Address or ENS domain>
+// swarm feed create <frequency> [--name <name>] [--data <0x Hexdata> [--multihash=false]]
+// swarm feed update <Manifest Address or ENS domain> <0x Hexdata> [--multihash=false]
+// swarm feed info <Manifest Address or ENS domain>
-func resourceCreate(ctx *cli.Context) {
+func feedCreateManifest(ctx *cli.Context) {
var (
bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
client = swarm.NewClient(bzzapi)
)
- newResourceRequest := mru.NewFirstRequest(getTopic(ctx))
- newResourceRequest.Feed.User = resourceGetUser(ctx)
+ newFeedUpdateRequest := mru.NewFirstRequest(getTopic(ctx))
+ newFeedUpdateRequest.Feed.User = feedGetUser(ctx)
- manifestAddress, err := client.CreateResource(newResourceRequest)
+ manifestAddress, err := client.CreateFeedWithManifest(newFeedUpdateRequest)
if err != nil {
- utils.Fatalf("Error creating resource: %s", err.Error())
+ utils.Fatalf("Error creating feed manifest: %s", err.Error())
return
}
fmt.Println(manifestAddress) // output manifest address to the user in a single line (useful for other commands to pick up)
}
-func resourceUpdate(ctx *cli.Context) {
+func feedUpdate(ctx *cli.Context) {
args := ctx.Args()
var (
bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
client = swarm.NewClient(bzzapi)
- manifestAddressOrDomain = ctx.String(SwarmResourceManifestFlag.Name)
+ manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name)
)
if len(args) < 1 {
@@ -110,10 +110,10 @@ func resourceUpdate(ctx *cli.Context) {
}
- // Retrieve resource status and metadata out of the manifest
- updateRequest, err = client.GetResourceMetadata(query, manifestAddressOrDomain)
+ // Retrieve feed status and metadata out of the manifest
+ updateRequest, err = client.GetFeedMetadata(query, manifestAddressOrDomain)
if err != nil {
- utils.Fatalf("Error retrieving resource status: %s", err.Error())
+ utils.Fatalf("Error retrieving feed status: %s", err.Error())
}
// set the new data
@@ -121,34 +121,34 @@ func resourceUpdate(ctx *cli.Context) {
// sign update
if err = updateRequest.Sign(signer); err != nil {
- utils.Fatalf("Error signing resource update: %s", err.Error())
+ utils.Fatalf("Error signing feed update: %s", err.Error())
}
// post update
- err = client.UpdateResource(updateRequest)
+ err = client.UpdateFeed(updateRequest)
if err != nil {
- utils.Fatalf("Error updating resource: %s", err.Error())
+ utils.Fatalf("Error updating feed: %s", err.Error())
return
}
}
-func resourceInfo(ctx *cli.Context) {
+func feedInfo(ctx *cli.Context) {
var (
bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
client = swarm.NewClient(bzzapi)
- manifestAddressOrDomain = ctx.String(SwarmResourceManifestFlag.Name)
+ manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name)
)
var query *mru.Query
if manifestAddressOrDomain == "" {
query = new(mru.Query)
query.Topic = getTopic(ctx)
- query.User = resourceGetUser(ctx)
+ query.User = feedGetUser(ctx)
}
- metadata, err := client.GetResourceMetadata(query, manifestAddressOrDomain)
+ metadata, err := client.GetFeedMetadata(query, manifestAddressOrDomain)
if err != nil {
- utils.Fatalf("Error retrieving resource metadata: %s", err.Error())
+ utils.Fatalf("Error retrieving feed metadata: %s", err.Error())
return
}
encodedMetadata, err := metadata.MarshalJSON()
@@ -158,8 +158,8 @@ func resourceInfo(ctx *cli.Context) {
fmt.Println(string(encodedMetadata))
}
-func resourceGetUser(ctx *cli.Context) common.Address {
- var user = ctx.String(SwarmResourceUserFlag.Name)
+func feedGetUser(ctx *cli.Context) common.Address {
+ var user = ctx.String(SwarmFeedUserFlag.Name)
if user != "" {
return common.HexToAddress(user)
}
diff --git a/cmd/swarm/mru_test.go b/cmd/swarm/mru_test.go
index c52097a6e..c0c43aca4 100644
--- a/cmd/swarm/mru_test.go
+++ b/cmd/swarm/mru_test.go
@@ -38,12 +38,12 @@ import (
swarmhttp "github.com/ethereum/go-ethereum/swarm/api/http"
)
-func TestCLIResourceUpdate(t *testing.T) {
+func TestCLIFeedUpdate(t *testing.T) {
srv := testutil.NewTestSwarmServer(t, func(api *api.API) testutil.TestServer {
return swarmhttp.NewServer(api, "")
}, nil)
- log.Info("starting 1 node cluster")
+ log.Info("starting a test swarm server")
defer srv.Close()
// create a private key file for signing
@@ -77,13 +77,13 @@ func TestCLIResourceUpdate(t *testing.T) {
flags := []string{
"--bzzapi", srv.URL,
"--bzzaccount", pkfile.Name(),
- "resource", "update",
+ "feed", "update",
"--topic", topic.Hex(),
"--name", name,
hexData}
// create an update and expect an exit without errors
- log.Info(fmt.Sprintf("updating a resource with 'swarm resource update'"))
+ log.Info(fmt.Sprintf("updating a feed with 'swarm feed update'"))
cmd := runSwarm(t, flags...)
cmd.ExpectExit()
@@ -100,17 +100,17 @@ func TestCLIResourceUpdate(t *testing.T) {
t.Fatal(err)
}
- // View configures whose updates we will be looking up.
- view := mru.Feed{
+ // Feed configures whose updates we will be looking up.
+ feed := mru.Feed{
Topic: topic,
User: address,
}
// Build a query to get the latest update
- query := mru.NewQueryLatest(&view, lookup.NoClue)
+ query := mru.NewQueryLatest(&feed, lookup.NoClue)
// retrieve content!
- reader, err := client.GetResource(query, "")
+ reader, err := client.QueryFeed(query, "")
if err != nil {
t.Fatal(err)
}
@@ -128,12 +128,12 @@ func TestCLIResourceUpdate(t *testing.T) {
// Now retrieve info for the next update
flags = []string{
"--bzzapi", srv.URL,
- "resource", "info",
+ "feed", "info",
"--topic", topic.Hex(),
"--user", address.Hex(),
}
- log.Info(fmt.Sprintf("getting resource info with 'swarm resource info'"))
+ log.Info(fmt.Sprintf("getting feed info with 'swarm feed info'"))
cmd = runSwarm(t, flags...)
_, matches := cmd.ExpectRegexp(`.*`) // regex hack to extract stdout
cmd.ExpectExit()
@@ -145,28 +145,28 @@ func TestCLIResourceUpdate(t *testing.T) {
t.Fatal(err)
}
- // make sure the retrieved view is the same
- if request.Feed != view {
- t.Fatalf("Expected view to be: %s, got %s", view, request.Feed)
+ // make sure the retrieved Feed is the same
+ if request.Feed != feed {
+ t.Fatalf("Expected feed to be: %s, got %s", feed, request.Feed)
}
// test publishing a manifest
flags = []string{
"--bzzapi", srv.URL,
"--bzzaccount", pkfile.Name(),
- "resource", "create",
+ "feed", "create",
"--topic", topic.Hex(),
}
- log.Info(fmt.Sprintf("Publishing manifest with 'swarm resource create'"))
+ log.Info(fmt.Sprintf("Publishing manifest with 'swarm feed create'"))
cmd = runSwarm(t, flags...)
_, matches = cmd.ExpectRegexp(`[a-f\d]{64}`) // regex hack to extract stdout
cmd.ExpectExit()
- manifestAddress := matches[0] // read the received resource manifest
+ manifestAddress := matches[0] // read the received feed manifest
// now attempt to lookup the latest update using a manifest instead
- reader, err = client.GetResource(nil, manifestAddress)
+ reader, err = client.QueryFeed(nil, manifestAddress)
if err != nil {
t.Fatal(err)
}