Ejemplo n.º 1
0
def iterate_name_updates(store, logger, chain_id):
    for height, tx_pos, txout_pos, from_pubkey_id, to_pubkey_id, script in store.selectall(
            """
          SELECT cc.block_height, bt.tx_pos, out1.txout_pos,
          out2.pubkey_id, out1.pubkey_id, out1.txout_scriptPubKey
          FROM chain_candidate cc
          JOIN block_tx bt ON (cc.block_id = bt.block_id)
          JOIN txout out1 ON (bt.tx_id = out1.tx_id)
          JOIN tx ON (tx.tx_id = out1.tx_id)
          JOIN txin ON (tx.tx_id = txin.tx_id)
          JOIN txout out2 ON (txin.txout_id = out2.txout_id)
          WHERE cc.chain_id = ?
          AND out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?
          AND ((out2.txout_scriptPubKey >= ? AND out2.txout_scriptPubKey < ?)
          OR (out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?))
          ORDER BY cc.block_height, bt.tx_pos, out1.txout_pos""",
        (chain_id, store.binin(NAME_SCRIPT_MIN), store.binin(NAME_SCRIPT_MAX),
         store.binin(NAME_SCRIPT_MIN), store.binin(NAME_SCRIPT_MAX),
         store.binin(NAME_SCRIPT_MIN), store.binin('\x52'))):
        height = int(height)
        tx_pos = int(tx_pos)
        txout_pos = int(txout_pos)
        tx_type = -1

        i = script_GetOp(store.binout(script))

        nameNewDict = {}

        try:
            name_op = i.next()[0]
            if name_op == NAME_NEW:
                tx_hash = i.next()[1]
                if tx_hash not in nameNewDict:
                    nameNewDict[tx_hash] = True
                    yield NameNew(height, tx_pos, txout_pos, from_pubkey_id,
                                  to_pubkey_id, tx_hash)
            elif name_op == NAME_FIRSTUPDATE:
                tx_type = 1
                raw_name = i.next()[1]
                name = raw_name.decode("ISO-8859-1")
                tx_rand = i.next()[1]
                value = i.next()[1]
                tx_hash = hash160(tx_rand + raw_name)
                yield NameFirstUpdate(height, tx_pos, txout_pos,
                                      from_pubkey_id, to_pubkey_id, name,
                                      tx_rand, value, tx_hash)
            elif name_op == NAME_UPDATE:
                raw_name = i.next()[1]
                name = raw_name.decode("ISO-8859-1")
                value = i.next()[1]
                yield NameUpdate(height, tx_pos, txout_pos, from_pubkey_id,
                                 to_pubkey_id, name, value)
            else:
                logger.warning("Unexpected first op: %s", repr(name_op))
                continue
        except StopIteration:
            logger.warning("Strange script at %d:%d:%d", height, tx_pos,
                           txout_pos)
            continue
Ejemplo n.º 2
0
def iterate_name_updates(store, logger, chain_id):


##"""
#            SELECT cc.block_height, bt.tx_pos, txout.txout_pos,
#            txout.txout_scriptPubKey
#            FROM chain_candidate cc
#            JOIN block_tx bt ON (cc.block_id = bt.block_id)
#            JOIN txout ON (bt.tx_id = txout.tx_id)
#            WHERE cc.chain_id = ?
#            AND txout_scriptPubKey >= ? AND txout_scriptPubKey < ?
#            ORDER BY cc.block_height, bt.tx_pos, txout.txout_pos""" 


    for height, from_pubkey_id, to_pubkey_id, script in store.selectall("""
          SELECT cc.block_height, out2.pubkey_id, out1.pubkey_id,
            out1.txout_scriptPubKey
          FROM chain_candidate cc
          JOIN block_tx bt ON (cc.block_id = bt.block_id)
          JOIN txout out1 ON (bt.tx_id = out1.tx_id)
          JOIN tx ON (tx.tx_id = out1.tx_id)
          JOIN txin ON (tx.tx_id = txin.tx_id)
          JOIN txout out2 ON (txin.txout_id = out2.txout_id)
          WHERE cc.chain_id = ?
          AND out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?
          AND ((out2.txout_scriptPubKey >= ? AND out2.txout_scriptPubKey < ?)
          OR (out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?))
          ORDER BY cc.block_height, bt.tx_pos, out1.txout_pos""",
                                     (chain_id, store.binin(NAME_SCRIPT_MIN),
                                      store.binin(NAME_SCRIPT_MAX), store.binin(NAME_SCRIPT_MIN),
                                      store.binin(NAME_SCRIPT_MAX), store.binin(NAME_SCRIPT_MIN),
                                      store.binin('\x52'))):
        height = int(height)

        i = script_GetOp(store.binout(script))
        try:
            name_op = i.next()[0]
            if name_op == NAME_NEW:
                continue  # no effect on name map
            elif name_op == NAME_FIRSTUPDATE:
                
                is_first = True
                name = i.next()[1] #
                newtx_hash = i.next()[1]
                #rand = i.next()[1]  # XXX documented as optional; is it?
                value = i.next()[1]
            elif name_op == NAME_UPDATE:
                is_first = False
                name = i.next()[1]
                value = i.next()[1]
            else:
                logger.warning("Unexpected first op: %s", repr(name_op))
                continue
        except StopIteration:
            logger.warning("Strange script at %d:%d:%d",
                           height, from_pubkey_id, to_pubkey_id)
            continue
        yield (height, from_pubkey_id, to_pubkey_id, is_first, name, value)
