Ejemplo n.º 1
0
def listEvents(conn, app, event, poolId, startTime):
    # logger.info("in listevents method")
    size = 500
    subType = None
    if "size" in event["queryStringParameters"]:
        size = int(event["queryStringParameters"]["size"])
    if "subType" in event["queryStringParameters"]:
        subType = event["queryStringParameters"]["subType"]

    # logger.info("params are: {}, {}".format(poolId, subType))
    sql = listEventsSql(poolId, None, size, subType)

    params = ()
    if poolId:
        if subType and subType != "others" and subType != "large" and subType != "val" and subType != "fee":
            params = (poolId, subType)
        else:
            params = poolId
        data = dbUtil.listResultsWithConn(sql, conn, params)
        val = harmonyData.getHPoolById(conn, poolId)
        return dbUtil.combineResults2("val", val, "data", data)
    else:
        if subType and subType != "others" and subType != "large" and subType != "val" and subType != "fee":
            params = subType
        return dbUtil.listResultsWithResponseWithConn(sql, conn, params)
Ejemplo n.º 2
0
def listAllAddresses(conn, app):
    sql = "select * "
    sql += " from " + tables.haddress
    sql += " order by addressBalance desc "

    # logger.info(sql)

    return dbUtil.listResultsWithResponseWithConn(sql, conn)
Ejemplo n.º 3
0
def listAllAddressesBasic(conn, app):
    sql = "select addressId, address, addressBalance, txCount, ranking "
    sql += " from " + tables.haddress
    sql += " order by ranking desc "

    # logger.info(sql)

    return dbUtil.listResultsWithResponseWithConn(sql, conn)
Ejemplo n.º 4
0
def listAllDelegates(conn, app):
    sql = "select hd.poolDelId, h.hPoolId, hd.address, hd.stake, hd.reward,  "
    sql += " h.lastUpdated, h.address as validator "
    sql += " from " + tables.hpooldel + " hd "
    sql += " inner join " + tables.hpool + " h "
    sql += " on h.hPoolId=hd.hPoolId "

    # logger.info(sql)

    return dbUtil.listResultsWithResponseWithConn(sql, conn)
Ejemplo n.º 5
0
def lambda_handler(event, context):
    startTime = datetime.datetime.now()

    conn, accessKey, error = accessKeyUtils.performCheckAndGetConn(
        event, constants.app, fnName)
    if error:
        logger.info(error)
        return error

    status = None
    if "status" in event["queryStringParameters"]:
        status = event["queryStringParameters"]["status"]
    sql, args = listHPoolsSql(status)
    logger.info(args)
    data = dbUtil.listResultsWithResponseWithConn(sql, conn, args)
    logger.info(data)

    auditUtils.auditSimple(conn, constants.app, startTime, fnName, accessKey)
    conn.close()
    return data
Ejemplo n.º 6
0
def listStakeHistoryChartData(conn, app, dataType, hPoolId=None, address=None):
	# sql = "select date(procDate) as title, round(totalStake/" + factor + ", 3) as value from "
	sql = "select epoch, value1, value2, value3, value4, value5, value6 from "
	sql += tables.hhistory
	sql += " where dataType=%s "

	args = (dataType)
	if hPoolId is not None:
		sql += " and hPoolId = %s "
		args = (dataType, hPoolId)
	elif address is not None:
		sql += " and address = %s "
		args = (dataType, address)
	sql += " order by epoch "
	# logger.info(sql)
	# logger.info(args)

	if hPoolId is None:
		return dbUtil.listResultsWithResponseWithConn(sql, conn, args)
	else:
		data = dbUtil.listResultsWithConn(sql, conn, args)
		validator = harmonyData.getHPoolById(conn, hPoolId)
		return dbUtil.combineResults2("validator", validator, "data", data)
Ejemplo n.º 7
0
def listAllValidatorsBasic(conn):
    sql, args = listHPoolsSql(None)
    # logger.info(args)
    data = dbUtil.listResultsWithResponseWithConn(sql, conn)
    return data
Ejemplo n.º 8
0
def listValKeys(conn):
    sql = "select blsKey, hPoolId from "
    sql += tables.hblskey

    return dbUtil.listResultsWithResponseWithConn(sql, conn)