You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
658 B
28 lines
658 B
#!/usr/bin/env python
|
|
|
|
from electrum import Interface, SimpleConfig, set_verbosity
|
|
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')
|
|
results = util.send_request(servers, {'method':'blockchain.headers.subscribe', 'params':[]})
|
|
|
|
d = defaultdict(int)
|
|
|
|
for k, r in results.items():
|
|
blocks = r.get('block_height')
|
|
d[blocks] += 1
|
|
|
|
|
|
|
|
for k, v in results.items():
|
|
print k, v.get('block_height')
|
|
|
|
v = d.values()
|
|
numblocks = d.keys()[v.index(max(v))]
|
|
print "blocks:",numblocks
|
|
|