Ejemplo n.º 3
0
def iterate_name_updates(store, logger, chain_id):

    ##"""
    #            SELECT cc.block_height, bt.tx_pos, txout.txout_pos,
    #            txout.txout_scriptPubKey
    #            FROM chain_candidate cc
    #            JOIN block_tx bt ON (cc.block_id = bt.block_id)
    #            JOIN txout ON (bt.tx_id = txout.tx_id)
    #            WHERE cc.chain_id = ?
    #            AND txout_scriptPubKey >= ? AND txout_scriptPubKey < ?
    #            ORDER BY cc.block_height, bt.tx_pos, txout.txout_pos"""

    for height, from_pubkey_id, to_pubkey_id, script in store.selectall(
            """
          SELECT cc.block_height, out2.pubkey_id, out1.pubkey_id,
            out1.txout_scriptPubKey
          FROM chain_candidate cc
          JOIN block_tx bt ON (cc.block_id = bt.block_id)
          JOIN txout out1 ON (bt.tx_id = out1.tx_id)
          JOIN tx ON (tx.tx_id = out1.tx_id)
          JOIN txin ON (tx.tx_id = txin.tx_id)
          JOIN txout out2 ON (txin.txout_id = out2.txout_id)
          WHERE cc.chain_id = ?
          AND out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?
          AND ((out2.txout_scriptPubKey >= ? AND out2.txout_scriptPubKey < ?)
          OR (out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?))
          ORDER BY cc.block_height, bt.tx_pos, out1.txout_pos""",
        (chain_id, store.binin(NAME_SCRIPT_MIN), store.binin(NAME_SCRIPT_MAX),
         store.binin(NAME_SCRIPT_MIN), store.binin(NAME_SCRIPT_MAX),
         store.binin(NAME_SCRIPT_MIN), store.binin('\x52'))):
        height = int(height)

        i = script_GetOp(store.binout(script))
        try:
            name_op = i.next()[0]
            if name_op == NAME_NEW:
                continue  # no effect on name map
            elif name_op == NAME_FIRSTUPDATE:

                is_first = True
                name = i.next()[1]  #
                newtx_hash = i.next()[1]
                #rand = i.next()[1]  # XXX documented as optional; is it?
                value = i.next()[1]
            elif name_op == NAME_UPDATE:
                is_first = False
                name = i.next()[1]
                value = i.next()[1]
            else:
                logger.warning("Unexpected first op: %s", repr(name_op))
                continue
        except StopIteration:
            logger.warning("Strange script at %d:%d:%d", height,
                           from_pubkey_id, to_pubkey_id)
            continue
        yield (height, from_pubkey_id, to_pubkey_id, is_first, name, value)
