Пример #1
0
def __update(blockChain, preHeight):
    CoinSqlite3().exec_sql(
        'Update BlockInfo set `version`=?,`previous_block_hash`=?,`merkle_root`=?,`timestamp`=?,`difficulty`=?,`nonce`=?,`state`=?,`height`=? where hash = ?',
        blockChain.version, blockChain.previous_block_hash,
        blockChain.merkle_root, blockChain.timestamp, blockChain.difficulty,
        blockChain.nonce, blockChain.state, preHeight + 1, blockChain.hash())
    for tx in blockChain.txs:
        TransactionDao.save(tx)
Пример #2
0
def __insert(blockChain, preHeight):
    CoinSqlite3().exec_sql(
        'INSERT INTO BlockInfo(hash, version,previous_block_hash,merkle_root,timestamp,difficulty,nonce,state,height) VALUES (?,?,?,?,?,?,?,?,?)',
        blockChain.hash(), blockChain.version, blockChain.previous_block_hash,
        blockChain.merkle_root, blockChain.timestamp, blockChain.difficulty,
        blockChain.nonce, blockChain.state, preHeight + 1)
    for tx in blockChain.txs:
        TransactionDao.save(tx)
Пример #3
0
def insert(tx):
    if TransactionDao.isExist(tx):
        return

    if isCFTransation(tx):
        if TransactionDao.isPreCFlinked(tx):
            return
        if tx.cf_header.lack_amount <= 0:
            tx.cf_header.end_time = int(time.time())

    updatePreOutState(tx)
    # 保存新交易
    TransactionDao.save(tx)

    # 如果是众筹成功 刷新所有众筹交易的状态为不可用
    if isCFTransation(tx):
        if tx.cf_header.lack_amount <= 0:
            TransactionDao.updateAllLinkedCFTransationOut(tx)
            TransactionOutDao.updateEndTimeToZero(tx)
            #把众筹初始发起的tx  usedstate设置为1
            TransactionDao.updateFirstCFState(tx)