aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm/mru.go
diff options
context:
space:
mode:
authorJavier Peletier <jm@epiclabs.io>2018-09-30 15:51:11 +0800
committerJavier Peletier <jm@epiclabs.io>2018-10-03 15:12:06 +0800
commitb6ccc06cdaac80d09da17c25b2f450cd1f1b7914 (patch)
tree2413da1a2025e901eecf253399fe4bfebbdd1925 /cmd/swarm/mru.go
parent83705ef6aa3645a6305a400fa175e44904a929f7 (diff)
downloaddexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar
dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.gz
dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.bz2
dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.lz
dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.xz
dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.tar.zst
dexon-b6ccc06cdaac80d09da17c25b2f450cd1f1b7914.zip
swarm/storage/feeds: Final package rename and moved files
Diffstat (limited to 'cmd/swarm/mru.go')
-rw-r--r--cmd/swarm/mru.go172
1 files changed, 0 insertions, 172 deletions
diff --git a/cmd/swarm/mru.go b/cmd/swarm/mru.go
deleted file mode 100644
index 6c6d44c0a..000000000
--- a/cmd/swarm/mru.go
+++ /dev/null
@@ -1,172 +0,0 @@
-// Copyright 2016 The go-ethereum Authors
-// This file is part of go-ethereum.
-//
-// go-ethereum is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// go-ethereum is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with go-ethereum. If not, see <http://www.gnu.org/licenses/>.
-
-// Command feed allows the user to create and update signed Swarm Feeds
-package main
-
-import (
- "fmt"
- "strings"
-
- "github.com/ethereum/go-ethereum/common"
- "github.com/ethereum/go-ethereum/common/hexutil"
- "github.com/ethereum/go-ethereum/crypto"
-
- "github.com/ethereum/go-ethereum/cmd/utils"
- swarm "github.com/ethereum/go-ethereum/swarm/api/client"
- "github.com/ethereum/go-ethereum/swarm/storage/mru"
- "gopkg.in/urfave/cli.v1"
-)
-
-func NewGenericSigner(ctx *cli.Context) mru.Signer {
- return mru.NewGenericSigner(getPrivKey(ctx))
-}
-
-func getTopic(ctx *cli.Context) (topic mru.Topic) {
- var name = ctx.String(SwarmFeedNameFlag.Name)
- var relatedTopic = ctx.String(SwarmFeedTopicFlag.Name)
- var relatedTopicBytes []byte
- var err error
-
- if relatedTopic != "" {
- relatedTopicBytes, err = hexutil.Decode(relatedTopic)
- if err != nil {
- utils.Fatalf("Error parsing topic: %s", err)
- }
- }
-
- topic, err = mru.NewTopic(name, relatedTopicBytes)
- if err != nil {
- utils.Fatalf("Error parsing topic: %s", err)
- }
- return topic
-}
-
-// 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 feedCreateManifest(ctx *cli.Context) {
- var (
- bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
- client = swarm.NewClient(bzzapi)
- )
-
- newFeedUpdateRequest := mru.NewFirstRequest(getTopic(ctx))
- newFeedUpdateRequest.Feed.User = feedGetUser(ctx)
-
- manifestAddress, err := client.CreateFeedWithManifest(newFeedUpdateRequest)
- if err != nil {
- 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 feedUpdate(ctx *cli.Context) {
- args := ctx.Args()
-
- var (
- bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
- client = swarm.NewClient(bzzapi)
- manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name)
- )
-
- if len(args) < 1 {
- fmt.Println("Incorrect number of arguments")
- cli.ShowCommandHelpAndExit(ctx, "update", 1)
- return
- }
-
- signer := NewGenericSigner(ctx)
-
- data, err := hexutil.Decode(args[0])
- if err != nil {
- utils.Fatalf("Error parsing data: %s", err.Error())
- return
- }
-
- var updateRequest *mru.Request
- var query *mru.Query
-
- if manifestAddressOrDomain == "" {
- query = new(mru.Query)
- query.User = signer.Address()
- query.Topic = getTopic(ctx)
-
- }
-
- // Retrieve feed status and metadata out of the manifest
- updateRequest, err = client.GetFeedMetadata(query, manifestAddressOrDomain)
- if err != nil {
- utils.Fatalf("Error retrieving feed status: %s", err.Error())
- }
-
- // set the new data
- updateRequest.SetData(data)
-
- // sign update
- if err = updateRequest.Sign(signer); err != nil {
- utils.Fatalf("Error signing feed update: %s", err.Error())
- }
-
- // post update
- err = client.UpdateFeed(updateRequest)
- if err != nil {
- utils.Fatalf("Error updating feed: %s", err.Error())
- return
- }
-}
-
-func feedInfo(ctx *cli.Context) {
- var (
- bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
- client = swarm.NewClient(bzzapi)
- manifestAddressOrDomain = ctx.String(SwarmFeedManifestFlag.Name)
- )
-
- var query *mru.Query
- if manifestAddressOrDomain == "" {
- query = new(mru.Query)
- query.Topic = getTopic(ctx)
- query.User = feedGetUser(ctx)
- }
-
- metadata, err := client.GetFeedMetadata(query, manifestAddressOrDomain)
- if err != nil {
- utils.Fatalf("Error retrieving feed metadata: %s", err.Error())
- return
- }
- encodedMetadata, err := metadata.MarshalJSON()
- if err != nil {
- utils.Fatalf("Error encoding metadata to JSON for display:%s", err)
- }
- fmt.Println(string(encodedMetadata))
-}
-
-func feedGetUser(ctx *cli.Context) common.Address {
- var user = ctx.String(SwarmFeedUserFlag.Name)
- if user != "" {
- return common.HexToAddress(user)
- }
- pk := getPrivKey(ctx)
- if pk == nil {
- utils.Fatalf("Cannot read private key. Must specify --user or --bzzaccount")
- }
- return crypto.PubkeyToAddress(pk.PublicKey)
-
-}