How to use the neo.lib.util.u64 function in neo

To help you get started, we’ve selected a few neo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Nexedi / neoppod / neo / storage / database / mysqldb.py View on Github external
def getTransaction(self, tid, all = False):
        tid = util.u64(tid)
        q = self.query
        r = q("SELECT oids, user, description, ext, packed, ttid"
              " FROM trans WHERE `partition` = %d AND tid = %d"
              % (self._getReadablePartition(tid), tid))
        if not r and all:
            r = q("SELECT oids, user, description, ext, packed, ttid"
                  " FROM ttrans WHERE tid = %d" % tid)
        if r:
            oids, user, desc, ext, packed, ttid = r[0]
            oid_list = splitOIDField(tid, oids)
            return oid_list, user, desc, ext, bool(packed), util.p64(ttid)
github Nexedi / neoppod / neo / storage / handlers / replication.py View on Github external
def _doAskCheckSerialRange(self, min_oid, min_tid, max_tid,
            length=RANGE_LENGTH):
        replicator = self.app.replicator
        partition = replicator.getCurrentOffset()
        neo.lib.logging.debug("Check serial range (offset=%s, min_oid=%x,"
            " min_tid=%x, max_tid=%x, length=%s)", partition, u64(min_oid),
            u64(min_tid), u64(max_tid), length)
        check_args = (min_oid, min_tid, max_tid, length, partition)
        replicator.checkSerialRange(*check_args)
        return Packets.AskCheckSerialRange(*check_args)
github Nexedi / neoppod / neo / master / transactions.py View on Github external
"""
        Compute the next TID based on the current time and check collisions.
        Also, if ttid is not None, divisor is mandatory adjust it so that
            tid % divisor == ttid % divisor
        while preserving
            min_tid < tid
        If ttid is None, divisor is ignored.
        When constraints allow, prefer decreasing generated TID, to avoid
        fast-forwarding to future dates.
        """
        tid = tidFromTime(time())
        min_tid = self._last_tid
        if tid <= min_tid:
            tid = addTID(min_tid, 1)
        if ttid is not None:
            remainder = u64(ttid) % divisor
            delta_remainder = remainder - u64(tid) % divisor
            if delta_remainder:
                tid = addTID(tid, delta_remainder)
                if tid <= min_tid:
                    tid = addTID(tid, divisor)
                assert u64(tid) % divisor == remainder, (dump(tid), remainder)
                assert min_tid < tid, (dump(min_tid), dump(tid))
        self._last_tid = tid
        return self._last_tid
github Nexedi / neoppod / neo / storage / database / sqlite.py View on Github external
def _deleteRange(self, partition, min_tid=None, max_tid=None):
        sql = " WHERE partition=?"
        args = [partition]
        if min_tid:
            sql += " AND ? < tid"
            args.append(util.u64(min_tid))
        if max_tid:
            sql += " AND tid <= ?"
            args.append(util.u64(max_tid))
        q = self.query
        q("DELETE FROM trans" + sql, args)
        sql = " FROM obj" + sql
        data_id_list = [x for x, in q("SELECT DISTINCT data_id" + sql, args)
                          if x]
        q("DELETE" + sql, args)
        self._pruneData(data_id_list)
github Nexedi / neoppod / neo / storage / handlers / replication.py View on Github external
def _doAskCheckTIDRange(self, min_tid, max_tid, length=RANGE_LENGTH):
        replicator = self.app.replicator
        partition = replicator.getCurrentOffset()
        neo.lib.logging.debug(
            "Check TID range (offset=%s, min_tid=%x, max_tid=%x, length=%s)",
            partition, u64(min_tid), u64(max_tid), length)
        replicator.checkTIDRange(min_tid, max_tid, length, partition)
        return Packets.AskCheckTIDRange(min_tid, max_tid, length, partition)
github Nexedi / neoppod / neo / storage / database / btree.py View on Github external
def finishTransaction(self, tid):
        tid = util.u64(tid)
        self._popTransactionFromTObj(tid, True)
        ttrans = self._ttrans
        try:
            data = ttrans[tid]
        except KeyError:
            pass
        else:
            del ttrans[tid]
            self._trans[tid] = data
github Nexedi / neoppod / neo / client / iterator.py View on Github external
def __str__(self):
        oid = u64(self.oid)
        tid = u64(self.tid)
        args = (oid, tid, len(self.data), self.data_txn)
        return 'Record %s:%s: %s (%s)' % args
github Nexedi / neoppod / neo / storage / database / sqlite.py View on Github external
def deleteTransaction(self, tid):
        tid = util.u64(tid)
        self.query("DELETE FROM trans WHERE partition=? AND tid=?",
            (self._getPartition(tid), tid))