main_peerblocks.py 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/usr/bin/env python3
  2. #
  3. # mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
  4. # Copyright (C)2013-2021 The MMGen Project <mmgen@tuta.io>
  5. #
  6. # This program is free software: you can redistribute it and/or modify it under
  7. # the terms of the GNU General Public License as published by the Free Software
  8. # Foundation, either version 3 of the License, or (at your option) any later
  9. # version.
  10. #
  11. # This program is distributed in the hope that it will be useful, but WITHOUT
  12. # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  13. # FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  14. # details.
  15. #
  16. # You should have received a copy of the GNU General Public License along with
  17. # this program. If not, see <http://www.gnu.org/licenses/>.
  18. """
  19. mmnode-peerblocks: List blocks in flight, disconnect stalling nodes
  20. """
  21. opts_data = {
  22. 'text': {
  23. 'desc': 'List blocks in flight, disconnect stalling nodes',
  24. 'usage': '[opts]',
  25. 'options': """
  26. -h, --help Print this help message
  27. --, --longhelp Print help message for long options (common options)
  28. """
  29. }
  30. }
  31. async def main():
  32. from mmgen.cfg import Config
  33. cfg = Config(opts_data=opts_data)
  34. from mmgen.rpc import rpc_init
  35. rpc = await rpc_init(cfg,ignore_wallet=True)
  36. from .PeerBlocks import BlocksDisplay,PeersDisplay
  37. blocks = BlocksDisplay(cfg)
  38. peers = PeersDisplay(cfg)
  39. while True:
  40. await blocks.run(rpc)
  41. await peers.run(rpc)
  42. from mmgen.util import async_run
  43. async_run(main())