@ -162,6 +162,7 @@ class TailableProc(object):
"""
"""
return self . wait_for_logs ( [ regex ] , timeout )
return self . wait_for_logs ( [ regex ] , timeout )
class SimpleBitcoinProxy :
class SimpleBitcoinProxy :
""" Wrapper for BitcoinProxy to reconnect.
""" Wrapper for BitcoinProxy to reconnect.
@ -170,8 +171,8 @@ class SimpleBitcoinProxy:
throwaway connections . This is easier than to reach into the RPC
throwaway connections . This is easier than to reach into the RPC
library to close , reopen and reauth upon failure .
library to close , reopen and reauth upon failure .
"""
"""
def __init__ ( self , url ) :
def __init__ ( self , btc_conf_file , * args , * * kwargs ) :
self . url = url
self . __btc_conf_file__ = btc_conf_file
def __getattr__ ( self , name ) :
def __getattr__ ( self , name ) :
if name . startswith ( ' __ ' ) and name . endswith ( ' __ ' ) :
if name . startswith ( ' __ ' ) and name . endswith ( ' __ ' ) :
@ -179,7 +180,9 @@ class SimpleBitcoinProxy:
raise AttributeError
raise AttributeError
# Create a callable to do the actual call
# Create a callable to do the actual call
f = lambda * args : BitcoinProxy ( self . url ) . _call ( name , * args )
proxy = BitcoinProxy ( btc_conf_file = self . __btc_conf_file__ )
f = lambda * args : proxy . _call ( name , * args )
# Make debuggers show <function bitcoin.rpc.name> rather than <function
# Make debuggers show <function bitcoin.rpc.name> rather than <function
# bitcoin.rpc.<lambda>>
# bitcoin.rpc.<lambda>>
@ -210,10 +213,10 @@ class BitcoinD(TailableProc):
' -nolisten ' ,
' -nolisten ' ,
]
]
BITCOIND_CONFIG [ ' rpcport ' ] = rpcport
BITCOIND_CONFIG [ ' rpcport ' ] = rpcport
btc_conf_file = os . path . join ( regtestdir , ' bitcoin.conf ' )
write_config ( os . path . join ( bitcoin_dir , ' bitcoin.conf ' ) , BITCOIND_CONFIG )
write_config ( os . path . join ( bitcoin_dir , ' bitcoin.conf ' ) , BITCOIND_CONFIG )
write_config ( os . path . join ( regtestdir , ' bitcoin.conf ' ) , BITCOIND_CONFIG )
write_config ( btc_conf_file , BITCOIND_CONFIG )
self . rpc = SimpleBitcoinProxy (
self . rpc = SimpleBitcoinProxy ( btc_conf_file = btc_conf_file )
" http://rpcuser:rpcpass@127.0.0.1: {} " . format ( self . rpcport ) )
def start ( self ) :
def start ( self ) :
TailableProc . start ( self )
TailableProc . start ( self )