Ejemplo n.º 1
0
def compress_five_minute():
    FiveMinuteShare.compress()
    FiveMinuteReject.compress()
    FiveMinuteTemperature.compress()
    FiveMinuteHashrate.compress()
    FiveMinuteType.compress()
    db.session.commit()
def compress_five_minute():
    FiveMinuteShare.compress()
    FiveMinuteReject.compress()
    FiveMinuteTemperature.compress()
    FiveMinuteHashrate.compress()
    FiveMinuteType.compress()
    db.session.commit()
Ejemplo n.º 3
0
def historical_update(blockheight):
    """ Very long running task. Fills out the network difficulty values for all
    blocks before the site was running. """

    def add_one_minute_diff(diff, time):
        try:
            m = OneMinuteType(typ='netdiff', value=diff, time=time)
            db.session.add(m)
            db.session.commit()
        except sqlalchemy.exc.IntegrityError:
            db.session.rollback()
            slc = OneMinuteType.query.with_lockmode('update').filter_by(
                time=time, typ='netdiff').one()
            # just average the diff of two blocks that occured in the same second..
            slc.value = (diff + slc.value) / 2
            db.session.commit()

    for ht in xrange(blockheight, 0, -1):
        hsh = coinserv.getblockhash(ht)
        info = coinserv.getblock(hsh)
        add_one_minute_diff(info['difficulty'] * 1000,
                            datetime.datetime.utcfromtimestamp(info['time']))
        current_app.logger.info("Processed block height {}".format(ht))

    db.session.commit()
    OneMinuteType.compress()
    db.session.commit()
    FiveMinuteType.compress()
    db.session.commit()
Ejemplo n.º 4
0
def historical_update(blockheight):
    """ Very long running task. Fills out the network difficulty values for all
    blocks before the site was running. """
    def add_one_minute_diff(diff, time):
        try:
            m = OneMinuteType(typ='netdiff', value=diff, time=time)
            db.session.add(m)
            db.session.commit()
        except sqlalchemy.exc.IntegrityError:
            db.session.rollback()
            slc = OneMinuteType.query.with_lockmode('update').filter_by(
                time=time, typ='netdiff').one()
            # just average the diff of two blocks that occured in the same second..
            slc.value = (diff + slc.value) / 2
            db.session.commit()

    for ht in xrange(blockheight, 0, -1):
        hsh = coinserv.getblockhash(ht)
        info = coinserv.getblock(hsh)
        add_one_minute_diff(info['difficulty'] * 1000,
                            datetime.datetime.utcfromtimestamp(info['time']))
        current_app.logger.info("Processed block height {}".format(ht))

    db.session.commit()
    OneMinuteType.compress()
    db.session.commit()
    FiveMinuteType.compress()
    db.session.commit()
Ejemplo n.º 5
0
def compress_five_minute(self):
    try:
        FiveMinuteShare.compress()
        FiveMinuteReject.compress()
        FiveMinuteTemperature.compress()
        FiveMinuteHashrate.compress()
        FiveMinuteType.compress()
        db.session.commit()
    except Exception:
        logger.error("Unhandled exception in compress_five_minute", exc_info=True)
        db.session.rollback()