Exemplo n.º 1
0
def output_transaction(
        transaction: transaction_model.TransactionModel) -> None:
    _log.info("Enqueueing to transaction processor")
    new_transaction = json.dumps(transaction.export_as_queue_task(),
                                 separators=(",", ":"))
    pushed = redis.lpush_sync("dc:tx:incoming", new_transaction)
    if pushed == 0:
        _log.info("Could not output transaction")
        raise exceptions.LedgerError("Error outputting contract data on chain")
    else:
        _log.info("Successfully enqueued SC response as transaction")
Exemplo n.º 2
0
def begin_task(sc_model: "smart_contract_model.SmartContractModel",
               task_type: "smart_contract_model.ContractActions") -> None:
    """Notify builder service to begin a task via message queue
    Args:
        sc_model (obj): Start an invocation of this smart contract
        task_type (Enum, optional): Task type of this invocation
    Raises:
        RuntimeError: When failing to begin a task by pushing to redis
    """
    if redis.lpush_sync(
            "mq:contract-task",
            json.dumps(sc_model.export_as_contract_task(task_type=task_type),
                       separators=(",", ":"))) == 0:
        raise RuntimeError("Failed to push to job MQ")
Exemplo n.º 3
0
 def test_lpush(self):
     redis.lpush_sync("banana", "banana", "banana")
     redis.redis_client.lpush.assert_called_once_with("banana", "banana", "banana")