Exemplo n.º 1
0
def assign_points(conn, cursor, date):
    """Returns the number of points awarded for the given size,
    uptime, and duration."""
    cursor.execute('''SELECT auth_address FROM summaries WHERE date=?''',
                   (str(date),))
    address_list = cursor.fetchall()
    for address in address_list:
        address = ''.join(address)
        cursor.execute('''SELECT auth_address, uptime, duration, height FROM summaries
                       WHERE auth_address = ? AND date = ?''',
                       (str(address), str(date),))
        data = cursor.fetchone()
        address = data[0]
        uptime = data[1]
        duration = data[2]
        size = data[3]
        if duration == 0:
            points = 0
        else:
            points = (payments.height_function(size / 199999) *
                  payments.uptime_logistic_function(uptime/duration) *
                  (duration / 86400))
        cursor.execute('UPDATE summaries SET points = ? WHERE auth_address = ?'
                       'AND date = ?', (points, str(address), str(date),))
        conn.commit()
Exemplo n.º 2
0
 def test_uptime_logistic_function(self):
     uptime = 0.5
     value = payments.uptime_logistic_function(uptime)
     self.assertTrue(isinstance(value, float))