Exemplo n.º 1
0
    def OnProcessNewBlock(self, block, added, changed, deleted):
        for tx in block.FullTransactions:

            if self.IsWalletTransaction(tx):
                db_tx = None
                try:
                    db_tx = Transaction.get(Hash=tx.Hash.ToBytes())
                except Exception as e:
                    pass

                ttype = tx.Type
                if type(ttype) is bytes:
                    ttype = int.from_bytes(tx.Type, 'little')

                if not db_tx:
                    db_tx = Transaction.create(
                        Hash=tx.Hash.ToBytes(),
                        TransactionType=ttype,
                        RawData=tx.ToArray(),
                        Height=block.Index,
                        DateTime=block.Timestamp
                    )
                else:
                    db_tx.Height = block.Index

                db_tx.save()

        self.OnCoinsChanged(added, changed, deleted)
Exemplo n.º 2
0
    def OnProcessNewBlock(self, block, added, changed, deleted):
        for tx in block.FullTransactions:

            if self.IsWalletTransaction(tx):
                db_tx = None
                try:
                    db_tx = Transaction.get(Hash=tx.Hash.ToBytes())
                except Exception as e:
                    pass

                ttype = tx.Type
                if type(ttype) is bytes:
                    ttype = int.from_bytes(tx.Type, 'little')

                if not db_tx:
                    db_tx = Transaction.create(
                        Hash=tx.Hash.ToBytes(),
                        TransactionType=ttype,
                        RawData=tx.ToArray(),
                        Height=block.Index,
                        DateTime=block.Timestamp
                    )
                else:
                    db_tx.Height = block.Index

                db_tx.save()

        self.OnCoinsChanged(added, changed, deleted)
Exemplo n.º 3
0
    def Rebuild(self):
        super(UserWallet, self).Rebuild()

        for c in Coin.select():
            c.delete_instance()
        for tx in Transaction.select():
            tx.delete_instance()

        self.__log.debug("deleted coins and transactions %s %s " %
                         (Coin.select().count(), Transaction.select().count()))
Exemplo n.º 4
0
    def Rebuild(self):
        try:
            super(UserWallet, self).Rebuild()

            logger.debug("wallet rebuild: deleting %s coins and %s transactions" %
                         (Coin.select().count(), Transaction.select().count()))

            for c in Coin.select():
                c.delete_instance()
            for tx in Transaction.select():
                tx.delete_instance()
        except Exception as e:
            print("Could not rebuild %s " % e)
Exemplo n.º 5
0
 def GetTransactions(self):
     transactions = []
     for db_tx in Transaction.select():
         raw = binascii.unhexlify(db_tx.RawData)
         tx = CoreTransaction.DeserializeFromBufer(raw, 0)
         transactions.append(tx)
     return transactions
    def Rebuild(self):
        self._lock.acquire()
        try:
            super(UserWallet, self).Rebuild()

            logger.debug("wallet rebuild: deleting %s coins and %s transactions" %
                         (Coin.select().count(), Transaction.select().count()))

            for c in Coin.select():
                c.delete_instance()
            for tx in Transaction.select():
                tx.delete_instance()
        finally:
            self._lock.release()

        logger.debug("wallet rebuild complete")
Exemplo n.º 7
0
 def GetTransactions(self):
     transactions = []
     for db_tx in Transaction.select():
         raw = binascii.unhexlify(db_tx.RawData)
         tx = CoreTransaction.DeserializeFromBufer(raw, 0)
         transactions.append(tx)
     return transactions
Exemplo n.º 8
0
    def Rebuild(self):
        self._lock.acquire()
        try:
            super(UserWallet, self).Rebuild()

            logger.debug("wallet rebuild: deleting %s coins and %s transactions" %
                         (Coin.select().count(), Transaction.select().count()))

            for c in Coin.select():
                c.delete_instance()
            for tx in Transaction.select():
                tx.delete_instance()
        finally:
            self._lock.release()

        logger.debug("wallet rebuild complete")
Exemplo n.º 9
0
 def LoadTransactions(self):
     return Transaction.select()
Exemplo n.º 10
0
 def LoadTransactions(self):
     return Transaction.select()