Browse Source
follow-up: SimpleConfig is supposed to be singleton
see cefa4762ba
and #5629
dependabot/pip/contrib/deterministic-build/ecdsa-0.13.3
SomberNight
5 years ago
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
7 changed files with
27 additions and
10 deletions
-
electrum/network.py
-
electrum/scripts/block_headers.py
-
electrum/scripts/estimate_fee.py
-
electrum/scripts/get_history.py
-
electrum/scripts/peers.py
-
electrum/scripts/txradar.py
-
electrum/scripts/watch_address.py
|
|
@ -234,7 +234,7 @@ class Network(Logger): |
|
|
|
|
|
|
|
LOGGING_SHORTCUT = 'n' |
|
|
|
|
|
|
|
def __init__(self, config: SimpleConfig=None): |
|
|
|
def __init__(self, config: SimpleConfig): |
|
|
|
global INSTANCE |
|
|
|
INSTANCE = self |
|
|
|
|
|
|
@ -244,9 +244,8 @@ class Network(Logger): |
|
|
|
assert self.asyncio_loop.is_running(), "event loop not running" |
|
|
|
self._loop_thread = None # type: threading.Thread # set by caller; only used for sanity checks |
|
|
|
|
|
|
|
if config is None: |
|
|
|
config = {} # Do not use mutables as default values! |
|
|
|
self.config = SimpleConfig(config) if isinstance(config, dict) else config # type: SimpleConfig |
|
|
|
assert isinstance(config, SimpleConfig), f"config should be a SimpleConfig instead of {type(config)}" |
|
|
|
self.config = config |
|
|
|
blockchain.read_blockchains(self.config) |
|
|
|
self.logger.info(f"blockchains {list(map(lambda b: b.forkpoint, blockchain.blockchains.values()))}") |
|
|
|
self._blockchain_preferred_block = self.config.get('blockchain_preferred_block', None) # type: Optional[Dict] |
|
|
|
|
|
@ -7,10 +7,13 @@ import asyncio |
|
|
|
|
|
|
|
from electrum.network import Network |
|
|
|
from electrum.util import print_msg, json_encode, create_and_start_event_loop, log_exceptions |
|
|
|
from electrum.simple_config import SimpleConfig |
|
|
|
|
|
|
|
config = SimpleConfig() |
|
|
|
|
|
|
|
# start network |
|
|
|
loop, stopping_fut, loop_thread = create_and_start_event_loop() |
|
|
|
network = Network() |
|
|
|
network = Network(config) |
|
|
|
network.start() |
|
|
|
|
|
|
|
# wait until connected |
|
|
|
|
|
@ -6,10 +6,13 @@ from numbers import Number |
|
|
|
|
|
|
|
from electrum.network import filter_protocol, Network |
|
|
|
from electrum.util import create_and_start_event_loop, log_exceptions |
|
|
|
from electrum.simple_config import SimpleConfig |
|
|
|
|
|
|
|
|
|
|
|
config = SimpleConfig() |
|
|
|
|
|
|
|
loop, stopping_fut, loop_thread = create_and_start_event_loop() |
|
|
|
network = Network() |
|
|
|
network = Network(config) |
|
|
|
network.start() |
|
|
|
|
|
|
|
@log_exceptions |
|
|
|
|
|
@ -6,6 +6,7 @@ import asyncio |
|
|
|
from electrum import bitcoin |
|
|
|
from electrum.network import Network |
|
|
|
from electrum.util import json_encode, print_msg, create_and_start_event_loop, log_exceptions |
|
|
|
from electrum.simple_config import SimpleConfig |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
@ -14,8 +15,10 @@ except Exception: |
|
|
|
print("usage: get_history <bitcoin_address>") |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
config = SimpleConfig() |
|
|
|
|
|
|
|
loop, stopping_fut, loop_thread = create_and_start_event_loop() |
|
|
|
network = Network() |
|
|
|
network = Network(config) |
|
|
|
network.start() |
|
|
|
|
|
|
|
@log_exceptions |
|
|
|
|
|
@ -4,9 +4,13 @@ import asyncio |
|
|
|
from electrum.network import filter_protocol, Network |
|
|
|
from electrum.util import create_and_start_event_loop, log_exceptions |
|
|
|
from electrum.blockchain import hash_raw_header |
|
|
|
from electrum.simple_config import SimpleConfig |
|
|
|
|
|
|
|
|
|
|
|
config = SimpleConfig() |
|
|
|
|
|
|
|
loop, stopping_fut, loop_thread = create_and_start_event_loop() |
|
|
|
network = Network() |
|
|
|
network = Network(config) |
|
|
|
network.start() |
|
|
|
|
|
|
|
@log_exceptions |
|
|
|
|
|
@ -4,6 +4,7 @@ import asyncio |
|
|
|
|
|
|
|
from electrum.network import filter_protocol, Network |
|
|
|
from electrum.util import create_and_start_event_loop, log_exceptions |
|
|
|
from electrum.simple_config import SimpleConfig |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
@ -12,9 +13,10 @@ except: |
|
|
|
print("usage: txradar txid") |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
config = SimpleConfig() |
|
|
|
|
|
|
|
loop, stopping_fut, loop_thread = create_and_start_event_loop() |
|
|
|
network = Network() |
|
|
|
network = Network(config) |
|
|
|
network.start() |
|
|
|
|
|
|
|
@log_exceptions |
|
|
|
|
|
@ -6,6 +6,7 @@ import asyncio |
|
|
|
from electrum.network import Network |
|
|
|
from electrum.util import print_msg, create_and_start_event_loop |
|
|
|
from electrum.synchronizer import SynchronizerBase |
|
|
|
from electrum.simple_config import SimpleConfig |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
@ -14,9 +15,11 @@ except Exception: |
|
|
|
print("usage: watch_address <bitcoin_address>") |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
config = SimpleConfig() |
|
|
|
|
|
|
|
# start network |
|
|
|
loop = create_and_start_event_loop()[0] |
|
|
|
network = Network() |
|
|
|
network = Network(config) |
|
|
|
network.start() |
|
|
|
|
|
|
|
|
|
|
|