-
Notifications
You must be signed in to change notification settings - Fork 0
/
models.py
68 lines (61 loc) · 2.28 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
from sqlalchemy import Column, ForeignKey, Integer, BigInteger, String, Boolean, DateTime, Float, create_engine, Numeric
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.orm import relationship
from sqlalchemy.dialects.postgresql import ARRAY, JSONB, BYTEA
from decouple import config
Base = declarative_base()
class EdenBlock(Base):
__tablename__ = 'eden_block'
block_number = Column(BigInteger, primary_key=True)
id = Column(String(100))
author = Column(String(100))
difficulty = Column(String(100))
gas_limit = Column(BigInteger)
gas_used = Column(BigInteger)
block_hash = Column(String(100))
from_active_producer = Column(Boolean)
parent_hash = Column(String(100))
uncle_hash = Column(String(100))
size = Column(BigInteger)
state_root = Column(String(100))
timestamp = Column(DateTime)
total_difficulty = Column(String(100))
transactions_root = Column(String(100))
receipts_root = Column(String(100))
epoch_number = Column(BigInteger)
class Epoch(Base):
__tablename__ = 'epochs'
id = Column(String(100), primary_key=True)
finalized = Column(Boolean)
epoch_number = Column(BigInteger)
start_block = Column(String(100))
start_block_number = Column(BigInteger)
end_block = Column(String(100))
end_block_number = Column(BigInteger)
producer_blocks = Column(BigInteger)
all_blocks = Column(BigInteger)
producer_blocks_ratio = Column(Float)
class Distribution(Base):
__tablename__ = 'distribution'
id = Column(String(100), primary_key=True)
distribution_number = Column(BigInteger)
distributor = Column(String(100))
timestamp = Column(DateTime)
merkle_root = Column(String(100))
metadata_url = Column(String(100))
epoch_number = Column(BigInteger)
token_total = Column(String(100))
class DistributionBalance(Base):
__tablename__ = 'distribution_balance'
id = Column(Integer, primary_key=True)
miner = Column(String(100))
balance_index = Column(BigInteger)
distribution_number = Column(BigInteger)
amount = Column(Numeric)
epoch_number = Column(BigInteger)
PSQL_ENDPOINT = config('PSQL_ENDPOINT')
engine = create_engine(PSQL_ENDPOINT)
Base.metadata.create_all(engine)