Example #1
0
#!/usr/bin/env python3
import json
import asyncio

from electrum_firo.simple_config import SimpleConfig
from electrum_firo.network import filter_version, Network
from electrum_firo.util import create_and_start_event_loop, log_exceptions
from electrum_firo import constants

# testnet?
#constants.set_testnet()
config = SimpleConfig({'testnet': False})

loop, stopping_fut, loop_thread = create_and_start_event_loop()
network = Network(config)
network.start()


@log_exceptions
async def f():
    try:
        peers = await network.get_peers()
        peers = filter_version(peers)
        print(json.dumps(peers, sort_keys=True, indent=4))
    finally:
        stopping_fut.set_result(1)


asyncio.run_coroutine_threadsafe(f(), loop)
Example #2
0
 def setUp(self):
     super().setUp()
     self.asyncio_loop, self._stop_loop, self._loop_thread = util.create_and_start_event_loop()
 def setUp(self):
     super().setUp()
     self.asyncio_loop, self._stop_loop, self._loop_thread = create_and_start_event_loop(
     )
     self.config = SimpleConfig({'electrum_path': self.electrum_path})
Example #4
0
from electrum_firo.network import Network
from electrum_firo.util import print_msg, create_and_start_event_loop
from electrum_firo.synchronizer import SynchronizerBase
from electrum_firo.simple_config import SimpleConfig


try:
    addr = sys.argv[1]
except Exception:
    print("usage: watch_address <dash_address>")
    sys.exit(1)

config = SimpleConfig()

# start network
loop = create_and_start_event_loop()[0]
network = Network(config)
network.start()


class Notifier(SynchronizerBase):
    def __init__(self, network):
        SynchronizerBase.__init__(self, network)
        self.watched_addresses = set()
        self.watch_queue = asyncio.Queue()

    async def main(self):
        # resend existing subscriptions if we were restarted
        for addr in self.watched_addresses:
            await self._add_address(addr)
        # main loop