electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit c3419eb7bb72e663068111599949e294054453da
parent 43c8fd43c4f7c5c2797126fddfc05dcafd6c68e0
Author: ThomasV <thomasv@gitorious>
Date:   Mon, 15 Sep 2014 15:01:09 +0200

update script

Diffstat:
Mscripts/servers | 39+++++++++------------------------------
1 file changed, 9 insertions(+), 30 deletions(-)

diff --git a/scripts/servers b/scripts/servers @@ -5,45 +5,24 @@ from electrum.network import DEFAULT_SERVERS, filter_protocol import time, Queue from collections import defaultdict +import util, json set_verbosity(False) config = SimpleConfig() servers = filter_protocol(DEFAULT_SERVERS,'t') -interfaces = map ( lambda server: Interface(server, config), servers ) +results = util.send_request(servers, {'method':'blockchain.headers.subscribe', 'params':[]}) -q = Queue.Queue() -results_queue = Queue.Queue() - -for i in interfaces: i.start(q) +d = defaultdict(int) -reached_servers = [] +for k, r in results.items(): + blocks = r.get('block_height') + d[blocks] += 1 -while servers: - i = q.get(timeout=1000) - servers.remove(i.server) - if i.is_connected: - i.send([('blockchain.headers.subscribe',[])], lambda i,x: results_queue.put((i,x))) - reached_servers.append(i.server) - i.status = "ok" - else: - i.status = "unreachable" -d = defaultdict(int) -while reached_servers: - i, r = results_queue.get(timeout=1000) - i.blocks = r.get('result').get('block_height') - d[i.blocks] += 1 - reached_servers.remove(i.server) +for k, v in results.items(): + print k, v.get('block_height') v = d.values() numblocks = d.keys()[v.index(max(v))] - -for i in interfaces: - if i.status == "ok": - if abs(i.blocks-numblocks)>1: i.status = "lagging" - else: - i.blocks = 0 - - print "%30s %d %s "%(i.host, i.blocks, i.status) - +print "blocks:",numblocks