
- Create project structure with FastAPI - Add database models for blocks, transactions, arbitrages, pools, and DEXes - Implement Solana RPC client for fetching blockchain data - Create arbitrage detection algorithm - Implement comprehensive API endpoints for analytics - Set up database migrations with Alembic - Add detailed project documentation generated with BackendIM... (backend.im) Co-Authored-By: Claude <noreply@anthropic.com>
26 lines
1.2 KiB
Python
26 lines
1.2 KiB
Python
from datetime import datetime
|
|
from sqlalchemy import Column, Integer, String, DateTime, BigInteger, Float
|
|
from sqlalchemy.orm import relationship
|
|
|
|
from app.db.base_class import Base
|
|
|
|
|
|
class Block(Base):
|
|
"""Solana blockchain block model."""
|
|
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
block_height = Column(BigInteger, unique=True, index=True, nullable=False)
|
|
block_hash = Column(String, unique=True, index=True, nullable=False)
|
|
parent_block_hash = Column(String, index=True, nullable=True)
|
|
slot = Column(BigInteger, index=True, nullable=False)
|
|
block_time = Column(DateTime, index=True, nullable=True)
|
|
transactions_count = Column(Integer, nullable=False, default=0)
|
|
successful_transactions_count = Column(Integer, nullable=False, default=0)
|
|
processed = Column(Integer, default=0, nullable=False) # 0=not processed, 1=processed
|
|
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
|
|
|
# Relationships
|
|
transactions = relationship("Transaction", back_populates="block", cascade="all, delete-orphan")
|
|
|
|
def __repr__(self):
|
|
return f"<Block(height={self.block_height}, hash={self.block_hash})>" |