X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=lib%2Fnetwork.py;h=114edc62ae67a4a37ed17f3fae512c08ba5a9518;hb=HEAD;hp=ca145e2e98da18e3fe1cbd8e0e2f965a230c612e;hpb=32cca276fe7a13af0a41d319c5d0ed92211edabc;p=electrum-nvc.git diff --git a/lib/network.py b/lib/network.py index ca145e2..114edc6 100644 --- a/lib/network.py +++ b/lib/network.py @@ -4,21 +4,12 @@ from bitcoin import * import interface from blockchain import Blockchain -DEFAULT_PORTS = {'t':'50001', 's':'50002', 'h':'8081', 'g':'8082'} +DEFAULT_PORTS = {'t':'40001', 's':'40002', 'h':'7081', 'g':'7082'} DEFAULT_SERVERS = { - 'ecdsa.org': DEFAULT_PORTS, - 'ecdsa.net': DEFAULT_PORTS, - 'electrum.hachre.de': DEFAULT_PORTS, - 'electrum.novit.ro': DEFAULT_PORTS, - 'electrum.coinwallet.me': DEFAULT_PORTS, - 'cube.l0g.in': DEFAULT_PORTS, - 'bitcoin.epicinet.net': DEFAULT_PORTS, - 'h.1209k.com': DEFAULT_PORTS, - 'electrum.electricnewyear.net': DEFAULT_PORTS, - 'erbium.sytes.net': DEFAULT_PORTS, - 'e2.pdmc.net':DEFAULT_PORTS, - 'electrum.thwg.org':DEFAULT_PORTS, +# '127.0.0.1': DEFAULT_PORTS, + '193.23.181.148': DEFAULT_PORTS, + '91.235.143.61': DEFAULT_PORTS, } @@ -70,7 +61,9 @@ from simple_config import SimpleConfig class Network(threading.Thread): - def __init__(self, config = {}): + def __init__(self, config=None): + if config is None: + config = {} # Do not use mutables as default values! threading.Thread.__init__(self) self.daemon = True self.config = SimpleConfig(config) if type(config) == type({}) else config @@ -109,6 +102,7 @@ class Network(threading.Thread): self.subscriptions = {} self.subscriptions[self.on_banner] = [('server.banner',[])] self.subscriptions[self.on_peers] = [('server.peers.subscribe',[])] + self.pending_transactions_for_notifications = [] def is_connected(self): @@ -368,8 +362,11 @@ class Network(threading.Thread): def on_header(self, i, r): result = r.get('result') - if not result: return + if not result: + return height = result.get('block_height') + if not height: + return self.heights[i.server] = height self.merkle_roots[i.server] = result.get('merkle_root') self.utxo_roots[i.server] = result.get('utxo_root')