Ejemplo n.º 1
0
def subscription_loop():
    bestblockhash = None
    mempool = []

    while True:
        data = General().info()
        if "result" in data:
            if "bestblockhash" in data["result"]:
                if data["result"]["bestblockhash"] != bestblockhash:
                    bestblockhash = data["result"]["bestblockhash"]

                    sio.emit("block.update",
                             utils.response({
                                 "height": data["result"]["blocks"],
                                 "hash": bestblockhash
                             }),
                             room="blocks")

                    updates = Block().inputs(bestblockhash)
                    for address in updates:
                        mempool = list(set(mempool) - set(updates[address]))

                        sio.emit("address.update",
                                 utils.response({
                                     "address":
                                     address,
                                     "tx":
                                     updates[address],
                                     "height":
                                     data["result"]["blocks"],
                                     "hash":
                                     bestblockhash
                                 }),
                                 room=address)

                data = General().mempool()
                temp_mempool = []

                if not data["error"]:
                    updates = Transaction.addresses(data["result"]["tx"])
                    for address in updates:
                        updates[address] = list(
                            set(updates[address]) - set(mempool))
                        temp_mempool += updates[address]

                        if len(updates[address]) > 0:
                            sio.emit("address.update",
                                     utils.response({
                                         "address": address,
                                         "tx": updates[address],
                                         "height": None,
                                         "hash": None
                                     }),
                                     room=address)

                mempool = list(set(mempool + temp_mempool))

        sio.sleep(0)
Ejemplo n.º 2
0
def init():
    bestblockhash = None

    while True:
        data = General().info()
        if data['result']['bestblockhash'] != bestblockhash:
            bestblockhash = data['result']['bestblockhash']
            sio.emit('block.update',
                     utils.response({
                         'height': data['result']['blocks'],
                         'hash': bestblockhash
                     }),
                     room='blocks')

            updates = Block().inputs(bestblockhash)
            for address in updates:
                mempool = list(set(state.mempool) - set(updates[address]))
                if address in state.rooms:
                    sio.emit('address.update',
                             utils.response({
                                 'address': address,
                                 'tx': updates[address],
                                 'height': data['result']['blocks'],
                                 'hash': bestblockhash
                             }),
                             room=address)

        data = General().mempool()
        updates = Transaction().addresses(data['result']['tx'])
        temp_mempool = []
        for address in updates:
            updates[address] = list(set(updates[address]) - set(mempool))
            temp_mempool += updates[address]
            if address in state.rooms:
                if len(updates[address]) > 0:
                    sio.emit('address.update',
                             utils.response({
                                 'address': address,
                                 'tx': updates[address],
                                 'height': None,
                                 'hash': None
                             }),
                             room=address)

        mempool = list(set(mempool + temp_mempool))
Ejemplo n.º 3
0
def blocks_range(height):
    data = General().info()
    blocks = []

    if not height:
        height = data["result"]["blocks"]

    data = Block().range(height, config.block_page)

    for block in data:
        blocks.append(Esplora().block(block))

    return jsonify(blocks)
Ejemplo n.º 4
0
def mempool_recent():
    data = General().mempool()
    result = []

    for txid in data["result"]["tx"]:
        transaction = Transaction().info(txid)["result"]
        item = Esplora().transaction(transaction)

        result.append({
            "txid": item["txid"],
            "fee": item["fee"],
            "vsize": item["weight"],
            "value": item["value"]
        })

    return jsonify(result)
Ejemplo n.º 5
0
 def get(self):
     data = General().price()
     return utils.response(data["sugarchain"])
Ejemplo n.º 6
0
 def get(self):
     return General().mempool()
Ejemplo n.º 7
0
def supply_plain():
    data = int(utils.amount(General().supply()["supply"]))
    return Response(str(data), mimetype="text/plain")
Ejemplo n.º 8
0
def price():
    data = General().price()
    return jsonify(utils.response(data["sugarchain"]))
Ejemplo n.º 9
0
def get_info():
    return jsonify(General().info())
Ejemplo n.º 10
0
def supply():
    data = General().supply()
    return jsonify(utils.response(data))
Ejemplo n.º 11
0
def EstimateFee():
    return General.fee()
Ejemplo n.º 12
0
def price():
    data = General.price()
    return jsonify(utils.response(data["microbitcoin"]))
Ejemplo n.º 13
0
 def get(self):
     return General().info()
Ejemplo n.º 14
0
 def get(self):
     data = General().supply()
     return utils.response(data)
Ejemplo n.º 15
0
def plain_tip_height():
    data = General().info()
    return Response(str(data["result"]["blocks"]), mimetype="text/plain")
Ejemplo n.º 16
0
 def get(self):
     data = General().price()
     return utils.response(data['beyondcoin'])
Ejemplo n.º 17
0
 def get(self):
     data = General().price()
     return utils.response(data['mochimo'])
Ejemplo n.º 18
0
def getprice():
    data = General().getprice()
    return jsonify(utils.response(data))
Ejemplo n.º 19
0
    def get(self):
        parser = reqparse.RequestParser()
        parser.add_argument("currency", type=str, default="RPD")
        args = parser.parse_args()

        return General().price(args["currency"])
Ejemplo n.º 20
0
 def get(self):
     return General().fee()
Ejemplo n.º 21
0
def mempool_info():
    return jsonify(General().mempool())
Ejemplo n.º 22
0
 def get(self):
     data = int(utils.amount(General().supply()['supply']))
     return Response(str(data), mimetype='text/plain')
Ejemplo n.º 23
0
def estimate_fee():
    return jsonify(General().fee())
Ejemplo n.º 24
0
def GetInfo():
    return General.info()
Ejemplo n.º 25
0
def GetPrice(currency="RPD"):
    return General().price(currency)