def setUp(self):
     super().setUp()
     self.asyncio_loop, self._stop_loop, self._loop_thread = create_and_start_event_loop()
     self.config = SimpleConfig({'actilectrum_pathathathatactilectrum_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_pathm_path})
from actilectrum.network import Network
from actilectrum.util import print_msg, create_and_start_event_loop
from actilectrum.synchronizer import SynchronizerBase
from actilectrum.simple_config import SimpleConfig

try:
    addr = sys.argv[1]
except Exception:
    print("usage: watch_address <actinium_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
Example #3
0
#!/usr/bin/env python3
import json
import asyncio

from actilectrum.simple_config import SimpleConfig
from actilectrum.network import filter_version, Network
from actilectrum.util import create_and_start_event_loop, log_exceptions
from actilectrum 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)
 def setUp(self):
     super().setUp()
     self.asyncio_loop, self._stop_loop, self._loop_thread = create_and_start_event_loop(
     )