aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/swarm/main.go
diff options
context:
space:
mode:
authorJanoš Guljaš <janos@users.noreply.github.com>2019-02-07 22:46:58 +0800
committerAnton Evangelatov <anton.evangelatov@gmail.com>2019-02-07 22:46:58 +0800
commit33d0a0efa61fed2b16797fd12161519943943282 (patch)
treee56eec28cba025f2f5209d5aca9a692bed30fec3 /cmd/swarm/main.go
parent685eec31288de5b364d7c7b527f26e5a623575a7 (diff)
downloadgo-tangerine-33d0a0efa61fed2b16797fd12161519943943282.tar
go-tangerine-33d0a0efa61fed2b16797fd12161519943943282.tar.gz
go-tangerine-33d0a0efa61fed2b16797fd12161519943943282.tar.bz2
go-tangerine-33d0a0efa61fed2b16797fd12161519943943282.tar.lz
go-tangerine-33d0a0efa61fed2b16797fd12161519943943282.tar.xz
go-tangerine-33d0a0efa61fed2b16797fd12161519943943282.tar.zst
go-tangerine-33d0a0efa61fed2b16797fd12161519943943282.zip
cmd/swarm/global-store: global store cmd (#19014)
Diffstat (limited to 'cmd/swarm/main.go')
-rw-r--r--cmd/swarm/main.go20
1 files changed, 17 insertions, 3 deletions
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index 839227b2b..385afad99 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -39,13 +39,16 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/p2p/enode"
+ "github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/swarm"
bzzapi "github.com/ethereum/go-ethereum/swarm/api"
swarmmetrics "github.com/ethereum/go-ethereum/swarm/metrics"
+ "github.com/ethereum/go-ethereum/swarm/storage/mock"
+ mockrpc "github.com/ethereum/go-ethereum/swarm/storage/mock/rpc"
"github.com/ethereum/go-ethereum/swarm/tracing"
sv "github.com/ethereum/go-ethereum/swarm/version"
- "gopkg.in/urfave/cli.v1"
+ cli "gopkg.in/urfave/cli.v1"
)
const clientIdentifier = "swarm"
@@ -196,6 +199,7 @@ func init() {
SwarmStorePath,
SwarmStoreCapacity,
SwarmStoreCacheCapacity,
+ SwarmGlobalStoreAPIFlag,
}
rpcFlags := []cli.Flag{
utils.WSEnabledFlag,
@@ -325,8 +329,18 @@ func bzzd(ctx *cli.Context) error {
func registerBzzService(bzzconfig *bzzapi.Config, stack *node.Node) {
//define the swarm service boot function
boot := func(_ *node.ServiceContext) (node.Service, error) {
- // In production, mockStore must be always nil.
- return swarm.NewSwarm(bzzconfig, nil)
+ var nodeStore *mock.NodeStore
+ if bzzconfig.GlobalStoreAPI != "" {
+ // connect to global store
+ client, err := rpc.Dial(bzzconfig.GlobalStoreAPI)
+ if err != nil {
+ return nil, fmt.Errorf("global store: %v", err)
+ }
+ globalStore := mockrpc.NewGlobalStore(client)
+ // create a node store for this swarm key on global store
+ nodeStore = globalStore.NewNodeStore(common.HexToAddress(bzzconfig.BzzKey))
+ }
+ return swarm.NewSwarm(bzzconfig, nodeStore)
}
//register within the ethereum node
if err := stack.Register(boot); err != nil {