mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 20:56: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
|
||||
|
||||
import (
|
||||
// "fmt"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/kademlia"
|
||||
)
|
||||
|
|
@ -38,7 +40,8 @@ func (self *hive) start() (err error) {
|
|||
self.kad.Start()
|
||||
err = self.kad.Load(self.path)
|
||||
if err != nil {
|
||||
return
|
||||
dpaLogger.Warnf("Warning: error reading kademlia node db (skipping): %v", err)
|
||||
err = nil
|
||||
}
|
||||
// go func() {
|
||||
// for {
|
||||
|
|
|
|||
|
|
@ -45,14 +45,23 @@ type requestStatus struct {
|
|||
C chan bool
|
||||
}
|
||||
|
||||
func NewNetStore(addr common.Hash, path, hivepath string) *NetStore {
|
||||
dbStore, _ := newDbStore(path)
|
||||
return &NetStore{
|
||||
func NewNetStore(addr common.Hash, path, hivepath string) (netstore *NetStore, err error) {
|
||||
dbStore, err := newDbStore(path)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
hive := newHive(addr, hivepath)
|
||||
netstore = &NetStore{
|
||||
localStore: &localStore{
|
||||
memStore: newMemStore(dbStore),
|
||||
dbStore: dbStore,
|
||||
}, hive: newHive(addr, hivepath),
|
||||
}, hive: hive,
|
||||
}
|
||||
err = hive.start()
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (self *NetStore) Put(entry *Chunk) {
|
||||
|
|
|
|||
|
|
@ -302,16 +302,20 @@ func New(config *Config) (*Ethereum, error) {
|
|||
eth.net.ListenAddr = ":" + config.Port
|
||||
}
|
||||
if config.Bzz {
|
||||
netStore := bzz.NewNetStore(eth.net.Self().Sha(), path.Join(config.DataDir, "bzz"), path.Join(config.DataDir, "bzzpeers.json"))
|
||||
chunker := &bzz.TreeChunker{}
|
||||
chunker.Init()
|
||||
dpa := &bzz.DPA{
|
||||
Chunker: chunker,
|
||||
ChunkStore: netStore,
|
||||
netStore, err := bzz.NewNetStore(eth.net.Self().Sha(), path.Join(config.DataDir, "bzz"), path.Join(config.DataDir, "bzzpeers.json"))
|
||||
if err != nil {
|
||||
glog.V(logger.Warn).Infof("BZZ: error creating net store: %v. Protocol skipped", err)
|
||||
} else {
|
||||
chunker := &bzz.TreeChunker{}
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue