LBRY-Vault/scripts/servers
Neil Booth 6f1367fea6 Unify message IDs between network and interfaces
Previously network.py had its own idea of request IDs,
and each interface had its own which was sent on the wire.
The interface would jump through hoops to translate one
to the other.

This unifies them so that a message ID is passed when
queueing a request, in addition to the method and params.
network.py is now solely responsible for message ID management.

Apart from being simpler and clearer, this also should be faster
as there is much less data structure manipulation and rebuilding
happening.
2015-09-09 21:00:25 +09:00

28 lines
605 B
Python
Executable file

#!/usr/bin/env python
from electrum import SimpleConfig, set_verbosity
from electrum.network import filter_protocol
import time, Queue
from collections import defaultdict
import util, json
set_verbosity(False)
config = SimpleConfig()
servers = filter_protocol(protocol = 't')
results = util.send_request(servers, 'blockchain.headers.subscribe', [])
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