File: persisting_a_consensus_with_parse_file.py

package info (click to toggle)
python-stem 1.8.1-2.1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 8,152 kB
  • sloc: python: 33,747; java: 312; makefile: 124; sh: 14
file content (10 lines) | stat: -rw-r--r-- 320 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
from stem.descriptor import DocumentHandler, parse_file

consensus = next(parse_file(
  '/tmp/descriptor_dump',
  descriptor_type = 'network-status-consensus-3 1.0',
  document_handler = DocumentHandler.DOCUMENT,
))

for fingerprint, relay in consensus.routers.items():
  print("%s: %s" % (fingerprint, relay.nickname))