def iterate_name_updates(store, logger, chain_id):
    for height, tx_pos, txout_pos, from_pubkey_id, to_pubkey_id, script in store.selectall("""
          SELECT cc.block_height, bt.tx_pos, out1.txout_pos,
          out2.pubkey_id, out1.pubkey_id, out1.txout_scriptPubKey
          FROM chain_candidate cc
          JOIN block_tx bt ON (cc.block_id = bt.block_id)
          JOIN txout out1 ON (bt.tx_id = out1.tx_id)
          JOIN tx ON (tx.tx_id = out1.tx_id)
          JOIN txin ON (tx.tx_id = txin.tx_id)
          JOIN txout out2 ON (txin.txout_id = out2.txout_id)
          WHERE cc.chain_id = ?
          AND out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?
          AND ((out2.txout_scriptPubKey >= ? AND out2.txout_scriptPubKey < ?)
          OR (out1.txout_scriptPubKey >= ? AND out1.txout_scriptPubKey < ?))
          ORDER BY cc.block_height, bt.tx_pos, out1.txout_pos""",
                                     (chain_id, store.binin(NAME_SCRIPT_MIN),
                                      store.binin(NAME_SCRIPT_MAX), store.binin(NAME_SCRIPT_MIN),
                                      store.binin(NAME_SCRIPT_MAX), store.binin(NAME_SCRIPT_MIN),
                                      store.binin('\x52'))):
        height = int(height)
        tx_pos = int(tx_pos)
        txout_pos = int(txout_pos)
        tx_type = -1

        i = script_GetOp(store.binout(script))

        nameNewDict = {}

        try:
            name_op = i.next()[0]
            if name_op == NAME_NEW:
                tx_hash = i.next()[1]
                if tx_hash not in nameNewDict:
                    nameNewDict[tx_hash] = True
                    yield NameNew(height, tx_pos, txout_pos, from_pubkey_id, to_pubkey_id, tx_hash)
            elif name_op == NAME_FIRSTUPDATE:
                tx_type = 1
                raw_name = i.next()[1]
                name = raw_name.decode("ISO-8859-1")
                tx_rand = i.next()[1]
                value = i.next()[1]
                tx_hash = hash160(tx_rand + raw_name)
                yield NameFirstUpdate(height, tx_pos, txout_pos, from_pubkey_id, to_pubkey_id, name, tx_rand, value, tx_hash)
            elif name_op == NAME_UPDATE:
                raw_name = i.next()[1]
                name = raw_name.decode("ISO-8859-1")
                value = i.next()[1]
                yield NameUpdate(height, tx_pos, txout_pos, from_pubkey_id, to_pubkey_id, name, value)
            else:
                logger.warning("Unexpected first op: %s", repr(name_op))
                continue
        except StopIteration:
            logger.warning("Strange script at %d:%d:%d",
                           height, tx_pos, txout_pos)
            continue
Ejemplo n.º 5
0
def iterate_name_updates(store, logger, chain_id):
    for height, tx_pos, txout_pos, script in store.selectall(
            """
        SELECT cc.block_height, bt.tx_pos, txout.txout_pos,
               txout.txout_scriptPubKey
          FROM chain_candidate cc
          JOIN block_tx bt ON (cc.block_id = bt.block_id)
          JOIN txout ON (bt.tx_id = txout.tx_id)
         WHERE cc.chain_id = ?
           AND txout_scriptPubKey >= ? AND txout_scriptPubKey < ?
         ORDER BY cc.block_height, bt.tx_pos, txout.txout_pos""",
        (chain_id, store.binin(NAME_SCRIPT_MIN),
         store.binin(NAME_SCRIPT_MAX))):
        height = int(height)
        tx_pos = int(tx_pos)
        txout_pos = int(txout_pos)

        i = script_GetOp(store.binout(script))
        try:
            name_op = i.next()[0]
            if name_op == NAME_NEW:
                continue  # no effect on name map
            elif name_op == NAME_FIRSTUPDATE:

                is_first = True
                name = i.next()[1]
                newtx_hash = i.next()[1]
                #rand = i.next()[1]  # XXX documented as optional; is it?
                value = i.next()[1]
            elif name_op == NAME_UPDATE:
                is_first = False
                name = i.next()[1]
                value = i.next()[1]
            else:
                logger.warning("Unexpected first op: %s", repr(name_op))
                continue
        except StopIteration:
            logger.warning("Strange script at %d:%d:%d", height, tx_pos,
                           txout_pos)
            continue
        yield (height, tx_pos, txout_pos, is_first, name, value)
Ejemplo n.º 6
0
def iterate_name_updates(store, logger, chain_id):
    for height, tx_pos, txout_pos, script in store.selectall("""
        SELECT cc.block_height, bt.tx_pos, txout.txout_pos,
               txout.txout_scriptPubKey
          FROM chain_candidate cc
          JOIN block_tx bt ON (cc.block_id = bt.block_id)
          JOIN txout ON (bt.tx_id = txout.tx_id)
         WHERE cc.chain_id = ?
           AND txout_scriptPubKey >= ? AND txout_scriptPubKey < ?
         ORDER BY cc.block_height, bt.tx_pos, txout.txout_pos""",
                                     (chain_id, store.binin(NAME_SCRIPT_MIN),
                                      store.binin(NAME_SCRIPT_MAX))):
        height = int(height)
        tx_pos = int(tx_pos)
        txout_pos = int(txout_pos)

        i = script_GetOp(store.binout(script))
        try:
            name_op = i.next()[0]
            if name_op == NAME_NEW:
                continue  # no effect on name map
            elif name_op == NAME_FIRSTUPDATE:
                
                is_first = True
                name = i.next()[1]
                newtx_hash = i.next()[1]
                #rand = i.next()[1]  # XXX documented as optional; is it?
                value = i.next()[1]
            elif name_op == NAME_UPDATE:
                is_first = False
                name = i.next()[1]
                value = i.next()[1]
            else:
                logger.warning("Unexpected first op: %s", repr(name_op))
                continue
        except StopIteration:
            logger.warning("Strange script at %d:%d:%d",
                           height, tx_pos, txout_pos)
            continue
        yield (height, tx_pos, txout_pos, is_first, name, value)