本文整理汇总了Python中network.Network.join方法的典型用法代码示例。如果您正苦于以下问题:Python Network.join方法的具体用法?Python Network.join怎么用?Python Network.join使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类network.Network
的用法示例。
在下文中一共展示了Network.join方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Daemon
# 需要导入模块: from network import Network [as 别名]
# 或者: from network.Network import join [as 别名]
#.........这里部分代码省略.........
if self.network:
p = self.network.get_parameters()
response = {
"path": self.network.config.path,
"server": p[0],
"blockchain_height": self.network.get_local_height(),
"server_height": self.network.get_server_height(),
"nodes": self.network.get_interfaces(),
"connected": self.network.is_connected(),
"auto_connect": p[4],
"wallets": {k: w.is_up_to_date() for k, w in self.wallets.items()},
}
else:
response = "Daemon offline"
elif sub == "stop":
self.stop()
response = "Daemon stopped"
return response
def run_gui(self, config_options):
config = SimpleConfig(config_options)
if self.gui:
if hasattr(self.gui, "new_window"):
path = config.get_wallet_path()
self.gui.new_window(path, config.get("url"))
response = "ok"
else:
response = "error: current GUI does not support multiple windows"
else:
response = "Error: Electrum is running in daemon mode. Please stop the daemon first."
return response
def load_wallet(self, path, get_wizard=None):
if path in self.wallets:
wallet = self.wallets[path]
else:
storage = WalletStorage(path)
if get_wizard:
if storage.file_exists:
wallet = Wallet(storage)
action = wallet.get_action()
else:
action = "new"
if action:
wizard = get_wizard()
wallet = wizard.run(self.network, storage)
else:
wallet.start_threads(self.network)
else:
wallet = Wallet(storage)
wallet.start_threads(self.network)
if wallet:
self.wallets[path] = wallet
return wallet
def run_cmdline(self, config_options):
config = SimpleConfig(config_options)
cmdname = config.get("cmd")
cmd = known_commands[cmdname]
path = config.get_wallet_path()
wallet = self.load_wallet(path) if cmd.requires_wallet else None
# arguments passed to function
args = map(lambda x: config.get(x), cmd.params)
# decode json arguments
args = map(json_decode, args)
# options
args += map(lambda x: config.get(x), cmd.options)
cmd_runner = Commands(
config,
wallet,
self.network,
password=config_options.get("password"),
new_password=config_options.get("new_password"),
)
func = getattr(cmd_runner, cmd.name)
result = func(*args)
return result
def run(self):
while self.is_running():
self.server.handle_request()
for k, wallet in self.wallets.items():
wallet.stop_threads()
if self.network:
self.print_error("shutting down network")
self.network.stop()
self.network.join()
def stop(self):
self.print_error("stopping, removing lockfile")
remove_lockfile(get_lockfile(self.config))
DaemonThread.stop(self)
def init_gui(self, config, plugins):
gui_name = config.get("gui", "qt")
if gui_name in ["lite", "classic"]:
gui_name = "qt"
gui = __import__("electrum_gui." + gui_name, fromlist=["electrum_gui"])
self.gui = gui.ElectrumGui(config, self, plugins)
self.gui.main()