Spaces:
Sleeping
Sleeping
Commit
·
ba497ab
1
Parent(s):
516d3e1
Add application file
Browse files- .DS_Store +0 -0
- README.md +1 -0
- data/.DS_Store +0 -0
- pages/4_🕵️♀️_Ethscriptions Data.py +27 -34
- video/.DS_Store +0 -0
.DS_Store
ADDED
|
Binary file (8.2 kB). View file
|
|
|
README.md
CHANGED
|
@@ -3,6 +3,7 @@ title: Eths
|
|
| 3 |
emoji: 📚
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: yellow
|
|
|
|
| 6 |
sdk: streamlit
|
| 7 |
sdk_version: 1.26.0
|
| 8 |
app_file: app.py
|
|
|
|
| 3 |
emoji: 📚
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: yellow
|
| 6 |
+
python_version: 3.9.2
|
| 7 |
sdk: streamlit
|
| 8 |
sdk_version: 1.26.0
|
| 9 |
app_file: app.py
|
data/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|
pages/4_🕵️♀️_Ethscriptions Data.py
CHANGED
|
@@ -8,7 +8,6 @@ from datetime import datetime, timezone
|
|
| 8 |
import threading
|
| 9 |
import base64
|
| 10 |
|
| 11 |
-
test1 = '233'
|
| 12 |
# 使用你的Ethereum节点的RPC地址
|
| 13 |
w3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/9bbc614b8a1d49d59869e97d0ee3bf61"))
|
| 14 |
|
|
@@ -22,7 +21,9 @@ ethscrptions_db_file = os.path.join(parent_dir, 'data', 'ethscriptions_data.db')
|
|
| 22 |
ethscriptions_con = sqlite3.connect(ethscrptions_db_file)
|
| 23 |
ethscriptions_cur = ethscriptions_con.cursor()
|
| 24 |
|
|
|
|
| 25 |
def get_eths_data():
|
|
|
|
| 26 |
# Initialize connection to SQLite database
|
| 27 |
eths_conn = sqlite3.connect(eths_db_file)
|
| 28 |
eths_cur = eths_conn.cursor()
|
|
@@ -72,7 +73,7 @@ def get_eths_data():
|
|
| 72 |
eths_cur.execute('INSERT INTO eths_data VALUES (?,?,?,?,?,?,?,?,?)', data)
|
| 73 |
eths_conn.commit()
|
| 74 |
except Exception as e:
|
| 75 |
-
|
| 76 |
time.sleep(60)
|
| 77 |
|
| 78 |
|
|
@@ -101,24 +102,22 @@ def get_ethscriptions_data():
|
|
| 101 |
# 获取该区块中所有交易的列表
|
| 102 |
transactions = block['transactions']
|
| 103 |
for tx in transactions:
|
| 104 |
-
print(tx['input'])
|
| 105 |
-
print(type(tx['input']))
|
| 106 |
input_data = tx['input']
|
| 107 |
|
| 108 |
if input_data.startswith(r"0x646174613a2c"):
|
| 109 |
# if bytes.fromhex(input_data).startswith(b"data:,"):
|
| 110 |
|
| 111 |
existing_data = ethscriptions_thread_cur.execute("SELECT * FROM data WHERE data=?",
|
| 112 |
-
|
| 113 |
|
| 114 |
if not existing_data:
|
| 115 |
timestamp = datetime.fromtimestamp(block['timestamp'], tz=timezone.utc)
|
| 116 |
|
| 117 |
ethscriptions_thread_cur.execute('''INSERT INTO data (block_time, block_number, data, owner, hash)
|
| 118 |
VALUES (?, ?, ?, ?, ?)''',
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
|
| 123 |
ethscriptions_thread_con.commit()
|
| 124 |
print(f'-----{input_data}-----')
|
|
@@ -176,12 +175,12 @@ if eths_data:
|
|
| 176 |
|
| 177 |
eths_stakers = st.metric(label='ETHS TVL', value=f'${eths_data[0][8]:,.0f}')
|
| 178 |
|
| 179 |
-
|
| 180 |
ethscriptions_cur.execute("SELECT block_number FROM process_blocks")
|
| 181 |
result = ethscriptions_cur.fetchone()
|
| 182 |
processed_block = result[0]
|
| 183 |
latest_block_number = w3.eth.block_number
|
| 184 |
-
st.markdown(
|
|
|
|
| 185 |
|
| 186 |
download = st.checkbox('⏬️', value=False)
|
| 187 |
if download:
|
|
@@ -191,33 +190,27 @@ if download:
|
|
| 191 |
ethscrptions_db_file = os.path.join(parent_dir, 'data', 'ethscriptions_data.db')
|
| 192 |
st.download_button(
|
| 193 |
label='下载数据库',
|
| 194 |
-
data=open(ethscrptions_db_file,'rb'),
|
| 195 |
file_name='ethscriptions_data.db',
|
| 196 |
mime='application/octet-stream'
|
| 197 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
# 修改状态值
|
| 199 |
-
|
| 200 |
-
ethscriptions_cur.execute("UPDATE thread_start_state SET state = ?", (
|
| 201 |
ethscriptions_con.commit()
|
| 202 |
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
| 206 |
-
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
|
| 210 |
-
|
| 211 |
-
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
eths_thread = threading.Thread(target=get_eths_data)
|
| 215 |
-
ethscriptions_thread = threading.Thread(target=get_ethscriptions_data)
|
| 216 |
-
|
| 217 |
-
# 启动线程
|
| 218 |
-
eths_thread.start()
|
| 219 |
-
ethscriptions_thread.start()
|
| 220 |
-
|
| 221 |
-
# 等待线程结束
|
| 222 |
-
eths_thread.join()
|
| 223 |
-
ethscriptions_thread.join()
|
|
|
|
| 8 |
import threading
|
| 9 |
import base64
|
| 10 |
|
|
|
|
| 11 |
# 使用你的Ethereum节点的RPC地址
|
| 12 |
w3 = Web3(Web3.HTTPProvider("https://mainnet.infura.io/v3/9bbc614b8a1d49d59869e97d0ee3bf61"))
|
| 13 |
|
|
|
|
| 21 |
ethscriptions_con = sqlite3.connect(ethscrptions_db_file)
|
| 22 |
ethscriptions_cur = ethscriptions_con.cursor()
|
| 23 |
|
| 24 |
+
|
| 25 |
def get_eths_data():
|
| 26 |
+
global eths_conn, eths_cur
|
| 27 |
# Initialize connection to SQLite database
|
| 28 |
eths_conn = sqlite3.connect(eths_db_file)
|
| 29 |
eths_cur = eths_conn.cursor()
|
|
|
|
| 73 |
eths_cur.execute('INSERT INTO eths_data VALUES (?,?,?,?,?,?,?,?,?)', data)
|
| 74 |
eths_conn.commit()
|
| 75 |
except Exception as e:
|
| 76 |
+
print(e)
|
| 77 |
time.sleep(60)
|
| 78 |
|
| 79 |
|
|
|
|
| 102 |
# 获取该区块中所有交易的列表
|
| 103 |
transactions = block['transactions']
|
| 104 |
for tx in transactions:
|
|
|
|
|
|
|
| 105 |
input_data = tx['input']
|
| 106 |
|
| 107 |
if input_data.startswith(r"0x646174613a2c"):
|
| 108 |
# if bytes.fromhex(input_data).startswith(b"data:,"):
|
| 109 |
|
| 110 |
existing_data = ethscriptions_thread_cur.execute("SELECT * FROM data WHERE data=?",
|
| 111 |
+
(input_data,)).fetchone()
|
| 112 |
|
| 113 |
if not existing_data:
|
| 114 |
timestamp = datetime.fromtimestamp(block['timestamp'], tz=timezone.utc)
|
| 115 |
|
| 116 |
ethscriptions_thread_cur.execute('''INSERT INTO data (block_time, block_number, data, owner, hash)
|
| 117 |
VALUES (?, ?, ?, ?, ?)''',
|
| 118 |
+
(
|
| 119 |
+
timestamp, tx['blockNumber'], input_data, tx['to'],
|
| 120 |
+
tx['hash'].hex()))
|
| 121 |
|
| 122 |
ethscriptions_thread_con.commit()
|
| 123 |
print(f'-----{input_data}-----')
|
|
|
|
| 175 |
|
| 176 |
eths_stakers = st.metric(label='ETHS TVL', value=f'${eths_data[0][8]:,.0f}')
|
| 177 |
|
|
|
|
| 178 |
ethscriptions_cur.execute("SELECT block_number FROM process_blocks")
|
| 179 |
result = ethscriptions_cur.fetchone()
|
| 180 |
processed_block = result[0]
|
| 181 |
latest_block_number = w3.eth.block_number
|
| 182 |
+
st.markdown(
|
| 183 |
+
f'EthPen Ethscriptions Index Status:当前 Ethereum 最高区块:{latest_block_number},已处理区块:{processed_block}')
|
| 184 |
|
| 185 |
download = st.checkbox('⏬️', value=False)
|
| 186 |
if download:
|
|
|
|
| 190 |
ethscrptions_db_file = os.path.join(parent_dir, 'data', 'ethscriptions_data.db')
|
| 191 |
st.download_button(
|
| 192 |
label='下载数据库',
|
| 193 |
+
data=open(ethscrptions_db_file, 'rb'),
|
| 194 |
file_name='ethscriptions_data.db',
|
| 195 |
mime='application/octet-stream'
|
| 196 |
)
|
| 197 |
+
|
| 198 |
+
# 查询state列的值
|
| 199 |
+
ethscriptions_cur.execute("SELECT state FROM thread_start_state")
|
| 200 |
+
state_value = ethscriptions_cur.fetchone()[0]
|
| 201 |
+
if state_value == "0":
|
| 202 |
# 修改状态值
|
| 203 |
+
new_state = "1"
|
| 204 |
+
ethscriptions_cur.execute("UPDATE thread_start_state SET state = ?", (new_state,))
|
| 205 |
ethscriptions_con.commit()
|
| 206 |
|
| 207 |
+
eths_thread = threading.Thread(target=get_eths_data)
|
| 208 |
+
ethscriptions_thread = threading.Thread(target=get_ethscriptions_data)
|
| 209 |
+
|
| 210 |
+
# 启动线程
|
| 211 |
+
eths_thread.start()
|
| 212 |
+
ethscriptions_thread.start()
|
| 213 |
+
|
| 214 |
+
# 等待线程结束
|
| 215 |
+
eths_thread.join()
|
| 216 |
+
ethscriptions_thread.join()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
video/.DS_Store
ADDED
|
Binary file (6.15 kB). View file
|
|
|