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,
}
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
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):
def get_servers(self):
- out = self.irc_servers if self.irc_servers else DEFAULT_SERVERS
- for s in self.recent_servers:
- host, port, protocol = s.split(':')
- if host not in out:
- out[host] = { protocol:port }
+ if self.irc_servers:
+ out = self.irc_servers
+ else:
+ out = DEFAULT_SERVERS
+ for s in self.recent_servers:
+ host, port, protocol = s.split(':')
+ if host not in out:
+ out[host] = { protocol:port }
return out
def start_interface(self, server):
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')