Beispiel #1
0
def publisher():
    from cilantro.logger import get_logger
    from cilantro.utils.test import MPComposer
    from cilantro.messages.transaction.standard import StandardTransactionBuilder
    import time, os, sys

    log = get_logger("Publisher")
    sub_info = delegates[1]
    sub_info['ip'] = os.getenv('HOST_IP')

    d_info = delegates[0]
    d_info['ip'] = os.getenv('HOST_IP')

    pub = MPComposer(sk=d_info['sk'])

    # Publish on this node's own IP
    pub.add_pub(os.getenv('HOST_IP'))

    for i in range(100):
        log.critical("Sending pub")
        msg = StandardTransactionBuilder.random_tx()
        time.sleep(0.1)
        pub.send_pub_msg(filter='0', message=msg)

    log.critical("Pub Done")
    sys.exit(0)
    exit
Beispiel #2
0
def publisher():
    SLEEP_TIME = 1
    MAX_TIME = 10
    from cilantro.logger import get_logger, overwrite_logger_level
    from cilantro.utils.test import MPComposer
    from cilantro.messages.transaction.standard import StandardTransactionBuilder
    import time, os

    log = get_logger("Publisher")
    sub_info = delegates[1]
    sub_info['ip'] = os.getenv('HOST_IP')

    d_info = delegates[0]
    d_info['ip'] = os.getenv('HOST_IP')

    pub = MPComposer(sk=d_info['sk'])

    # Publish on this node's own IP
    pub.add_pub(os.getenv('HOST_IP'))

    log.critical(
        "Starting experiment, sending messages every {} seconds for a total of {} seconds"
        .format(SLEEP_TIME, MAX_TIME))
    elapsed_time = 0

    while elapsed_time < MAX_TIME:
        log.info("Sending pub")
        msg = StandardTransactionBuilder.random_tx()
        pub.send_pub_msg(filter='0', message=msg)

        time.sleep(SLEEP_TIME)
        elapsed_time += SLEEP_TIME

    pub.teardown()
    log.critical("Done with experiment!")
Beispiel #3
0
def publisher():
    SLEEP_TIME = 0.05
    MAX_TIME = 10
    from cilantro.logger import get_logger, overwrite_logger_level
    from cilantro.utils.test import MPComposer
    from cilantro.messages.transaction.contract import ContractTransactionBuilder
    from cilantro.constants.testnet import TESTNET_DELEGATES
    import time, os

    log = get_logger("Publisher")
    sub_info = TESTNET_DELEGATES[1]
    sub_info['ip'] = os.getenv('HOST_IP')

    d_info = TESTNET_DELEGATES[0]
    d_info['ip'] = os.getenv('HOST_IP')

    pub = MPComposer(sk=d_info['sk'])

    # Publish on this node's own IP
    pub.add_pub(os.getenv('HOST_IP'))

    log.important(
        "Starting experiment, sending messages every {} seconds for a total of {} seconds"
        .format(SLEEP_TIME, MAX_TIME))
    elapsed_time = 0

    while elapsed_time < MAX_TIME:
        log.notice("Sending pub")
        msg = ContractTransactionBuilder.random_currency_tx()
        pub.send_pub_msg(filter='0', message=msg)

        time.sleep(SLEEP_TIME)
        elapsed_time += SLEEP_TIME

    pub.teardown()
    log.important("Done with experiment!")