mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-23 17:47:31 +00:00
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.
28 lines
605 B
Python
Executable file
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
|