예제 #1
0
def listPoolsSummary(conn, app):
    sql, args = listHPoolsSql(None)
    # logger.info(args)
    data = dbUtil.listResultsWithConn(sql, conn, args)
    # logger.info(data)
    coinStat = commonUtils.getCoinStat(conn, app)
    return dbUtil.combineResults2("data", data, "coinStat", coinStat)
예제 #2
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)
예제 #3
0
def listDataForEpochSign(conn, app):
    sql, args = listHPoolsSql(None)
    # logger.info(args)
    data = dbUtil.listResultsWithConn(sql, conn)
    syncStatus = commonUtils.getSyncStatus(
        conn, app, constants.SYNC_STATUS_EPOCH_FOR_SIGN)
    epoch = syncStatus["syncedTillEpoch"]
    return dbUtil.combineResults2("validators", data, "epoch", epoch)
예제 #4
0
def listBlsKeySyncDetails(conn, app):
    sql, args = harmonyData.listHPoolsSql(None)
    validators = dbUtil.listResultsWithConn(sql, conn)
    keys = listBlsKeys(conn)
    # shards = listLatestShardDelay(conn)

    # return dbUtil.combineResults3("validators", validators, "keys", keys, "shards", shards)
    return dbUtil.combineResults2("validators", validators, "keys", keys)
예제 #5
0
def listVersionStats(conn):
    startTime = commonUtils.getCurrentTime()

    nodeVersionSummary = listNodeVersionSummary(conn)
    commonUtils.logTimeDiff(startTime, "after nodeVersionSummary")

    nodeVersions = listNodeVersions(conn)
    commonUtils.logTimeDiff(startTime, "after nodeVersions")

    return dbUtil.combineResults2("nodeVersionSummary", nodeVersionSummary,
                                  "nodeVersions", nodeVersions)
예제 #6
0
def listHPoolsApr(conn, app):
    sql = " select hPoolId as code, "
    sql += " concat(trim(replace(left(name, 29), '?','')), ' - ', status, ' - ', "
    sql += " (case when avgApr is null then 0 else avgApr end)) as description, "
    sql += " avgApr, avgNetApr, (fee * 100) as fee "
    sql += " from " + tables.hpool + " p "
    sql += " where status != %s "
    sql += " having description is not null "
    sql += " order by description "
    # logger.info(sql)
    data = dbUtil.listResultsWithConn(sql, conn, hConstants.H_NOT_ELIGIBLE)

    coinStat = commonUtils.getCoinStat(conn, app)
    return dbUtil.combineResults2("data", data, "coinStat", coinStat)
예제 #7
0
def listDelegates(conn, app, hPoolId):
    sql = " select ad.ranking, p.name, pd.address, round(pd.stake,0) as stake, round(reward,0) as reward "
    sql += " from " + tables.hpool + " p "
    sql += " inner join " + tables.hpooldel + " pd on pd.hPoolId=p.hPoolId"
    sql += " inner join " + tables.haddress + " ad on ad.address=pd.address"
    sql += " where p.hPoolId = %s "
    sql += " and pd.stake > " + MIN_AMOUNT
    sql += " order by pd.stake desc "

    # logger.info(sql)

    data = dbUtil.listResultsWithConn(sql, conn, (str(hPoolId)))
    # logger.info("getting pool details")
    val = getHPoolById(conn, hPoolId)
    return dbUtil.combineResults2("val", val, "data", data)
def listHealthCheckData(conn, app, event, startTime):
    # logger.info("obtaining health check data from database - " + app)
    sql = " select healthid, nodeName, symbol, UNIX_TIMESTAMP(checkupTime) as cTime, "
    sql += " DATE_FORMAT(checkupTime,'%%Y-%%m-%%d %%H:%%i:%%s') as checkupTime, "
    sql += " networkBlockHeight, nodeBlockHeight, heightGap, shardId, epochTimestamp, "
    sql += " round(time_to_sec((TIMEDIFF(NOW(), checkupTime))) / 60,0) as elapsedTime "
    sql += " from " + tables.nodehealth + " w "
    sql += " where symbol = %s "
    sql += " order by cTime desc"
    sql += " limit 50"
    # logger.info(sql)

    activities = dbUtil.listResultsWithConn(sql, conn, app)
    pool = None

    auditUtils.audit(conn, app, event, "listHealthCheckData", "get", startTime, None)
    return dbUtil.combineResults2("pool", pool, "activities", activities)
예제 #9
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)
예제 #10
0
def listNetworkStats(conn, app):
	coinStat = commonUtils.getCoinStat(conn, app)

	shardData = harmonyShard.getShardDataFromDB(conn)

	return dbUtil.combineResults2("coinStat", coinStat, "shardData", shardData)
예제 #11
0
def getShardSyncInputDetails(conn):
	epochNumber = commonUtils.getEventDescriptionInt(conn, eventName.lastHarmonyShardSyncDetails)
	shardData = getShardDataFromDB(conn)

	return dbUtil.combineResults2("epochNumber", epochNumber, "shardData", shardData)