本文整理汇总了Python中simple_config.SimpleConfig.get_active_chain_code方法的典型用法代码示例。如果您正苦于以下问题:Python SimpleConfig.get_active_chain_code方法的具体用法?Python SimpleConfig.get_active_chain_code怎么用?Python SimpleConfig.get_active_chain_code使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类simple_config.SimpleConfig
的用法示例。
在下文中一共展示了SimpleConfig.get_active_chain_code方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Network
# 需要导入模块: from simple_config import SimpleConfig [as 别名]
# 或者: from simple_config.SimpleConfig import get_active_chain_code [as 别名]
class Network(util.DaemonThread):
"""The Network class manages a set of connections to remote
electrum servers, each connection is handled by its own
thread object returned from Interface(). Its external API:
- Member functions get_header(), get_parameters(), get_status_value(),
new_blockchain_height(), set_parameters(), start(),
stop()
"""
def __init__(self, pipe, config=None, active_chain=None):
if config is None:
config = {} # Do not use mutables as default values!
util.DaemonThread.__init__(self)
self.config = SimpleConfig(config) if type(config) == type({}) else config
if active_chain is None:
active_chain = chainparams.get_active_chain()
self.active_chain = active_chain
self.num_server = 8 if not self.config.get('oneserver') else 0
self.blockchain = Blockchain(self.config, self, self.active_chain)
self.queue = Queue.Queue()
self.requests_queue = pipe.send_queue
self.response_queue = pipe.get_queue
# run() will block while this event is cleared
self.chain_switched = threading.Event()
self.chain_switched.set()
# A deque of interface header requests, processed left-to-right
self.bc_requests = deque()
# Server for addresses and transactions
self.sanitize_default_server()
self.irc_servers = {} # returned by interface (list from irc)
self.recent_servers = self.read_recent_servers()
self.banner = ''
self.heights = {}
self.merkle_roots = {}
self.utxo_roots = {}
dir_path = os.path.join( self.config.path, 'certs')
if not os.path.exists(dir_path):
os.mkdir(dir_path)
# subscriptions and requests
self.subscribed_addresses = set()
# cached address status
self.addr_responses = {}
# unanswered requests
self.unanswered_requests = {}
# retry times
self.server_retry_time = time.time()
self.nodes_retry_time = time.time()
# kick off the network. interface is the main server we are currently
# communicating with. interfaces is the set of servers we are connecting
# to or have an ongoing connection with
self.interface = None
self.interfaces = {}
self.start_network(deserialize_server(self.default_server)[2],
deserialize_proxy(self.config.get('proxy')))
def switch_chains(self, chaincode=None):
if chaincode is None:
chain = chainparams.get_active_chain()
else:
chain = chainparams.get_chain_instance(chaincode)
self.chain_switched.clear()
self.active_chain = chain
if self.config.get_active_chain_code() != self.active_chain.code:
self.config.set_active_chain_code(self.active_chain.code)
self.print_error('switching chains to {}'.format(chain.code))
self.stop_network()
time.sleep(0.2)
self.bc_requests.clear()
self.blockchain = Blockchain(self.config, self, self.active_chain)
self.queue = Queue.Queue()
self.sanitize_default_server()
self.irc_servers = {} # returned by interface (list from irc)
self.recent_servers = self.read_recent_servers()
self.banner = ''
self.heights = {}
self.merkle_roots = {}
self.utxo_roots = {}
self.interface = None
self.interfaces = {}
# subscriptions and requests
self.subscribed_addresses = set()
# cached address status
self.addr_responses = {}
# unanswered requests
self.unanswered_requests = {}
self.blockchain.init()
# Start the new network
#.........这里部分代码省略.........