import pymysql from sqlalchemy.dialects.mysql import LONGTEXT from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, Text, create_engine, Index from sqlalchemy.orm import sessionmaker from config import setting from project_log import setup_mylogger logger = setup_mylogger(logfile="log/store_block_info.log") pymysql.install_as_MySQLdb() def _check_database(database_name): conn = pymysql.connect(host=setting.MYSQLDATABASE["host"], user=setting.MYSQLDATABASE["user"], passwd=setting.MYSQLDATABASE["passwd"]) cursor = conn.cursor() cursor.execute( """create database if not exists {} """.format(database_name)) cursor.close() conn.commit() conn.close() _check_database("block_info") engine = create_engine( 'mysql://%s:%s@%s/%s' %
#!/usr/bin/env python # coding=utf-8 import json from decimal import Decimal from pymongo import MongoClient import time import requests from config import setting from project_log import setup_mylogger logger = setup_mylogger(logfile="log/store_tx.log") def md5_for_transfer_record(tx_id, address_from, address_to, value, contract): import hashlib src = "{}{}{}{}{}".format(tx_id, address_from, address_to, value, contract).encode() m1 = hashlib.md5() m1.update(src) return m1.hexdigest() class MongodbEth(object): def __init__(self): self.client = MongoClient(setting.MONGO_URI) self.db = self.client.eth_table def insert_block_height(self, block_height): self.db.BlockHeightForStoreTx.insert_one({"height": block_height})
import pymysql from sqlalchemy.dialects.mysql import LONGTEXT from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, Text, create_engine,UniqueConstraint from sqlalchemy.orm import sessionmaker from config import setting from project_log import setup_mylogger logger=setup_mylogger(logfile="log/store_token_holding.log") pymysql.install_as_MySQLdb() block_info_engine = create_engine('mysql://%s:%s@%s/%s' %(setting.MYSQLDATABASE["user"], setting.MYSQLDATABASE["passwd"], setting.MYSQLDATABASE["host"], setting.MYSQLDATABASE["db_block_info"]), pool_recycle=3600,pool_size=100,pool_pre_ping=True) neo_table_engine = create_engine('mysql://%s:%s@%s/%s' %(setting.MYSQLDATABASE["user"], setting.MYSQLDATABASE["passwd"], setting.MYSQLDATABASE["host"], setting.MYSQLDATABASE["db_neo_table"] ), pool_recycle=3600,pool_size=100,pool_pre_ping=True)
import pymysql from sqlalchemy.dialects.mysql import LONGTEXT from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, Text, create_engine, UniqueConstraint from sqlalchemy.orm import sessionmaker from config import setting from project_log import setup_mylogger logger = setup_mylogger() pymysql.install_as_MySQLdb() def _check_database(database_name): conn = pymysql.connect(host=setting.MYSQLDATABASE["host"], user=setting.MYSQLDATABASE["user"], passwd=setting.MYSQLDATABASE["passwd"]) cursor = conn.cursor() cursor.execute( """CREATE DATABASE IF NOT EXISTS {} DEFAULT CHARSET utf8 COLLATE utf8_general_ci;""" .format(database_name)) cursor.close() conn.commit() conn.close() _check_database("neo_table") block_info_engine = create_engine(
import pymysql from sqlalchemy.dialects.mysql import LONGTEXT from sqlalchemy.ext.declarative import declarative_base from sqlalchemy import Column, Integer, String, Text, create_engine, UniqueConstraint from sqlalchemy.orm import sessionmaker from config import setting from project_log import setup_mylogger logger = setup_mylogger(logfile="log/store_vout.log") pymysql.install_as_MySQLdb() def _check_database(database_name): conn = pymysql.connect(host=setting.MYSQLDATABASE["host"], user=setting.MYSQLDATABASE["user"], passwd=setting.MYSQLDATABASE["passwd"]) cursor = conn.cursor() cursor.execute( """CREATE DATABASE IF NOT EXISTS {} DEFAULT CHARSET utf8 COLLATE utf8_general_ci;""" .format(database_name)) cursor.close() conn.commit() conn.close() _check_database("neo_table") block_info_engine = create_engine(
import time import requests import os from project_log import setup_mylogger NEOSCAN_GETBLOCKHEIGHT_URL = "https://api.neoscan.io/api/main_net/v1/get_height" LOCAL_NEONODE_URL = "http://127.0.0.1:10332" # LOCAL_NEONODE_URL = "http://47.254.43.76:10332" logger = setup_mylogger(logfile="log/watch_neo_node.log") ENVIRON = os.environ NO_REPLY_EMAIL_PAWD = ENVIRON.get("EMAIL_PASSWORD") def execute_shell_command(command): import os os.system(command) def request_block_height_from_neoscan(url): res = requests.get(url) if res.status_code == 200: return res.json().get("height") return None def request_block_height_from_local(url): data = {"jsonrpc": "2.0", "method": "getblockcount", "params": [], "id": 1} res = requests.post(url, json=data) if res.status_code == 200:
#!/usr/bin/env python # coding=utf-8 import json from etherscan.accounts import Account from pymongo import MongoClient import time from config import setting from project_log import setup_mylogger logger = setup_mylogger(logfile="log/store_transfer_tx_from_ethscan.log") def md5_for_transfer_record(tx_id, address_from, address_to, value, contract): import hashlib src = "{}{}{}{}{}".format(tx_id, address_from, address_to, value, contract).encode() m1 = hashlib.md5() m1.update(src) return m1.hexdigest() class MongodbEth(object): def __init__(self): self.client = MongoClient(setting.MONGO_URI) self.db = self.client.eth_table self.db.TransferRecord.create_index([("addressFrom", 1)]) self.db.TransferRecord.create_index([("addressTo", 1)]) self.db.TransferRecord.create_index([("asset", 1)]) self.db.TransferRecord.create_index([("txId", 1)])