add hive to protocol constructors

This commit is contained in:
zelig 2015-02-07 07:34:28 +01:00
parent d82157ec86
commit c3add4001c

View file

@ -141,22 +141,23 @@ main entrypoint, wrappers starting a server running the bzz protocol
use this constructor to attach the protocol ("class") to server caps use this constructor to attach the protocol ("class") to server caps
the Dev p2p layer then runs the protocol instance on each peer the Dev p2p layer then runs the protocol instance on each peer
*/ */
func BzzProtocol(netStore *netStore) p2p.Protocol { func BzzProtocol(netStore *netStore, hive *hive) p2p.Protocol {
return p2p.Protocol{ return p2p.Protocol{
Name: "bzz", Name: "bzz",
Version: Version, Version: Version,
Length: ProtocolLength, Length: ProtocolLength,
Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error { Run: func(p *p2p.Peer, rw p2p.MsgReadWriter) error {
return runBzzProtocol(netStore, p, rw) return runBzzProtocol(netStore, hive, p, rw)
}, },
} }
} }
// the main loop that handles incoming messages // the main loop that handles incoming messages
// note RemovePeer in the post-disconnect hook // note RemovePeer in the post-disconnect hook
func runBzzProtocol(netStore *netStore, p *p2p.Peer, rw p2p.MsgReadWriter) (err error) { func runBzzProtocol(netStore *netStore, hive *hive, p *p2p.Peer, rw p2p.MsgReadWriter) (err error) {
self := &bzzProtocol{ self := &bzzProtocol{
netStore: netStore, netStore: netStore,
hive: hive,
rw: rw, rw: rw,
peer: p, peer: p,
} }