コード例 #1
0
ファイル: test_register.py プロジェクト: PetarKirov/pyaleph
async def test_register_outgoing_worker(monkeypatch):
    monkeypatch.setattr(register, 'OUTGOING_WORKERS', dict())
    curlen = len(register.OUTGOING_WORKERS.keys())
    a = object()
    register_outgoing_worker('TEST', a)
    assert len(register.OUTGOING_WORKERS.keys()) == curlen + 1
    assert register.OUTGOING_WORKERS['TEST'] is a
コード例 #2
0
        messages = [
            message async for message in (await Message.get_unconfirmed_raw(
                limit=100000, for_chain=CHAIN_NAME))
        ]
        if len(messages):
            content = await get_chaindata(messages, bulk_threshold=0)
            # content = json.dumps(content)
            tx = await loop.run_in_executor(None, prepare_transfer_tx, wallet,
                                            target_addr, content)
            # tx_hash = await tx.get_hash()
            LOGGER.info("Broadcasting TX")
            await client.broadcast_msg(tx, sync=True)

        await asyncio.sleep(config.binancechain.commit_delay.value)

        i += 1


async def binance_outgoing_worker(config):
    if config.binancechain.packing_node.value:
        while True:
            try:
                await binance_packer(config)

            except Exception:
                LOGGER.exception("ERROR, relaunching outgoing in 10 seconds")
                await asyncio.sleep(10)


register_outgoing_worker(CHAIN_NAME, binance_outgoing_worker)
コード例 #3
0
ファイル: nuls2.py プロジェクト: PetarKirov/pyaleph
        await asyncio.sleep(config.nuls2.commit_delay.value)
        i += 1


async def nuls2_outgoing_worker(config):
    if config.nuls2.packing_node.value:
        while True:
            try:
                await nuls2_packer(config)

            except Exception:
                LOGGER.exception("ERROR, relaunching outgoing in 10 seconds")
                await asyncio.sleep(10)

register_outgoing_worker(CHAIN_NAME, nuls2_outgoing_worker)

@cached(ttl=60*10, cache=SimpleMemoryCache, timeout=120)
async def nuls2_balance_getter(address, config=None):
    global DECIMALS
    if config is None:
        from aleph.web import app
        config = app['config']
    server = get_server(config.nuls2.api_url.value)
    contract_address = get_server(config.nuls2.contract_address.value)
    chain_id = config.nuls2.chain_id.value
    
    if DECIMALS is None:
        response = await server.invokeView([chain_id, "decimals", "", []])
        DECIMALS = int(response['result'])        
    
コード例 #4
0
ファイル: ethereum.py プロジェクト: aleph-im/pyaleph
                contract,
                web3,
                account,
                int(gas_price * 1.1),
                nonce,
                content,
            )
            LOGGER.info("Broadcasted %r on %s" % (response, CHAIN_NAME))

        await asyncio.sleep(config.ethereum.commit_delay.value)
        i += 1


async def ethereum_outgoing_worker(config):
    if config.ethereum.packing_node.value:
        while True:
            try:
                await ethereum_packer(config)

            except Exception:
                LOGGER.exception("ERROR, relaunching outgoing in 10 seconds")
                await asyncio.sleep(10)


register_outgoing_worker(CHAIN_NAME, ethereum_outgoing_worker)


async def get_token_contract(config, web3: Web3):
    return web3.eth.contract(config.ethereum.sync_contract.value,
                             abi=await get_contract_abi())