Example #1
0
def process_in_crypto(CurrencyTitle):
    List = None
    crypto_acc = "trade_stock"
    if CurrencyTitle in ("ZEC"):
        crypto_acc = ""
    Crypton = CryptoAccount(CurrencyTitle, crypto_acc)
    print "process %s" % CurrencyTitle
    TimeLastBlock = None
    TopBlock = int(Crypton.getblockcount())
    print "top block %i" % TopBlock
    try:
        TimeLastBlock = VolatileConsts.objects.get(
            Name="last_process_block_%s" % CurrencyTitle)
        TimeLastBlock.Value = int(TimeLastBlock.Value)

    except VolatileConsts.DoesNotExist:
        count = TopBlock - 100
        TimeLastBlock = VolatileConsts(Name="last_process_block_%s" %
                                       CurrencyTitle,
                                       Value=str(count))
        TimeLastBlock.save()

    Time = int(TimeLastBlock.Value)
    print "start process block %i " % Time

    user_system = User.objects.get(id=1)
    CurrencyInstance = Currency.objects.get(title=CurrencyTitle)
    getcontext().prec = crypton.settings.TRANS_PREC
    block_hash = Crypton.getblockhash(Time - 200)
    print "block %s" % block_hash
    List = Crypton.listsinceblock(block_hash)
    List = List["transactions"]
    process_in_crypto_low(List, user_system, CurrencyInstance)
    TimeLastBlock.Value = str(TopBlock)
    TimeLastBlock.save()