From 9db8b3df1e42a277508f046946804fc96896649f Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Mon, 11 May 2015 17:39:25 +0200 Subject: [PATCH 1/3] Re-introduced Swarm and Swarm http proxy into geth. --- bzz/dbstore.go | 4 ++-- cmd/geth/main.go | 1 + cmd/utils/flags.go | 5 +++++ eth/backend.go | 17 +++++++++++++++++ 4 files changed, 25 insertions(+), 2 deletions(-) diff --git a/bzz/dbstore.go b/bzz/dbstore.go index e3325077e1..87337c5fa7 100644 --- a/bzz/dbstore.go +++ b/bzz/dbstore.go @@ -232,7 +232,7 @@ func (s *dbStore) collectGarbage(ratio float32) { cutidx := gcListSelect(s.gcArray, 0, gcnt-1, int(float32(gcnt)*ratio)) cutval := s.gcArray[cutidx].value - fmt.Print(gcnt, " ", s.entryCnt, " ") + // fmt.Print(gcnt, " ", s.entryCnt, " ") // actual gc for i := 0; i < gcnt; i++ { @@ -246,7 +246,7 @@ func (s *dbStore) collectGarbage(ratio float32) { } } - fmt.Println(s.entryCnt) + // fmt.Println(s.entryCnt) s.db.Put(keyGCPos, s.gcPos) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index fd7aae4c21..7f963f435a 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -255,6 +255,7 @@ JavaScript API. See https://github.com/ethereum/go-ethereum/wiki/Javascipt-Conso utils.RPCListenAddrFlag, utils.RPCPortFlag, utils.WhisperEnabledFlag, + utils.SwarmEnabledFlag, utils.VMDebugFlag, utils.ProtocolVersionFlag, utils.NetworkIdFlag, diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index dd3b6c8a2f..e84ba26e3a 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -235,6 +235,10 @@ var ( Name: "shh", Usage: "Enable whisper", } + SwarmEnabledFlag = cli.BoolFlag{ + Name: "bzz", + Usage: "Enable swarm", + } // ATM the url is left to the user and deployment to JSpathFlag = cli.StringFlag{ Name: "jspath", @@ -309,6 +313,7 @@ func MakeEthConfig(clientID, version string, ctx *cli.Context) *eth.Config { NatSpec: ctx.GlobalBool(NatspecEnabledFlag.Name), NodeKey: GetNodeKey(ctx), Shh: ctx.GlobalBool(WhisperEnabledFlag.Name), + Bzz: ctx.GlobalBool(SwarmEnabledFlag.Name), Dial: true, BootNodes: ctx.GlobalString(BootnodesFlag.Name), GasPrice: common.String2Big(ctx.GlobalString(GasPriceFlag.Name)), diff --git a/eth/backend.go b/eth/backend.go index cdbe35b26f..9171a3acb8 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -14,6 +14,7 @@ import ( "github.com/ethereum/ethash" "github.com/ethereum/go-ethereum/accounts" + "github.com/ethereum/go-ethereum/bzz" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core" "github.com/ethereum/go-ethereum/core/types" @@ -74,6 +75,7 @@ type Config struct { NAT nat.Interface Shh bool + Bzz bool Dial bool Etherbase string @@ -280,7 +282,22 @@ func New(config *Config) (*Ethereum, error) { if err != nil { return nil, err } + protocols := []p2p.Protocol{eth.protocolManager.SubProtocol} + + if config.Bzz { + netStore := bzz.NewNetStore(config.DataDir + "/bzz") + chunker := &bzz.TreeChunker{} + chunker.Init() + dpa := &bzz.DPA{ + Chunker: chunker, + ChunkStore: netStore, + } + dpa.Start() + protocols = append(protocols, bzz.BzzProtocol(netStore)) + go bzz.StartHttpServer(dpa) + } + if config.Shh { protocols = append(protocols, eth.whisper.Protocol()) } From 345af05f09f52c45ead7f80ae61b4f3ef0b56d39 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Mon, 11 May 2015 17:40:43 +0200 Subject: [PATCH 2/3] fmt import removed --- bzz/dbstore.go | 1 - 1 file changed, 1 deletion(-) diff --git a/bzz/dbstore.go b/bzz/dbstore.go index 87337c5fa7..76797eb00c 100644 --- a/bzz/dbstore.go +++ b/bzz/dbstore.go @@ -5,7 +5,6 @@ package bzz import ( "bytes" "encoding/binary" - "fmt" "sync" "github.com/ethereum/go-ethereum/ethdb" From 05c64815b740a753cefe7d2693e1cd3c68c58025 Mon Sep 17 00:00:00 2001 From: "Daniel A. Nagy" Date: Mon, 11 May 2015 18:24:20 +0200 Subject: [PATCH 3/3] Increased disk capacity to 20G --- bzz/dbstore.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bzz/dbstore.go b/bzz/dbstore.go index 76797eb00c..88b52bd1c7 100644 --- a/bzz/dbstore.go +++ b/bzz/dbstore.go @@ -385,7 +385,7 @@ func newDbStore(path string) (s *dbStore, err error) { return } - s.setCapacity(50000) // TODO define default capacity as constant + s.setCapacity(5000000) // TODO define default capacity as constant s.gcStartPos = make([]byte, 1) s.gcStartPos[0] = kpIndex