Пример #1
0
 def poll(self):
     logger.info('-----------etc_recharge start-----------')
     session = Session()
     self.init_block_info(session)
     while True:
         try:
             operator = self.erc_op_class(ipc_path=config.etc_ipc_path)
             # 获取区块信息及交易列表
             block_info = session.query(self.block_info_coll).filter_by(
                 coin_type=self.coin_category).first()
             checked_block_info = self.check_block(block_info, operator)
             if not checked_block_info:
                 continue
             tx_list = operator.get_block_tx_id_list(
                 checked_block_info['block_num'])
             # 遍历交易列表
             for tx_id in tx_list:
                 self.tx_process(session, hexstr_if_str(to_hex, tx_id),
                                 operator)
             logger.info(
                 f'pull block finished: {checked_block_info["block_num"]}')
         except Exception as e:
             logger.exception(e)
         else:
             # 存储交易区块信息
             block_info.block_num = checked_block_info['block_num']
             block_info.block_hash = checked_block_info['block_hash']
             try:
                 session.commit()
             except Exception as e:
                 logger.exception("检查回滚区块时发生错误{}".format(e))
                 session.rollback()
         time.sleep(3)
Пример #2
0
def main():
    session = Session()
    init_block_info(session)
    while True:
        try:
            operator = ERC20Token(provider_endpoint=config.eth_wallet_url)
            # 获取区块信息及交易列表
            block_info = session.query(block_info_document).filter_by(
                coin_type=coin_type).first()
            checked_block_info = check_block(block_info, operator)

            if not checked_block_info:
                continue

            tx_list = operator.get_block_tx_id_list(
                checked_block_info['block_num'])
            # 遍历交易列表
            for tx_id in tx_list:
                tx_process(session, hexstr_if_str(to_hex, tx_id), operator)
            logger.info(
                f'pull block finished: {checked_block_info["block_num"]}')
        except Exception as e:
            logger.exception(e)
        else:
            block_info.block_hash = checked_block_info['block_hash']
            block_info.block_num = checked_block_info['block_num']
            try:
                session.commit()
            except Exception as e:
                logger.exception("更新区块发生错误{}".format(e))
                session.rollback()
        time.sleep(3)
Пример #3
0
 def poll(self):
     logger.info("----------- eth_askfee_tx_listener start -----------")
     session = Session()
     while True:
         try:
             coin_ask_fee_list = session.query(
                 self.coin_ask_fee_coll).filter_by(
                 status=AskFeeStatusEnum.WAIT_CONFIRM, coin_series="ETH").all()
             for item in coin_ask_fee_list:
                 self.monitor_tx_id(session, item)
             try:
                 session.commit()
             except Exception as e:
                 logger.error("缴费交易轮寻更新数据库失败")
                 logger.exception(e)
                 session.rollback()
         except Exception as e:
             logger.exception("缴费交易轮寻发生错误{}".format(e))
         time.sleep(10)
Пример #4
0
 def poll(self):
     logger.info("----------- eth_gather_tx_listener start -----------")
     session = Session()
     while True:
         try:
             transfer_list = session.query(
                 self.coin_transfer_coll).filter_by(
                 status=GatherStatusEnum.GATHERING,
                 coin_series="ETH").all()
             for item in transfer_list:
                 self.monitor_tx_id(session, item)
             try:
                 session.commit()
             except Exception as e:
                 logger.error("汇聚交易数据库操作时发生错误")
                 logger.exception(e)
                 session.rollback()
         except Exception as e:
             logger.exception("汇聚交易轮寻发生错误{}".format(e))
         time.sleep(10)
Пример #5
0
 def poll(self):
     logger.info("----------- erc_charge_withdraw start -----------")
     session = Session()
     while True:
         try:
             withdraw_list = session.query(
                 self.withdraw_coll).filter_by(**{
                     'coin_series': 'ETH',
                     'informed': InformEnum.NO
                 }).all()
             for item in withdraw_list:
                 self.monitor_tx_id(session, item, 'withdraw')
             try:
                 session.commit()
             except Exception as e:
                 logger.error("提币轮寻数据库操作失败")
                 logger.exception(e)
                 session.rollback()
             else:
                 logger.info("提币轮寻更新成功")
         except Exception as e:
             logger.exception("提币交易确认轮寻发生错误{}".format(e))
         time.sleep(10)
Пример #6
0
 def poll(self):
     logger.info("----------- erc_recharge_tx start -----------")
     session = Session()
     while True:
         try:
             recharge_list = session.query(
                 self.coin_recharge_coll).filter_by(
                     **{
                         'coin_series': 'ETH',
                         'informed': InformEnum.NO
                     }).all()
             for item in recharge_list:
                 self.monitor_tx_id(session, item)
             try:
                 session.commit()
             except Exception as e:
                 session.rollback()
                 logger.error("冲币执行数据库commit失败")
                 logger.exception(e)
             else:
                 logger.info("冲币更新数据成功")
         except Exception as e:
             logger.exception("充币交易确认轮寻发生错误{}".format(e))
         time.sleep(10)