示例#1
0
def has_funds_for_transactions() -> bool:
    try:
        current_funds = float(storage.get("BROADCAST/CURRENT_FUNDS").decode("utf-8"))
        estimated_transaction_fee = INTERCHAIN.get_transaction_fee_estimate()

        if (estimated_transaction_fee * TRANSACTION_BUFFER) < current_funds:
            _log.info("[L5] You have enough funds!")
            return True
        else:
            global FUNDED
            if FUNDED:
                _log.info("[L5] Low on funds, deregistering node from matchmaking")
                matchmaking.update_funded_flag(False)
                FUNDED = False
            return False
    except exceptions.NotFound:
        return False
示例#2
0
def watch_for_funds() -> None:
    _log.info("[L5] Watching for funds")
    current_funds = INTERCHAIN.check_balance()
    _log.info(f"[L5] raw balance: {current_funds}")

    set_funds(current_funds)
    set_last_watch_time()

    estimated_transaction_fee = INTERCHAIN.get_transaction_fee_estimate()

    global FUNDED
    _log.info("[L5] Checking if should update funded flag...")
    _log.info(
        f"[L5] Deregistered: {FUNDED}\tEstimated Fee: {estimated_transaction_fee}\tTransaction Buffer: {TRANSACTION_BUFFER}\tCurrent Funds: {current_funds}"
    )
    if not FUNDED and (estimated_transaction_fee * TRANSACTION_BUFFER) < current_funds:
        _log.info("[L5] Updating metadata!")
        matchmaking.update_funded_flag(True)
        FUNDED = True