MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / wait_for_rpc_connection

Method wait_for_rpc_connection

test/functional/test_framework/test_node.py:168–194  ·  view source on GitHub ↗

Sets up an RPC connection to the bitcoind process. Returns False if unable to connect.

(self)

Source from the content-addressed store, hash-verified

166 self.log.debug("bitcoind started, waiting for RPC to come up")
167
168 def wait_for_rpc_connection(self):
169 """Sets up an RPC connection to the bitcoind process. Returns False if unable to connect."""
170 # Poll at a rate of four times per second
171 poll_per_s = 4
172 for _ in range(poll_per_s * self.rpc_timeout):
173 if self.process.poll() is not None:
174 raise FailedToStartError(self._node_msg(
175 'bitcoind exited with status {} during initialization'.format(self.process.returncode)))
176 try:
177 self.rpc = get_rpc_proxy(rpc_url(self.datadir, self.index, self.rpchost), self.index, timeout=self.rpc_timeout, coveragedir=self.coverage_dir)
178 self.rpc.getblockcount()
179 # If the call to getblockcount() succeeds then the RPC connection is up
180 self.rpc_connected = True
181 self.url = self.rpc.url
182 self.log.debug("RPC successfully started")
183 return
184 except IOError as e:
185 if e.errno != errno.ECONNREFUSED: # Port not yet open?
186 raise # unknown IO error
187 except JSONRPCException as e: # Initialization phase
188 if e.error['code'] != -28: # RPC in warmup?
189 raise # unknown JSON RPC exception
190 except ValueError as e: # cookie file not found and no rpcuser or rpcassword. bitcoind still starting
191 if "No RPC credentials" not in str(e):
192 raise
193 time.sleep(1.0 / poll_per_s)
194 self._raise_assertion_error("Unable to connect to bitcoind")
195
196 def get_wallet_rpc(self, wallet_name):
197 if self.use_cli:

Callers 4

start_nodeMethod · 0.80
start_nodesMethod · 0.80
_initialize_chainMethod · 0.80

Calls 6

_node_msgMethod · 0.95
FailedToStartErrorClass · 0.85
get_rpc_proxyFunction · 0.85
rpc_urlFunction · 0.85
formatMethod · 0.80

Tested by

no test coverage detected