mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 13:16:42 +00:00
start hive and cademlia in netstore initializer
This commit is contained in:
parent
0fddda3969
commit
1ab5ec387a
3 changed files with 30 additions and 14 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
package bzz
|
package bzz
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
// "fmt"
|
||||||
|
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/common/kademlia"
|
"github.com/ethereum/go-ethereum/common/kademlia"
|
||||||
)
|
)
|
||||||
|
|
@ -38,7 +40,8 @@ func (self *hive) start() (err error) {
|
||||||
self.kad.Start()
|
self.kad.Start()
|
||||||
err = self.kad.Load(self.path)
|
err = self.kad.Load(self.path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
dpaLogger.Warnf("Warning: error reading kademlia node db (skipping): %v", err)
|
||||||
|
err = nil
|
||||||
}
|
}
|
||||||
// go func() {
|
// go func() {
|
||||||
// for {
|
// for {
|
||||||
|
|
|
||||||
|
|
@ -45,14 +45,23 @@ type requestStatus struct {
|
||||||
C chan bool
|
C chan bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewNetStore(addr common.Hash, path, hivepath string) *NetStore {
|
func NewNetStore(addr common.Hash, path, hivepath string) (netstore *NetStore, err error) {
|
||||||
dbStore, _ := newDbStore(path)
|
dbStore, err := newDbStore(path)
|
||||||
return &NetStore{
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
hive := newHive(addr, hivepath)
|
||||||
|
netstore = &NetStore{
|
||||||
localStore: &localStore{
|
localStore: &localStore{
|
||||||
memStore: newMemStore(dbStore),
|
memStore: newMemStore(dbStore),
|
||||||
dbStore: dbStore,
|
dbStore: dbStore,
|
||||||
}, hive: newHive(addr, hivepath),
|
}, hive: hive,
|
||||||
}
|
}
|
||||||
|
err = hive.start()
|
||||||
|
if err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *NetStore) Put(entry *Chunk) {
|
func (self *NetStore) Put(entry *Chunk) {
|
||||||
|
|
|
||||||
|
|
@ -302,16 +302,20 @@ func New(config *Config) (*Ethereum, error) {
|
||||||
eth.net.ListenAddr = ":" + config.Port
|
eth.net.ListenAddr = ":" + config.Port
|
||||||
}
|
}
|
||||||
if config.Bzz {
|
if config.Bzz {
|
||||||
netStore := bzz.NewNetStore(eth.net.Self().Sha(), path.Join(config.DataDir, "bzz"), path.Join(config.DataDir, "bzzpeers.json"))
|
netStore, err := bzz.NewNetStore(eth.net.Self().Sha(), path.Join(config.DataDir, "bzz"), path.Join(config.DataDir, "bzzpeers.json"))
|
||||||
chunker := &bzz.TreeChunker{}
|
if err != nil {
|
||||||
chunker.Init()
|
glog.V(logger.Warn).Infof("BZZ: error creating net store: %v. Protocol skipped", err)
|
||||||
dpa := &bzz.DPA{
|
} else {
|
||||||
Chunker: chunker,
|
chunker := &bzz.TreeChunker{}
|
||||||
ChunkStore: netStore,
|
chunker.Init()
|
||||||
|
dpa := &bzz.DPA{
|
||||||
|
Chunker: chunker,
|
||||||
|
ChunkStore: netStore,
|
||||||
|
}
|
||||||
|
dpa.Start()
|
||||||
|
protocols = append(protocols, bzz.BzzProtocol(netStore, eth.net.Self))
|
||||||
|
go bzz.StartHttpServer(dpa)
|
||||||
}
|
}
|
||||||
dpa.Start()
|
|
||||||
protocols = append(protocols, bzz.BzzProtocol(netStore, eth.net.Self))
|
|
||||||
go bzz.StartHttpServer(dpa)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Shh {
|
if config.Shh {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue