def __init__(self, runmode, log): super(Bootstrapper, self).__init__() self.log = log #.getChild("bootstrap") self.runmode = runmode self.ircbootstrapper = IrcBootstrapper(runmode, log=log) self.dnsbootstrapper = DnsBoostrapper(runmode, log=log) self.ircbootstrapper.subscribe(IrcBootstrapper.EVT_FOUND_PEER, self.on_found_peer) self.dnsbootstrapper.subscribe(DnsBoostrapper.EVT_FOUND_PEER, self.on_found_peer)
class Bootstrapper(Observable): EVT_FOUND_PEER = Observable.createevent() def __init__(self, runmode, log): super(Bootstrapper, self).__init__() self.log = log #.getChild("bootstrap") self.runmode = runmode self.ircbootstrapper = IrcBootstrapper(runmode, log=log) self.dnsbootstrapper = DnsBoostrapper(runmode, log=log) self.ircbootstrapper.subscribe(IrcBootstrapper.EVT_FOUND_PEER, self.on_found_peer) self.dnsbootstrapper.subscribe(DnsBoostrapper.EVT_FOUND_PEER, self.on_found_peer) def on_found_peer(self, event): self.fire(self.EVT_FOUND_PEER, peeraddress=event.peeraddress) def bootstrap(self): if self.runmode == MAIN: self.dnsbootstrapper.bootstrap() else: self.ircbootstrapper.start()