Ejemplo n.º 1
0
 def __init__(self):
     self._red = get_redis_conn()
     self._pg = get_postgres_conn()
     self._logger = get_logger('web')
Ejemplo n.º 2
0
def balance():
    return float(rpc.getbalance(account='', minconf=120)) - config['serverMin']

logger = get_logger('payout')

while True:
    try:
        logger.info('Connecting to dogecoind')
        rpc = bitcoinrpc.connect_to_remote(config['dogecoindUser'], config['dogecoindPass'], config['dogecoindHost'], config['dogecoindPort'])

        # reserve an amount for transaction fees
        block_count = rpc.getblockcount()
        block_value = subsidy_func(block_count)

        conn = get_postgres_conn()
        cur = conn.cursor()

        logger.info('Block value: ' + str(block_value))
        logger.info('Server balance: ' + str(balance()))

        def pay_pending():
            # try and pay outstanding tids
            conn.set_session('serializable')
            cur.execute('SELECT id, total FROM transactions WHERE txid is NULL;')
            # we can do a join but there's no point, since we'll need to split it anyway
            pending_tids = cur.fetchall();
            logger.info('Pending tids: ' + str(pending_tids))

            for tid, total in pending_tids:
                if balance() < total:
Ejemplo n.º 3
0
 def __init__(self):
     self._red = get_redis_conn()
     self._pg = get_postgres_conn()
     self._logger = get_logger('web')