mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 05:06:43 +00:00
fix path->filepath; open requestDB only once in bzzProtocol
This commit is contained in:
parent
c9a598ed4c
commit
89df3a4648
2 changed files with 14 additions and 11 deletions
|
|
@ -204,25 +204,25 @@ main entrypoint, wrappers starting a server running the bzz protocol
|
|||
use this constructor to attach the protocol ("class") to server caps
|
||||
the Dev p2p layer then runs the protocol instance on each peer
|
||||
*/
|
||||
func BzzProtocol(netStore *NetStore) p2p.Protocol {
|
||||
func BzzProtocol(netStore *NetStore) (p2p.Protocol, error) {
|
||||
|
||||
db, err := NewLDBDatabase(path.Join(netStore.path, "requests"))
|
||||
if err != nil {
|
||||
return p2p.Protocol{}, err
|
||||
}
|
||||
return p2p.Protocol{
|
||||
Name: "bzz",
|
||||
Version: Version,
|
||||
Length: ProtocolLength,
|
||||
Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {
|
||||
return runBzzProtocol(netStore, p, rw)
|
||||
return runBzzProtocol(db, netStore, p, rw)
|
||||
},
|
||||
}
|
||||
}, nil
|
||||
}
|
||||
|
||||
// the main loop that handles incoming messages
|
||||
// note RemovePeer in the post-disconnect hook
|
||||
func runBzzProtocol(netStore *NetStore, p *p2p.Peer, rw p2p.MsgReadWriter) (err error) {
|
||||
|
||||
db, err := NewLDBDatabase(path.Join(netStore.path, "requests"))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
func runBzzProtocol(db *LDBDatabase, netStore *NetStore, p *p2p.Peer, rw p2p.MsgReadWriter) (err error) {
|
||||
|
||||
self := &bzzProtocol{
|
||||
netStore: netStore,
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ func New(config *Config) (*Ethereum, error) {
|
|||
protocols := []p2p.Protocol{eth.protocolManager.SubProtocol}
|
||||
|
||||
if config.Bzz {
|
||||
eth.netStore, err = bzz.NewNetStore(path.Join(config.DataDir, "bzz"), path.Join(config.DataDir, "bzzpeers.json"))
|
||||
eth.netStore, err = bzz.NewNetStore(filepath.Join(config.DataDir, "bzz"), filepath.Join(config.DataDir, "bzzpeers.json"))
|
||||
if err != nil {
|
||||
glog.V(logger.Warn).Infof("BZZ: error creating net store: %v. Protocol skipped", err)
|
||||
} else {
|
||||
|
|
@ -303,7 +303,10 @@ func New(config *Config) (*Ethereum, error) {
|
|||
Chunker: chunker,
|
||||
ChunkStore: eth.netStore,
|
||||
}
|
||||
protocols = append(protocols, bzz.BzzProtocol(eth.netStore))
|
||||
bzzProto, err := bzz.BzzProtocol(eth.netStore)
|
||||
if err != nil {
|
||||
protocols = append(protocols, bzzProto)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue